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

Request to include request headers into span attributes for http #1510

Open
alextricity25 opened this issue Feb 17, 2025 · 1 comment
Open

Comments

@alextricity25
Copy link

Is your feature request related to a problem?

Python and Java auto instrumentation each support an environment variable OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST which allows for specified HTTP Headers to be automatically included in spans as attributes. The PHP auto instrumentation implementation doesn't have such a mechanism, AFAIK.

Describe the solution you'd like
I would like to define a list of HTTP request headers to be included into the span attributes

Describe alternatives you've considered
I've looked into https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_headers but this seems to add headers, which isn't what I want. I want to include the already existing headers as span attributes.

Additional context
We were looking at our spans generated by the php otel auto-instrumentation, and noticed that several of the headers we were looking for are not included. This eventually let us to conclude that these spans don't include the request headers, which is not ideal.

@brettmc
Copy link
Collaborator

brettmc commented Feb 17, 2025

psr-18 and most of the http-based auto-instrumentations have something like https://github.com/open-telemetry/opentelemetry-php-contrib/blob/main/src/Instrumentation/Psr18/src/Psr18Instrumentation.php#L71 - we don't use the same header as Python because it's not part of the spec, but the capability is coming in declarative configuration

I haven't personally tested using otel.instrumentation.http.request_headers, and it looks like it needs to be configured in php.ini or .htaccess, but it should do what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants