feat: add prototype for EnvVarsCarrier (env var propagation)#3521
feat: add prototype for EnvVarsCarrier (env var propagation)#3521jsurany wants to merge 16 commits into
Conversation
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3521 +/- ##
======================================
Coverage 82.9% 83.0%
======================================
Files 130 131 +1
Lines 27484 27586 +102
======================================
+ Hits 22796 22902 +106
+ Misses 4688 4684 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TommyCpp
left a comment
There was a problem hiding this comment.
Most implementation leave this in API and the carrier is SDK agnostic, so we should move it to api create(opentelemetry/src/propagation)
moved the change. Would it be OK if I rebase? I didn't update my git config for this PR and as a result the EasyCLA thinks that the early commits are coming from a different account (one that I don't use anymore). |
|
EasyCLA is failing. |
* fix(sdk): enforce W3C Baggage limits in BaggagePropagator extract path BaggagePropagator::extract_with_context parsed each list-member of an inbound `baggage` header in full -- splitting on `;`, decoding the percent-encoded key/value, allocating Vec<String> for property segments, and constructing a KeyValueMetadata -- before passing the result to Baggage::insert_with_metadata. The storage-side limit (MAX_KEY_VALUE_PAIRS=64, MAX_LEN_OF_ALL_PAIRS=8192) silently dropped entries once full, but per-entry allocation work continued for every attacker-supplied member. This change applies the W3C Baggage limits at the propagator boundary: - Reject the header when its byte length exceeds MAX_BAGGAGE_LENGTH (8192). The header is logged at warn level and an empty Context is returned. - Cap the outer comma-split iterator with .take(MAX_BAGGAGE_ITEMS) so parsing stops after 64 list-members regardless of header content. The injection path is unchanged; the existing Baggage storage type already enforces both limits when entries are added. Two unit tests cover the new behavior: - extract_drops_header_exceeding_max_length verifies that an oversized header produces an empty Baggage. - extract_caps_entry_count_at_max_baggage_items verifies that more than 64 syntactically valid entries are truncated to 64. References: - W3C Baggage limits: https://www.w3.org/TR/baggage/#limits Signed-off-by: tonghuaroot <tonghuaroot@gmail.com> * Clarify CHANGELOG: 8192-byte over-limit drops, 64-entry over-limit truncates Address reviewer feedback that 'dropped at the propagator boundary' was ambiguous: the over-length header path drops the whole header, while the over-count path truncates to the first 64 list members. Split the wording into two clauses so the behavior is unambiguous. Signed-off-by: tonghuaroot <tonghuaroot@gmail.com> --------- Signed-off-by: tonghuaroot <tonghuaroot@gmail.com>
Co-authored-by: Scott Gerring <scottgerring@users.noreply.github.com>
|
Sorry, I had to rebase in order to change the contact info for past commits for EasyCLA to pass |
|
It might make sense to keep this as a draft until the following issue is resolved: open-telemetry/opentelemetry-specification#5143. PTAL when you have a chance, and feel free to share your thoughts there. Waiting could help us avoid extra PRs and save reviewers some time. |
|
Converted to draft per above. Waiting for open-telemetry/opentelemetry-specification#5143 |
open-telemetry/opentelemetry-specification#5144 is going to be merged soon. Feel free to adopt necessary changes in this PR. |
@pellared the
It feels like the overall design would be more consistent if If we make it so EDIT - correction is that |
|
@jsurany |
|
Ok I think I understand now. |
|
Is this a draft on purpose? |
There was a problem hiding this comment.
Pull request overview
Adds an environment-variable-backed carrier to the opentelemetry crate’s propagation module to support the OpenTelemetry environment variable context propagation (“env-carriers”) mechanism discussed in #3285.
Changes:
- Introduces
EnvVarsCarrierimplementingExtractorandInjector, including key normalization logic andfrom_env/emptyconstructors. - Re-exports
EnvVarsCarrierfromopentelemetry::propagation. - Adds Cargo
[env]config entries used by unit tests that validatefrom_env()behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
opentelemetry/src/propagation/mod.rs |
Wires the new carrier module into the propagation API surface via re-export. |
opentelemetry/src/propagation/env_vars_carrier.rs |
Implements the env-var carrier, normalization helpers, and unit tests. |
.cargo/config.toml |
Defines test environment variables used by EnvVarsCarrier::from_env() tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Propagates name-value pairs via environment variables. | ||
| /// | ||
| /// This propagator provides a mechanism for propagating context information | ||
| /// across process boundaries using environment variables, usually for when | ||
| /// network protocols are not applicable. |
| /// Create a new `EnvVarsCarrier` object, built from environment variables. | ||
| /// Environment variables are fetched and normalized at construction time. | ||
| pub fn from_env() -> Self { |
| pub use composite::TextMapCompositePropagator; | ||
| pub use env_vars_carrier::EnvVarsCarrier; | ||
| pub use text_map_propagator::TextMapPropagator; |
|
Hey, sorry the effort under which I made this PR has wrapped up and I now need to wait for a different set of approvals to go through to continue work on this PR. It could take up to 6 weeks. I'll finish up the remaining comments when I have approval again. |
|
This is only a prototype and at this point of time we rather need an actual experimental implementation. I suggest closing. |
|
Superseded by #3574 |
Fixes #3285
Design discussion issue (if applicable) N/A?
Changes
Please provide a brief description of the changes here.
EnvVarsCarriertype that implementsExtractorandInjectortraits, with the normalization described in the spec.EnvVarsCarrierpulls the environment infrom_env, with normalizationExtractortrait seemed straightforward, butInjectorfelt up to interpretation. In this design, the injection only modifies the internal map on theEnvVarsCarriertype (keys are always normalized)..cargo/config.tomlfor testing the carrier's initialization. This seemed better than addingunsafecode to the tests.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changesWould like some feedback on if this is the correct way to have implemented this feature, and advice on managing the changelog.