You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opentelemetry tracing provider doesn't respect client_sampling when both traceparent and x-client-trace-id header is present #35721
Title: opentelemetry tracing provider doesn't respect client_sampling when both traceparent and x-client-trace-id header is present
Description:
Hi, we enabled opentelemtry tracing provider and we found out client_sampling in tracing is not applied if the incoming request has both traceparent and x-client-trace-id header. We also use x-request-id by default. Even if we set client_sampling to 0%, envoy still exports spans based on sample flag in parent context(traceparent) header. And envoy code seems align with the behavior. I wonder if this is the expected behavior, which means if envoy can extract the parent context from the incoming request, envoy will respect the sampling decision in the downstream, then no sampling decision will be applied.
in conn-manager, envoy startspan no matter what tracing decision made earlier:
in opentelemetry tracer, if envoy can extract parent context, which is a valid traceparent header, it will start a span from parent context, ignoring tracing decision made earlier.
Because in the envoy documentation(link), client_samping is:
Target percentage of requests managed by this HTTP connection manager that will be force traced if the x-client-trace-id header is set.
So I thought if the x-client-trace-id is present, no matter if parent context can be extracted, client_sampling should be respected. Please correct me if I understand it wrong here.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
So, my conclusion is: When it's a root span, started by Envoy, the sampling percentage config should be applied and work. But when it's not a root span (meaning it is part of a existing trace), then Envoy simply respects the previous sampling decision which is the correct and expected behavior.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
Activity
adisuissa commentedon Aug 15, 2024
cc @AlexanderEllis @htuch as code owners.
cc @wbpcode who has lots of tracing expertise.
yuanguolang commentedon Aug 15, 2024
Because in the envoy documentation(link),
client_sampingis:So I thought if the
x-client-trace-idis present, no matter if parent context can be extracted, client_sampling should be respected. Please correct me if I understand it wrong here.github-actions commentedon Oct 1, 2024
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
joaopgrassi commentedon Oct 2, 2024
When
if (!extractor.propagationHeaderPresent()) {is true, meaning, there's notraceparent, Envoy invokesstartSpanand sets the sampling decision that is already there, which should be the percentage one if you don't have anything else configured (a custom sampler in the OTel tracer). It will call this line https://github.com/envoyproxy/envoy/blob/main/source/extensions/tracers/opentelemetry/tracer.cc#L261 which should set whatever tracing decision Envoy made.Now, if the incoming request has a
traceparentheader, then the tracer respects that and uses whatever sampling decision was already recorded: https://github.com/envoyproxy/envoy/blob/main/source/extensions/tracers/opentelemetry/tracer.cc#L284. This is the expected behavior, otherwise you may break the entire trace chain.So, my conclusion is: When it's a root span, started by Envoy, the sampling percentage config should be applied and work. But when it's not a root span (meaning it is part of a existing trace), then Envoy simply respects the previous sampling decision which is the correct and expected behavior.
github-actions commentedon Nov 1, 2024
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
github-actions commentedon Nov 8, 2024
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
tracing: make otel tracer respect envoy tracing decision (#45830)