Repository navigation
Conversation
…Telemetry tracer Since envoyproxy#45830 the OpenTelemetry driver applies the HCM tracing decision as a final veto, also when a sampled parent span context is extracted. With random_sampling below 100 percent, every hop rewrites a sampled parent to unsampled. The HCM now reports whether a request was only not selected by random_sampling (no x-client-trace-id, valid request ID, passed overall_sampling). It carries this as Tracing::Decision::parent_sampling_allowed. The new opt-in honor_parent_sampling_decision field lets the OpenTelemetry tracer keep the parent's or the sampler's decision in that case only. Default behavior is unchanged. Follows the design proposed in envoyproxy#49638.
…g_decision - Re-apply the refreshed HCM decision to a span that kept its parent's decision. Spans get a defaulted refreshTracingDecision() hook; only the OpenTelemetry span that took the honor branch acts on it. - Compute parent_sampling_allowed for internally created streams against the target route without mutating the tracing headers again. - Require a valid W3C traceparent before the parent overrides the Envoy decision.
…g_decision - Require a well-formed request ID before allowing the parent's decision. RequestIDExtension gets isValidRequestId(), defaulting to getInteger(); the UUID extension checks the full UUID form. - Compute parent_sampling_allowed only when the tracer reads it, through a defaulted usesParentSamplingAllowed() on Tracer and Driver, so other tracers and the option-off path do no extra runtime lookup. - Document that this build reads the x-sendbird-traceparent header.
…g_decision - With the option on, apply a refreshed not-traced decision to every parent-context span the driver started, not only to spans that took the honor branch. Option off is unchanged. - Declare the direct Abseil strings dependency of the UUID extension.
Remove the route refresh handling added in review rounds 1 and 3. A span that continues a parent context now ignores later route refreshes, as in Envoy 1.38 and as the base branch already does for spans that do not use the local decision. refreshTracing() keeps the base behavior.
…oss internal redirects The recreated stream inherits the original stream's parent_sampling_allowed and only narrows it for the target route. A client_sampling rejection now survives a route that removed x-client-trace-id.
…nt_sampling_decision An internally created stream does not mutate tracing headers again, so it now keeps the default veto. This removes the redirect helper and the recreateStream() copy; recreateStream() matches the base branch.
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.

JIRA: https://sendbird.atlassian.net/browse/CPLAT-13467
Summary
Adds an opt-in OpenTelemetry tracer field,
honor_parent_sampling_decision(defaultfalse). When it istrue, a span that continues a valid parent span context keeps the parent's sampled flag (or the configured sampler's decision) if the request was only not selected byrandom_sampling. This follows the design proposed upstream in envoyproxy#49638.Why
Driver::startSpanapplies the HCM tracing decision as a final veto (applyTracingDecisionsetssampled=false), also when a sampled parent context was extracted.randomSamplingPercentage: 0. So every sidecar hop rewrites the propagatedx-sendbird-traceparentflag from01to00, and the services behind it drop their spans.x-sendbird-traceparent: ...-01loses sampling after one sidecar. Sent directly to the app, the flag is honored.Change
ConnectionManagerUtility::mutateTracingRequestHeadernow returns the trace reason plusparent_sampling_allowed. It istrueonly when the request has nox-client-trace-id, has a well-formed request ID, was not selected byrandom_sampling, and passesoverall_sampling. To compute this,overall_samplingis also evaluated for requests not selected byrandom_sampling. It only reads runtime and changes no header.Tracing::TracerandTracing::DrivergetusesParentSamplingAllowed()(defaultfalse),TracerImplforwards it, and the OpenTelemetry driver returns the config field. Other tracers and the option-off path therefore do no extra runtime lookup.RequestIDExtensiongetsisValidRequestId(). Its default keeps today's rule (getInteger()succeeds), and the UUID extension checks the full 8-4-4-4-12 hex form.getInteger()alone reads only the last 8 hex digits, so an ID such asxxxxxxxx-xxxx-xxxx-xxxx-xxxx09f48a28would otherwise count as valid.ActiveStream::Stateand setsTracing::Decision::parent_sampling_allowed(new field, defaultfalse) intraceRequest(), only when the reason isNotTraceable. A health check gets reasonHealthCheck, so it staysfalse.x-request-id:x-request-idonly encodes aReasonand propagates across hops, but this signal is per hop. Adding it toStreamInfowould change a public interface and every implementation and mock. Only span start reads the signal, so the stream state is enough.useLocalDecision() == false.refreshTracing()keeps the base behavior and does not compute the signal.parent_sampling_allowedstaysfalseand the base veto applies.recreateStream()matches the base branch.true, a valid W3Ctraceparent(checked withTracing::isValidTraceParent(), so versionffis rejected), reasonNotTraceableandparent_sampling_allowed, the span skips the veto. The non-honor path still uses the existing extractor. Root spans (no parent context) are not changed.overall_sampling,client_samplingforx-client-trace-id, missing or invalid request ID, and health checks.x-sendbird-traceparent(andx-sendbird-tracestate), not the standardtraceparentheader.bool honor_parent_sampling_decision = 9;inOpenTelemetryConfig(next free field in this branch). Upstream opentelemetry: option to honor a sampled parent context when a request is only not selected byrandom_samplingenvoyproxy/envoy#49638 proposes 13, so the number can conflict if upstream adds other fields first. Changelog fragment added underchangelogs/current/new_features/.flowchart TD A[Request with a valid parent span context] --> B{HCM decision traced?} B -- yes --> S[Keep parent or sampler decision] B -- no --> C{honor_parent_sampling_decision set?} C -- no --> V[Veto: span unsampled, flag 00 injected] C -- yes --> D{reason NotTraceable and parent_sampling_allowed?} D -- no --> V D -- yes --> S subgraph HCM sets parent_sampling_allowed only when H1[No x-client-trace-id] H2[Valid request ID] H3[Not selected by random_sampling] H4[Passes overall_sampling] H5[Not a health check] endHow to enable
Istio does not expose this field. It needs an EnvoyFilter patch on the OpenTelemetry provider config, or a change in istiod.
Testing
Not compiled or tested locally. The local Docker VM ran out of memory while building the test targets, so this PR relies on CI. Formatted with
clang-format21.1.8 on the changed hunks; the pinned format check has not been run.Codex review rounds:
overall_samplingrejection to a span that kept its parent's decision; internal redirects lost the signal; the honor branch accepted atraceparentwith versionff. Declined: a separate request ID format check.isValidRequestId()like the round 1 span hook; proto docs now namex-sendbird-traceparent; the extraoverall_samplinglookup now runs only when the tracer reads the signal.isValidRequestId(), because Envoy's own UUID handling never checks the variant, and clients or proxies that send UUID-shaped IDs with another variant would silently lose parent sampling; the shape check already blocks the parse-only IDs raised in rounds 1 and 2.disableLocalDecision()contract, upstream child spans), and the diff kept growing.client_samplingrejection when the original route removedx-client-trace-id. The recreated stream now inherits the first-pass result.traceparentwith extension fields, which is pre-existing extractor behavior on the base branch and out of scope.New and updated tests:
conn_manager_utility_test: allowed when only not selected by random sampling; not allowed for overall sampling rejection (both before and after selection), selection by random sampling,client_samplingrejection ofx-client-trace-id, missing or invalid request ID, anduse_request_id_for_trace_sampling: false. Existing tests are unchanged, because the extra read only happens when the tracer reads the signal.conn_manager_impl_test:ParentSamplingAllowedReachesTracer(parameterized on overall sampling) checks the decision passed to the tracer.conn_manager_utility_test:ParentSamplingNotComputedWhenTracerDoesNotUseIt(nooverall_samplinglookup) andParentSamplingNotAllowedWithMalformedRequestId.request_id/uuid/config_test:IsValidRequestId.tracer_impl_test:UsesParentSamplingAllowedFollowsDriver.conn_manager_impl_test:ParentSamplingAllowedNotComputedForTracerThatIgnoresIt.conn_manager_impl_test:InternalRedirectDoesNotAllowParentSampling(the redirected stream's decision hasparent_sampling_allowed == false).opentelemetry_tracer_impl_test: versionffparent is vetoed;opentelemetry_tracer_impl_test: option off vetoes a sampled parent; option on keeps parent01(span exported, injected flag01) and parent00; vetoes when the HCM does not allow it or the reason isHealthCheck; root spans unchanged; with thealways_onsampler the sampler decision is kept and still vetoed when not allowed.Known limits and open questions
overall_samplingrejects the request does not unsample a span that kept its parent's decision.-01parent. Enable it only on sidecars or where the parent context is trusted.opentelemetry_tracer_impl_test.cc(UseLocalDecisionFalse,PropagatedSpanWithAlwaysOnSamplerStillHonorsEnvoyDecision,AlwaysOnSamplerExportsWhenEnvoyDecisionAllowsTracing) set a literaltraceparentheader, but this fork readsx-sendbird-traceparent. They may already fail on the base branch. This PR does not change them; CI will show.AI assistance
The change and the tests were prepared with AI assistance (Claude Code).