[API] Environment Variables as Context Propagation Carriers#3834
[API] Environment Variables as Context Propagation Carriers#3834marcalff merged 11 commits intoopen-telemetry:mainfrom
Conversation
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3834 +/- ##
==========================================
+ Coverage 89.99% 90.04% +0.05%
==========================================
Files 225 226 +1
Lines 7170 7195 +25
==========================================
+ Hits 6452 6478 +26
+ Misses 718 717 -1
🚀 New features to boost your workflow:
|
|
Thanks for the feature.
The spec proposes either a single interface (Propagator), or two separate interfaces (Injector, Extractor) for propagation. Given that opentelemetry-cpp uses a single interface with a TextMapCarrier, I think keeping a single class makes sense.
A shared pointer is better, to avoid misuse.
Every operating system will have a character limit, not only windows. Given that the code does not do a
The Carrier is supposed to be ignorant of which propagator is used, only propagators will know the keys. Conceptually, the environment variable carrier is supposed to work with any propagator, including B3, so it should not hard code any known keys. Notice how none of the carriers, including the I propose to not implement
For HTTP, when two threads make an http call and need to inject keys to talk to two different services, each thread will use its own carrier to inject into its own http message. For environment variables, the pattern should be the same, the This PR is looking good already. A great addition will be an example with a parent process that forks a child, so people can see in practice how to implement the whole thing. |
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
|
Thanks for the review. I have added a basic example that should work in unix environments. Do we need an example for windows as well? |
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
marcalff
left a comment
There was a problem hiding this comment.
LGTM, thanks for the feature.
See a minor comment.
Thanks for the example added. It looks good as is, it shows how to use the environment carrier. |
|
Could you review as well, given that this change touches the API ? Thanks. |
api/include/opentelemetry/context/propagation/environment_carrier.h
Outdated
Show resolved
Hide resolved
| if (value != nullptr) | ||
| { | ||
| // Cache for lifetime management (string_view requires stable storage) | ||
| cache_[std::string(key)] = std::string(value); |
There was a problem hiding this comment.
Get is marked as const, but it does mutate the internal state cache_. Perhaps this should be documented in the API doc?
Signed-off-by: Harish <140232061+perhapsmaple@users.noreply.github.com>
[API] Environment Variables as Context Propagation Carriers (open-telemetry#3834)
Fixes #3817
Written with inspiration from: Go PR
Changes
Need help from maintainers on below:
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes