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

Don't normalize headers with "hyphen -> underscore" #3104

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Kludex
Copy link
Contributor

@Kludex Kludex commented Dec 13, 2024

I think this can be considered a breaking change, and I'm not sure how it affects other services, but it fixes the behavior according to the OTel specification.

Changes

  • Remove replace - to _ on the HTTP header normalizer.
  • Update test suite.
  • Update documentation.

Details

The current behavior is incorrect according to the HTTP RFCs regarding HTTP headers (because they are just case-insensitive), and the OpenTelemetry specification itself.

Screenshot 2024-12-13 at 11 19 26

The following headers are not the same:

Content-Type: application/json
Content_Type: application/json

But those two, should be treated as same:

Content-Type: application/json
content-type: application/json

@Kludex Kludex requested a review from a team as a code owner December 13, 2024 10:18
@github-actions github-actions bot requested a review from shalevr December 13, 2024 10:19
Comment on lines 186 to 193
def normalise_request_header_name(header: str) -> str:
key = header.lower().replace("-", "_")
key = header.lower()
return f"http.request.header.{key}"


def normalise_response_header_name(header: str) -> str:
key = header.lower().replace("-", "_")
key = header.lower()
return f"http.response.header.{key}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are the relevant changes. The rest is just to comply with this.

@Kludex
Copy link
Contributor Author

Kludex commented Dec 13, 2024

I don't know what's wrong with the docs... 😢

CHANGELOG.md Outdated Show resolved Hide resolved
…telemetry/instrumentation/tornado/__init__.py
@Kludex
Copy link
Contributor Author

Kludex commented Dec 20, 2024

Thanks @emdneto

@lzchen
Copy link
Contributor

lzchen commented Jan 2, 2025

Relevant pr in semconv: open-telemetry/semantic-conventions#369

Would this breaking change fall under semconv migration? @emdneto @aabmass @xrmx wdyt?

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

Successfully merging this pull request may close these issues.

4 participants