-
Notifications
You must be signed in to change notification settings - Fork 845
Fix OtlpExporterOptionsExtensions.GetHeaders incorrectly throwing for comma in header value #6511
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
base: main
Are you sure you want to change the base?
Conversation
… comma in header value
int commaIndex = headersSpan.IndexOf(','); | ||
ReadOnlySpan<char> pair; | ||
if (commaIndex == -1) | ||
var key = headersSpan.Slice(0, nextEqualIndex).Trim().ToString(); |
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.
likely able to avoid the additional string allocations and only use spans for the new parsing logic
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.
How do you mean? I'm already using Span for the parsing, but there's no way around allocating a string for the key and value at some point.
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.
initial read looked like there were multiple ToString calls. looks reasonable to push those calls as late as possible
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.
Do you have a concrete idea of how to do so? I'm not even sure if performance improvements in this part of the code matter that much. This isn't even on any hot path right?
I feel like the headers shouldn't be a string at all TBH. If we're sending headerS (multiples), it sounds like this should be a I'm not mentionning Else it will turn into another footgun TBH |
@tebeco I like the idea. Which could be fine. It would just add churn for everyone currently using the string option. |
the other thing i haven't looked at all is performance what i remember is in aspnetcore they use a special StringValues value type because generally a header often only have one value i have no knowledge of the OTEL specifics here im just adding it here in case it rings a bell for someone i hope it doesn't explode the scope of that evol' |
yeah, i feel the pain, dealing with env var and array is generally not fun unless you split env var to multiple aggregate yourself and then map it i don't think there's such thing as escape in env var |
Fixes #6510
Changes
Updates
OtlpExporterOptionsExtensions.GetHeaders
to no longer throw for commas inside of header values.Previously a valid header value like
VL-Stream-Fields=service.name,service.environment
would've thrown, since the comma would've been incorrectly interpreted as a delimiter to another header pair - now it's properly parsed.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes