Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Looking for a way to avoid traceparent header rewriting. #2440

Open
ingevarr opened this issue Dec 20, 2024 · 0 comments
Open
Labels
comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http enhancement New feature or request

Comments

@ingevarr
Copy link

ingevarr commented Dec 20, 2024

Component

OpenTelemetry.Instrumentation.Http

Is your feature request related to a problem?

HttpHandlerDiagnosticListener propagates/rewrites context irrespective of sampling decision and presence of traceparent header.

In our company we have custom client library built around HttpClient for some internal purposes. We manually create Activity and manually add traceparent header before request execution, and then suppress instrumentation with SuppressInstrumentationScope.Begin() to force underlying HttpClient to not emit it's own events to avoid duplication.

There is a problem when someone uses that library with Opentelemetry.Instrumentation.Http enabled:
HttpClient creates Activity despite the instrumentation suppressed, but doesn't touch traceparent if it already present. Although this Activity will not be recorded, it falls into HttpHandlerDiagnosticListener which rewrites present and valid traceparent header. This leads to trace corruption.

Why such behaviour was chosen? Do I have any options to change it?

What is the expected behavior?

Check presence of traceparent header before rewriting it like runtime DiagnosticsHandler does.

Which alternative solutions or features have you considered?

Add some settings to choose which behaviour to use.

Additional context

Besides current issue, it's not obvious to me why HttpClient fallback to Activity creation even if the sampler's decision is to drop it. I am trying to supress it, but as a result Activity is still being created. Moreover, it is created with Recorded == true property, but it will not be recorded actually.

@ingevarr ingevarr added the enhancement New feature or request label Dec 20, 2024
@github-actions github-actions bot added the comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant