feat(appender-tracing): stabilize span attribute propagation#3482
Draft
cijothomas wants to merge 5 commits intoopen-telemetry:mainfrom
Draft
feat(appender-tracing): stabilize span attribute propagation#3482cijothomas wants to merge 5 commits intoopen-telemetry:mainfrom
cijothomas wants to merge 5 commits intoopen-telemetry:mainfrom
Conversation
Drops the experimental_span_attributes cargo feature; span attribute
propagation is now part of the stable API surface.
Propagation is disabled by default (no per-span overhead). Users opt in
at runtime via the new builder method:
OpenTelemetryTracingBridge::builder(&provider)
.with_span_attributes(std::iter::empty::<&str>()) // copy all
.build();
OpenTelemetryTracingBridge::builder(&provider)
.with_span_attributes(["session.id"]) // allowlist
.build();
Migration: drop the experimental_span_attributes feature from Cargo.toml,
and replace with_span_attribute_allowlist(keys) with
with_span_attributes(keys). Pass an empty iterator to preserve the
previous "copy everything" default.
Closes open-telemetry#3481.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3482 +/- ##
======================================
Coverage 83.7% 83.7%
======================================
Files 126 126
Lines 25386 25507 +121
======================================
+ Hits 21255 21374 +119
- Misses 4131 4133 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace the single with_span_attributes method (which required an empty iterator sentinel to mean 'copy all') with two methods: - enable_span_attributes(bool): turn the feature on or off. - with_span_attribute_allowlist(keys): restrict to specific keys; also implicitly enables propagation. Semantics: - enable_span_attributes(true) enables, preserving any allowlist already configured. - enable_span_attributes(false) disables and clears the allowlist. - with_span_attribute_allowlist replaces any prior allowlist (last call wins) and implicitly enables. Adds tests for the new interaction semantics.
Follow-up to the separate-methods design: the two methods are now fully orthogonal. with_span_attribute_allowlist no longer implicitly enables propagation. enable_span_attributes(false) no longer clears any configured allowlist. To prevent silent misconfiguration, build() emits an otel_warn! when an allowlist is set but enable_span_attributes(true) was not called. Adds an internal-logs feature on opentelemetry-appender-tracing that forwards to opentelemetry/internal-logs, required by the otel_warn! call.
…el Span 'Propagation' overloads the OTel term for context propagation. 'Enrichment' is what Java/.NET use for this same pattern (and matches the original introducing PR's title). Updates CHANGELOG, doc comments, internal comments, the otel_warn! message, and bench docs. Also explicitly clarifies in doc comments and CHANGELOG that 'span' here refers to a tracing::span! from the tracing crate, NOT an opentelemetry::trace::Span.
Re-runs both logs and span-attributes benches on the current toolchain and updates the documented results. No real perf regression vs main: the apparent variance between runs is bench-to-bench noise (~15% jitter on this hardware), confirmed by running both code paths twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the API shape discussed in #3481.
Note: throughout this PR, "span" refers to a
tracing::span!from thetracingcrate (the source the appender consumes), not anopentelemetry::trace::Span.Changes
Removes the
experimental_span_attributescargo feature. Tracing-span attribute enrichment (copying attributes from activetracingspans onto each emitted log record) is now part of the stable API surface ofopentelemetry-appender-tracing.Disabled by default. Users who don't enable enrichment pay no per-span overhead (
on_new_span/on_record/ scope walk all return early).Two orthogonal builder methods to configure runtime behavior:
Semantics:
enable_span_attributes(bool)toggles enrichment on or off.with_span_attribute_allowlist(keys)configures the filter.enable_span_attributes(true)is also called.with_span_attribute_allowlistwithoutenable_span_attributes(true)is a no-op;build()emits anotel_warn!to surface the misconfiguration.Adds an
internal-logscargo feature onopentelemetry-appender-tracing(forwarding toopentelemetry/internal-logs) so theotel_warn!call frombuild()participates in the standard internal-logs feature wiring used by other crates in the workspace.Terminology
The PR uses "enrichment" rather than "propagation". Propagation is already an overloaded term in OpenTelemetry (W3C TraceContext, baggage, etc.), and "enrichment" matches the term used by the Java and .NET SDKs for this exact pattern, as well as the title of the original PR (#3282) that introduced the experimental feature.
Migration
Users of the previous
experimental_span_attributesfeature need to:experimental_span_attributesfeature fromCargo.toml..enable_span_attributes(true)call on the builder.with_span_attribute_allowlist(keys)calls are preserved as-is.Tests
All existing tests have been migrated off the cargo feature gate. New tests added covering the orthogonal semantics:
tracing_appender_span_attributes_disabled_by_default— enrichment off by default.tracing_appender_enable_span_attributes_copies_all—enable_span_attributes(true)without allowlist copies all.tracing_appender_allowlist_alone_is_no_op—with_span_attribute_allowlistalone (withoutenable_span_attributes(true)) does not enrich anything.tracing_appender_enable_then_allowlist_order_independent— order of the two builder methods does not matter.Test counts:
cargo test -p opentelemetry-appender-tracing --all-features --lib: 14 passed, 2 ignored.cargo clippy -p opentelemetry-appender-tracing --all-targets --all-features -- -Dwarnings: clean.cargo clippy -p opentelemetry-appender-tracing --all-targets --no-default-features -- -Dwarnings: clean.cargo clippy --workspace --all-targets --all-features -- -Dwarnings: clean.cargo doc -p opentelemetry-appender-tracing --no-deps --all-features: clean.Out of Scope
span.namepropagation (feat(appender-tracing): propagate span name to logs #3466) is intentionally not part of this PR. Discussion continues separately.experimental_metadata_attributescargo feature is unchanged; that's a separate stabilization decision.Refs
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changesenable_span_attributes, keepswith_span_attribute_allowlist, addsinternal-logscargo feature, removesexperimental_span_attributesfeature)