diff --git a/CHANGELOG.md b/CHANGELOG.md index ae22221e3f..efb766bda4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Breaking changes + +- `opentelemetry-instrumentation-botocore` Use `cloud.region` instead of `aws.region` span attribute as per semantic conventions. + ([#3474](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3474)) + + ## Version 1.33.0/0.54b0 (2025-05-09) ### Added 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 45f50c2b2d..0649d62893 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py @@ -109,6 +109,9 @@ def response_hook(span, service_name, operation_name, result): ) from opentelemetry.metrics import Instrument, Meter, get_meter from opentelemetry.propagators.aws.aws_xray_propagator import AwsXRayPropagator +from opentelemetry.semconv._incubating.attributes.cloud_attributes import ( + CLOUD_REGION, +) from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import get_tracer from opentelemetry.trace.span import Span @@ -276,8 +279,7 @@ def _patched_api_call(self, original_func, instance, args, kwargs): SpanAttributes.RPC_SYSTEM: "aws-api", SpanAttributes.RPC_SERVICE: call_context.service_id, SpanAttributes.RPC_METHOD: call_context.operation, - # TODO: update when semantic conventions exist - "aws.region": call_context.region, + CLOUD_REGION: call_context.region, **get_server_attributes(call_context.endpoint_url), } diff --git a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py index c9b985e877..6ebb074deb 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py @@ -27,6 +27,9 @@ ) from opentelemetry.propagate import get_global_textmap, set_global_textmap from opentelemetry.propagators.aws.aws_xray_propagator import TRACE_HEADER_KEY +from opentelemetry.semconv._incubating.attributes.cloud_attributes import ( + CLOUD_REGION, +) from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.mock_textmap import MockTextMapPropagator from opentelemetry.test.test_base import TestBase @@ -61,7 +64,7 @@ def _default_span_attributes(self, service: str, operation: str): SpanAttributes.RPC_SYSTEM: "aws-api", SpanAttributes.RPC_SERVICE: service, SpanAttributes.RPC_METHOD: operation, - "aws.region": self.region, + CLOUD_REGION: self.region, "retry_attempts": 0, SpanAttributes.HTTP_STATUS_CODE: 200, # Some services like IAM or STS have a global endpoint and exclude specified region. @@ -527,7 +530,7 @@ def test_server_attributes(self): attributes={ SpanAttributes.SERVER_ADDRESS: "iam.amazonaws.com", SpanAttributes.SERVER_PORT: 443, - "aws.region": "aws-global", + CLOUD_REGION: "aws-global", }, )