Skip to content

Commit b82627b

Browse files
committed
Update changelogs + fix lint
1 parent 58f77f5 commit b82627b

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

instrumentation/opentelemetry-instrumentation-botocore/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Add propagator injection for botocore calls
5+
([#181](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/181))
46

57
## Version 0.13b0
68

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,21 @@
5656
from botocore.client import BaseClient
5757
from wrapt import ObjectProxy, wrap_function_wrapper
5858

59+
from opentelemetry import propagators
5960
from opentelemetry.instrumentation.botocore.version import __version__
6061
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
6162
from opentelemetry.sdk.trace import Resource
62-
from opentelemetry import propagators
6363
from opentelemetry.trace import SpanKind, get_tracer
6464

6565
logger = logging.getLogger(__name__)
6666

67+
# pylint: disable=unused-argument
68+
def _patched_endpoint_prepare_request(wrapped, instance, args, kwargs):
69+
request = args[0]
70+
headers = request.headers
71+
propagators.inject(type(headers).__setitem__, headers)
72+
return wrapped(*args, **kwargs)
73+
6774

6875
class BotocoreInstrumentor(BaseInstrumentor):
6976
"""A instrumentor for Botocore
@@ -89,7 +96,7 @@ def _instrument(self, **kwargs):
8996
wrap_function_wrapper(
9097
"botocore.endpoint",
9198
"Endpoint.prepare_request",
92-
self._patched_prepare_request,
99+
_patched_endpoint_prepare_request,
93100
)
94101

95102
def _uninstrument(self, **kwargs):
@@ -151,12 +158,6 @@ def _patched_api_call(self, original_func, instance, args, kwargs):
151158

152159
return result
153160

154-
def _patched_prepare_request(self, wrapped, instance, args, kwargs):
155-
request = args[0]
156-
headers = request.headers
157-
propagators.inject(type(headers).__setitem__, headers)
158-
return wrapped(*args, **kwargs)
159-
160161

161162
def unwrap(obj, attr):
162163
function = getattr(obj, attr, None)

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
mock_sqs,
2626
)
2727

28-
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
2928
from opentelemetry import propagators
29+
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
3030
from opentelemetry.sdk.resources import Resource
3131
from opentelemetry.test.mock_textmap import MockTextMapPropagator
3232
from opentelemetry.test.test_base import TestBase

0 commit comments

Comments
 (0)