From 4064fcf9101b33952611125f4504c3c435cc943c Mon Sep 17 00:00:00 2001 From: Michael Stella Date: Thu, 17 Dec 2020 22:46:09 -0500 Subject: [PATCH] switch setter for injecting headers w/propagator 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 #262 --- .../src/opentelemetry/instrumentation/botocore/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py index 713a1e6a61..0ec61c73fa 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py @@ -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) return wrapped(*args, **kwargs)