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

Add environment variables for capturing Http headers #2461

Closed
wants to merge 2 commits into from

Conversation

ashu658
Copy link
Member

@ashu658 ashu658 commented Mar 31, 2022

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 configures
OTEL_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.

@ashu658 ashu658 requested review from a team March 31, 2022 09:39
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 31, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ashu658 / name: Ashutosh Goel (a3477ba)

@ashu658 ashu658 changed the title Adding environment variables for capturing Http headers Add environment variables for capturing Http headers Mar 31, 2022

See [HTTP request and response headers](https:/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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:/open-telemetry/opentelemetry-specification/pull/2276)).
- Add documentation REQUIREMENT for adding attributes at span creation.
([#2383](https:/open-telemetry/opentelemetry-specification/pull/2383)).
- Add environment variables for capturing Http headers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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
Copy link
Member

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?

Copy link
Member

@reyang reyang left a 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. |
Copy link
Contributor

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?

Copy link
Member

@dyladan dyladan Apr 5, 2022

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

Copy link
Member Author

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:/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.

Copy link
Member

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.

@arminru arminru added spec:trace Related to the specification/trace directory area:configuration Related to configuring the SDK labels Apr 5, 2022
@dyladan
Copy link
Member

dyladan commented Apr 5, 2022

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 configures
OTEL_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.

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.

@ashu658
Copy link
Member Author

ashu658 commented Apr 5, 2022

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.

@yurishkuro
Copy link
Member

@open-telemetry/technical-committee I just did a quick search and did not find any env vars of the patten OTEL_INSTRUMENTATION_*. Which is understandable because so far the env vars were limited to configuring the SDKs. Capturing headers is not an SDK function, it's an instrumentation function. We have already heard concerns with having too many env vars that need to be supported by all SDKs. Do we want to extend this even further to configuring instrumentation libraries?

@dyladan
Copy link
Member

dyladan commented Apr 5, 2022

@open-telemetry/technical-committee I just did a quick search and did not find any env vars of the patten OTEL_INSTRUMENTATION_*. Which is understandable because so far the env vars were limited to configuring the SDKs. Capturing headers is not an SDK function, it's an instrumentation function. We have already heard concerns with having too many env vars that need to be supported by all SDKs. Do we want to extend this even further to configuring instrumentation libraries?

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.

@svrnm
Copy link
Member

svrnm commented Apr 5, 2022

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.

@tigrannajaryan
Copy link
Member

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:

  • Should instrumentations be configurable via env variables?
  • Is the same configuration settable from the code?
  • Is naming of instrumentations' env variables dictated by the spec?
  • Where in the spec it should live?
  • What is the variable naming scheme? Do we choose a particular prefix like this PR suggests?
  • How to name variables which are specific for just one instrumentation and are not generic and applicable to many instrumentations like "OTEL_INSTRUMENTATION_HTTP*" is? Should the variable names be prefixed by the instrumentation library name?

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.

@svrnm
Copy link
Member

svrnm commented Apr 6, 2022

thanks @tigrannajaryan for the clarification, is #1773 the right issue to continue the conversation or is a new one doing a better job?

@tigrannajaryan
Copy link
Member

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.

@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Apr 14, 2022
@github-actions
Copy link

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:configuration Related to configuring the SDK spec:trace Related to the specification/trace directory Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants