-
Notifications
You must be signed in to change notification settings - Fork 626
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
botocore: switch setter for injecting headers into propagator #264
botocore: switch setter for injecting headers into propagator #264
Conversation
Occasionally not all of the headers available to botocore are strings. It does allow this, using the `add_header` method rather than `__setitem__`. According to the docs for `botocore.compat.HTTPHeaders`: ``` If a parameter value contains non-ASCII characters it can be specified as a three-tuple of (charset, language, value), in which case it will be encoded according to RFC2231 rules. Otherwise it will be encoded using the utf-8 charset and a language of '' ``` Whereas using `__setitem__` does not do this conversion. Fixes open-telemetry#262
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 code seems innocuous, but we should probably root cause + add a test to make sure this is right, as you mentioned. I'll comment more on the other issue.
@@ -67,7 +67,7 @@ | |||
def _patched_endpoint_prepare_request(wrapped, instance, args, kwargs): | |||
request = args[0] | |||
headers = request.headers | |||
propagators.inject(type(headers).__setitem__, headers) | |||
propagators.inject(type(headers).add_header, 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.
I don't have a lot of context on this, but we should probably add at least a test for the case you're running into.
From #262, it sounds like the most relevant part is the DyanamoDB API call. have you tried adding a mock DynamiDB api call (moto looks to support dynamodb)? It seems like a call that maps what you're executing in your service should trigger the error.
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.
Taking a closer look, the part I'm a little unclear on is, as you mentioned, what is actually causing this. I have a feeling something was injected that should not have been by the propagator. I'll comment more on the issue.
Closing this, it's not the root cause of #262 and so doesn't seem necessary. |
…ry#264) Adding the ext.dbapi and ext.mysql package.
Description
Occasionally not all of the headers available to botocore are strings - I've noticed this when a call is being made with an active span passed from a different application (specifically via gRPC). Botocore does allow this, using the
add_header
method rather than__setitem__
. According to the docs forbotocore.compat.HTTPHeaders
:Whereas using
__setitem__
does not do this conversion.I'm not convinced this is the right place to fix this, however - I've only encountered it in the situation described in #262, and haven't been able to find what would be passing in a non-string header in the first place. I'll be happy to dig more if anyone has a better suggestion, but as far as I can tell, this is also an innocuous change.
One question I have though is about how I could test this - I don't know how to simulate (in the botocore tests) having an active trace passed through from another application, so advice on this would be welcome.
Fixes #262
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
All existing tests still pass, and I've been working with the situation described in #262
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.