-
Notifications
You must be signed in to change notification settings - Fork 888
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
Add environment variables for capturing Http headers #2461
Conversation
|
ec4af0f
to
a3477ba
Compare
|
||
See [HTTP request and response headers](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers) | ||
|
||
Environment variables for capturing http request and response headers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variables for capturing http request and response headers: | |
Environment variables for capturing HTTP request and response headers: |
@@ -16,6 +16,8 @@ release. | |||
([#2276](https://github.com/open-telemetry/opentelemetry-specification/pull/2276)). | |||
- Add documentation REQUIREMENT for adding attributes at span creation. | |||
([#2383](https://github.com/open-telemetry/opentelemetry-specification/pull/2383)). | |||
- Add environment variables for capturing Http headers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add environment variables for capturing Http headers. | |
- Add environment variables for capturing HTTP headers. |
@@ -263,3 +263,19 @@ To ensure consistent naming across projects, this specification recommends that | |||
``` | |||
OTEL_{LANGUAGE}_{FEATURE} | |||
``` | |||
|
|||
## HTTP request and response headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the Status of this section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
| Name | Description | | ||
|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST | A comma-separated list of HTTP header names. HTTP server instrumentations will capture HTTP request header values for all configured header names. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these header names case-sensitive? Can you add a sentence or two saying what implementations are required to do with these variables in explicit terms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From [RFC 7230] Section 3.2. Header Fields
Each header field consists of a case-insensitive field name followed
by a colon (":"), optional leading whitespace, the field value, and
optional trailing whitespace.
emphasis mine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec which describes how to capture the HTTP headers https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers requires the captured header names to be normalised (lowercase, with - characters replaced by _) when added as span attributes. So, two different header fields (e.g. custom-header
and custom_header
) will have the same span attribute key when added as span attribute.
I am not sure if this would be okay. Please share your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the proposal for that behavior was done there by @Oberon00 #1898 (comment)
The motivation for lowercasing is obvious enough, but it seems the motivation to transform -
to _
was simply so that it would comply with the naming convention of our other semantic conventions? IMO the transformation was a mistake but one that it might be too late to rectify. In any case, configuring which headers are captured is an entirely different problem than how to represent them in OTLP. I still stand by my case that the -
to _
conversion is confusing within this header spec. Lowercasing seems fine and an obvious enough way to comply with case insensitivity.
This seems very Python-specific to me and depends heavily on the library being used and the idioms of the ecosystem. I think this would be considered very confusing by most non-python users. |
@dyladan thanks for the feedback! I was not sure if this might affect the spec so, mentioned it here. |
@open-telemetry/technical-committee I just did a quick search and did not find any env vars of the patten |
Discussed this briefly on the spec call today and I think the consensus was that instrumentation-specific configuration doesn't belong in the SDK spec. The greater takeaway was the need for a consistent configuration specification and mechanism to ensure we can provide these configurations and others to all instrumentations in a consistent manner and document them appropriately. I can't remember who exactly but I think someone volunteered to get the ball rolling in that area. |
Just for our understanding: Does this mean we should close this PR and wait for the configuration specification & mechanism to come? Assuming that this will take some time, what to do with this in the meantime, Java and Python are using it already and if other languages jump on that same topic, it would be good to have used the same variables until the config exists. |
I think we need to at least figure out some answers to these general questions so that all instrumentations follow a consistent configuration approach:
This should be ideally opened as a separate issue, discussed and after we come to an agreement on what we want to do generally, we can unblock this PR. |
thanks @tigrannajaryan for the clarification, is #1773 the right issue to continue the conversation or is a new one doing a better job? |
I think #1773 is related but a bit different, I would not wait for it since it may also take longer to resolve and will unnecessarily delay this particular task. I would advise to open a separate issue about how instrumentations should be configured via env variables. When #1773 is ready it should take care of instrumentations' configuration too. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Changes
Add environment variables to be configured for capturing http headers.
This spec (HTTP request and response headers) describes how to capture the http request/response header and add them in the span. It does not specify the environment variables need to be configured to capture the headers. This change specifies these environment variables.
Env vars proposed in the PR are already supported in Java and Python sdks.
Related PR: #1898
Additional info:
One thing that I have seen in python is that headers provided by some frameworks/libraries (e.g. wsgi based frameworks like flask) are lowercase and
-
is replaced with_
which would mean user who configuresOTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST="CusTOM_HEAder-1"
will be able to capture
custom-header-1
from request headers for some frameworks/libraries whereas for some other frameworks he won't be able to capture this header as it does not change-
to_
.(All python frameworks/libraries I saw provides case-insensitive headers but only some of them replace
-
with_
)Mentioning this info here as I am not sure if it might affect this spec or not.