-
Notifications
You must be signed in to change notification settings - Fork 650
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
Update otel-exporter OTLP headers parsing to match format specs #1869
Changes from all commits
85af83e
01eb50c
d421626
d6ef97a
d8e1367
ad281f6
c64dd22
dfe8d9e
4f33b06
cd0fdf4
eac6146
daf9d13
4b67a7d
578c4a7
1d81888
b287ab0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,9 +229,20 @@ def __init__( | |
|
||
self._headers = headers or environ.get(OTEL_EXPORTER_OTLP_HEADERS) | ||
if isinstance(self._headers, str): | ||
self._headers = tuple( | ||
tuple(item.split("=")) for item in self._headers.split(",") | ||
) | ||
temp_headers = [] | ||
for header_pair in self._headers.split(","): | ||
key, value = header_pair.split("=", maxsplit=1) | ||
key = key.strip().lower() | ||
value = value.strip() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure if we should strip individual keys and values. Generally we just strip a pair as people tend to add whitespace after comma but don't do it before/after |
||
temp_headers.append( | ||
( | ||
key, | ||
value, | ||
) | ||
) | ||
|
||
self._headers = tuple(temp_headers) | ||
|
||
self._timeout = timeout or int( | ||
environ.get(OTEL_EXPORTER_OTLP_TIMEOUT, 10) | ||
) | ||
|
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.
Your change is totally fine but you could just add another list comprehension to the existing one. Something like
since this runs only once, the extra pass over the collection should not be problem. That said, a plain loop may be more obvious/readable to some over nested comprehension. I'll leave it to you.
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.
I appreciate the feedback! I also thought about just adding another nested list comp, but it was getting a bit out of hand, so I made it into a plain loop! Thanks again 😄