diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py index c92ccc8106..ca0218fe9f 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py @@ -52,7 +52,10 @@ from opentelemetry.instrumentation.boto.version import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap -from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.semconv._incubating.attributes.http_attributes import ( + HTTP_METHOD, + HTTP_STATUS_CODE, +) from opentelemetry.trace import SpanKind, get_tracer logger = logging.getLogger(__name__) @@ -158,12 +161,8 @@ def _common_request( # pylint: disable=too-many-locals for key, value in meta.items(): span.set_attribute(key, value) - span.set_attribute( - SpanAttributes.HTTP_STATUS_CODE, getattr(result, "status") - ) - span.set_attribute( - SpanAttributes.HTTP_METHOD, getattr(result, "_method") - ) + span.set_attribute(HTTP_STATUS_CODE, getattr(result, "status")) + span.set_attribute(HTTP_METHOD, getattr(result, "_method")) return result diff --git a/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py b/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py index 7d20f53150..89684d4a05 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py @@ -28,13 +28,16 @@ ) from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.semconv._incubating.attributes.http_attributes import ( + HTTP_METHOD, + HTTP_STATUS_CODE, +) from opentelemetry.test.test_base import TestBase def assert_span_http_status_code(span, code): """Assert on the span's 'http.status_code' tag""" - tag = span.attributes[SpanAttributes.HTTP_STATUS_CODE] + tag = span.attributes[HTTP_STATUS_CODE] assert tag == code, f"{tag} != {code}" @@ -60,7 +63,7 @@ def test_ec2_client(self): span = spans[0] self.assertEqual(span.attributes["aws.operation"], "DescribeInstances") assert_span_http_status_code(span, 200) - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "POST") + self.assertEqual(span.attributes[HTTP_METHOD], "POST") self.assertEqual(span.attributes["aws.region"], "us-west-2") # Create an instance @@ -73,7 +76,7 @@ def test_ec2_client(self): assert_span_http_status_code(span, 200) self.assertEqual(span.attributes["endpoint"], "ec2") self.assertEqual(span.attributes["http_method"], "runinstances") - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "POST") + self.assertEqual(span.attributes[HTTP_METHOD], "POST") self.assertEqual(span.attributes["aws.region"], "us-west-2") self.assertEqual(span.name, "ec2.command") @@ -120,7 +123,7 @@ def test_s3_client(self): self.assertEqual(len(spans), 1) span = spans[0] assert_span_http_status_code(span, 200) - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "GET") + self.assertEqual(span.attributes[HTTP_METHOD], "GET") self.assertEqual(span.attributes["aws.operation"], "get_all_buckets") # Create a bucket command @@ -130,7 +133,7 @@ def test_s3_client(self): self.assertEqual(len(spans), 2) span = spans[1] assert_span_http_status_code(span, 200) - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "PUT") + self.assertEqual(span.attributes[HTTP_METHOD], "PUT") self.assertEqual(span.attributes["path"], "/") self.assertEqual(span.attributes["aws.operation"], "create_bucket") @@ -143,7 +146,7 @@ def test_s3_client(self): assert_span_http_status_code(span, 200) self.assertEqual(span.attributes["endpoint"], "s3") self.assertEqual(span.attributes["http_method"], "head") - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "HEAD") + self.assertEqual(span.attributes[HTTP_METHOD], "HEAD") self.assertEqual(span.attributes["aws.operation"], "head_bucket") self.assertEqual(span.name, "s3.command") @@ -240,7 +243,7 @@ def test_lambda_client(self): assert_span_http_status_code(span, 200) self.assertEqual(span.attributes["endpoint"], "lambda") self.assertEqual(span.attributes["http_method"], "get") - self.assertEqual(span.attributes[SpanAttributes.HTTP_METHOD], "GET") + self.assertEqual(span.attributes[HTTP_METHOD], "GET") self.assertEqual(span.attributes["aws.region"], "us-east-2") self.assertEqual(span.attributes["aws.operation"], "list_functions")