Skip to content

Commit 3d5c78b

Browse files
committed
remove custom context of botocore instrumentation (#367)
specifically, the `service` property clashes with the existing `context.service` property in the Elasticsearch storage backend closes #367
1 parent 6b1e2de commit 3d5c78b

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* implemented de-dotting of tag names and context keys (#353)
6+
* wrote a quickfix for the boto3/botocore instrumentation (#367)
67

78
## v4.0.2
89
[Check the diff](https://github.com/elastic/apm-agent-python/compare/v4.0.1...v4.0.2)

elasticapm/instrumentation/packages/botocore.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ def call(self, module, method, wrapped, instance, args, kwargs):
1717
target_endpoint = instance._endpoint.host
1818
parsed_url = urlparse.urlparse(target_endpoint)
1919
if "." in parsed_url.hostname:
20-
service, region = parsed_url.hostname.split(".", 2)[:2]
20+
service = parsed_url.hostname.split(".", 2)[0]
2121
else:
22-
service, region = parsed_url.hostname, None
22+
service = parsed_url.hostname
2323

2424
signature = "{}:{}".format(service, operation_name)
25-
extra_data = {"service": service, "region": region, "operation": operation_name}
2625

27-
with capture_span(signature, "ext.http.aws", extra_data, leaf=True):
26+
with capture_span(signature, "ext.http.aws", leaf=True):
2827
return wrapped(*args, **kwargs)

tests/instrumentation/botocore_tests.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ def test_botocore_instrumentation(mock_make_request, instrument, elasticapm_clie
2424
span = elasticapm_client.events[SPAN][0]
2525

2626
assert span["name"] == "ec2:DescribeInstances"
27-
assert span["context"]["service"] == "ec2"
28-
assert span["context"]["region"] == "us-west-2"
29-
assert span["context"]["operation"] == "DescribeInstances"
3027

3128

3229
def test_nonstandard_endpoint_url(instrument, elasticapm_client):
@@ -39,6 +36,3 @@ def test_nonstandard_endpoint_url(instrument, elasticapm_client):
3936
span = elasticapm_client.events[SPAN][0]
4037

4138
assert span["name"] == "example:DescribeInstances"
42-
assert span["context"]["service"] == "example"
43-
assert span["context"]["region"] is None
44-
assert span["context"]["operation"] == "DescribeInstances"

0 commit comments

Comments
 (0)