Skip to content

Commit 94a4854

Browse files
committed
Update botocore instrumentation to use semantic convention attribute for cloud region
1 parent 5c76d04 commit 94a4854

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def response_hook(span, service_name, operation_name, result):
109109
)
110110
from opentelemetry.metrics import Instrument, Meter, get_meter
111111
from opentelemetry.propagators.aws.aws_xray_propagator import AwsXRayPropagator
112+
from opentelemetry.semconv._incubating.attributes.cloud_attributes import (
113+
CLOUD_REGION,
114+
)
112115
from opentelemetry.semconv.trace import SpanAttributes
113116
from opentelemetry.trace import get_tracer
114117
from opentelemetry.trace.span import Span
@@ -276,8 +279,7 @@ def _patched_api_call(self, original_func, instance, args, kwargs):
276279
SpanAttributes.RPC_SYSTEM: "aws-api",
277280
SpanAttributes.RPC_SERVICE: call_context.service_id,
278281
SpanAttributes.RPC_METHOD: call_context.operation,
279-
# TODO: update when semantic conventions exist
280-
"aws.region": call_context.region,
282+
CLOUD_REGION: call_context.region,
281283
**get_server_attributes(call_context.endpoint_url),
282284
}
283285

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
)
2828
from opentelemetry.propagate import get_global_textmap, set_global_textmap
2929
from opentelemetry.propagators.aws.aws_xray_propagator import TRACE_HEADER_KEY
30+
from opentelemetry.semconv._incubating.attributes.cloud_attributes import (
31+
CLOUD_REGION,
32+
)
3033
from opentelemetry.semconv.trace import SpanAttributes
3134
from opentelemetry.test.mock_textmap import MockTextMapPropagator
3235
from opentelemetry.test.test_base import TestBase
@@ -61,7 +64,7 @@ def _default_span_attributes(self, service: str, operation: str):
6164
SpanAttributes.RPC_SYSTEM: "aws-api",
6265
SpanAttributes.RPC_SERVICE: service,
6366
SpanAttributes.RPC_METHOD: operation,
64-
"aws.region": self.region,
67+
CLOUD_REGION: self.region,
6568
"retry_attempts": 0,
6669
SpanAttributes.HTTP_STATUS_CODE: 200,
6770
# Some services like IAM or STS have a global endpoint and exclude specified region.
@@ -527,7 +530,7 @@ def test_server_attributes(self):
527530
attributes={
528531
SpanAttributes.SERVER_ADDRESS: "iam.amazonaws.com",
529532
SpanAttributes.SERVER_PORT: 443,
530-
"aws.region": "aws-global",
533+
CLOUD_REGION: "aws-global",
531534
},
532535
)
533536

0 commit comments

Comments
 (0)