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

PHP doesnt follow Otel spec to not capture custom http headers by default. #1519

Open
HeenaBansal20 opened this issue Feb 27, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@HeenaBansal20
Copy link

Does PHP supports any explicit config to capture custom http headers.?

http.request.header: Instrumentations SHOULD require an explicit configuration of which headers are to be captured. Including all request headers can be a security risk - explicit configuration helps avoid leaking sensitive information. The User-Agent header is already captured in the user_agent.original attribute. Users MAY explicitly configure instrumentations to capture them even though it is not recommended. The attribute value MUST consist of either multiple header values as an array of strings or a single-item array containing a possibly comma-concatenated string, depending on the way the HTTP library provides access to headers.

@HeenaBansal20 HeenaBansal20 added the bug Something isn't working label Feb 27, 2025
@HeenaBansal20 HeenaBansal20 changed the title Does PHP supports any explicit config to capture custom http headers.? PHP doesnt follow Otel spec to not capture custom http headers by default. Feb 27, 2025
@brettmc
Copy link
Collaborator

brettmc commented Feb 27, 2025

Most of our http-based auto-instrumentation packages allow capturing request and response headers, eg https://github.com/open-telemetry/opentelemetry-php-contrib/blob/main/src/Instrumentation/Psr18/src/Psr18Instrumentation.php#L74
Is this what you mean?

@HeenaBansal20
Copy link
Author

HeenaBansal20 commented Feb 27, 2025

yes , but this is library specific implementation ... I am also looking something like OTEL_PHP_ config whose scope is wider and applicable to each auto instrumented library ?

Do we have something like it exists for JAVA , https://opentelemetry.io/docs/zero-code/java/agent/instrumentation/http/

@HeenaBansal20
Copy link
Author

IS this setting can be used PHP wide for all instrumented libraries by otel "otel.instrumentation.http.request_headers"?
I see that curl library supports these variables. Is this specific to curl library or it can also be used with any auto I instrumented libraries.

OTEL_PHP_INSTRUMENTATION_HTTP_RESPONSE_HEADERS=content-type,server
OTEL_PHP_INSTRUMENTATION_HTTP_REQUEST_HEADERS=host,accept

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants