Skip to content

Commit

Permalink
Add "s3/"-prefix to S3 destination.service.resource
Browse files Browse the repository at this point in the history
  • Loading branch information
beniwohli committed Mar 27, 2023
1 parent a78f764 commit 24cc3e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.asciidoc
Expand Up @@ -43,7 +43,14 @@ endif::[]
* Fix spans being dropped if they don't have a name {pull}1770[#1770]
* Fix AWS Lambda support when `event` is not a dict {pull}1775[#1775]
* Fix deprecation warning with urllib3 2.0.0 pre-release versions {pull}1778[#1778]
* Fix span.context.destination.service.resource for S3 spans to have an "s3/" prefix. {pull}x[#x]
+
*Note*: While this is considered a bugfix, it can potentially be a breaking
change in the Kibana APM app: It can break the history of the S3-Spans / metrics
for users relying on `context.destination.service.resource`. If users happen to
run agents both with and without this fix (for same or different languages), the
same S3-buckets can appear twice in the service map (with and without
s3-prefix).
[[release-notes-6.x]]
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/instrumentation/packages/botocore.py
Expand Up @@ -123,7 +123,7 @@ def handle_s3(operation_name, service, instance, args, kwargs, context):
bucket = ""
signature = f"S3 {operation_name} {bucket}"

context["destination"]["service"] = {"name": span_subtype, "resource": bucket, "type": span_type}
context["destination"]["service"] = {"name": span_subtype, "resource": f"s3/{bucket}", "type": span_type}

return HandlerInfo(signature, span_type, span_subtype, span_action, context)

Expand Down
2 changes: 1 addition & 1 deletion tests/instrumentation/botocore_tests.py
Expand Up @@ -116,7 +116,7 @@ def test_s3(instrument, elasticapm_client):
assert span["context"]["destination"]["port"] == LOCALSTACK_ENDPOINT_URL.port
assert span["context"]["destination"]["cloud"]["region"] == "us-east-1"
assert span["context"]["destination"]["service"]["name"] == "s3"
assert span["context"]["destination"]["service"]["resource"] == "xyz"
assert span["context"]["destination"]["service"]["resource"] == "s3/xyz"
assert span["context"]["destination"]["service"]["type"] == "storage"
assert span["context"]["http"]["request"]["id"]
assert spans[0]["name"] == "S3 CreateBucket xyz"
Expand Down

0 comments on commit 24cc3e2

Please sign in to comment.