From beebaaf86d2dfe49120d330062977285687ea437 Mon Sep 17 00:00:00 2001 From: alrex Date: Wed, 9 Sep 2020 08:23:18 -0700 Subject: [PATCH] sdk: rename resource labels to attributes (#1082) This aligns with the specification for Resources --- .../instrumentation/boto/__init__.py | 6 ++++-- .../tests/test_boto_instrumentation.py | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) 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 e6a0e351e..8e03cd6e7 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py @@ -126,13 +126,15 @@ class BotoInstrumentor(BaseInstrumentor): if args: http_method = args[0] span.resource = Resource( - labels={ + attributes={ "endpoint": endpoint_name, "http_method": http_method.lower(), } ) else: - span.resource = Resource(labels={"endpoint": endpoint_name}) + span.resource = Resource( + attributes={"endpoint": endpoint_name} + ) add_span_arg_tags( span, endpoint_name, args, args_name, traced_args, diff --git a/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py b/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py index 7ed877550..0a4a4b886 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py @@ -73,7 +73,7 @@ class TestBotoInstrumentor(TestBase): self.assertEqual( span.resource, Resource( - labels={"endpoint": "ec2", "http_method": "runinstances"} + attributes={"endpoint": "ec2", "http_method": "runinstances"} ), ) self.assertEqual(span.attributes["http.method"], "POST") @@ -131,7 +131,7 @@ class TestBotoInstrumentor(TestBase): assert_span_http_status_code(span, 200) self.assertEqual( span.resource, - Resource(labels={"endpoint": "s3", "http_method": "head"}), + Resource(attributes={"endpoint": "s3", "http_method": "head"}), ) self.assertEqual(span.attributes["http.method"], "HEAD") self.assertEqual(span.attributes["aws.operation"], "head_bucket") @@ -146,7 +146,7 @@ class TestBotoInstrumentor(TestBase): span = spans[2] self.assertEqual( span.resource, - Resource(labels={"endpoint": "s3", "http_method": "head"}), + Resource(attributes={"endpoint": "s3", "http_method": "head"}), ) @mock_s3_deprecated @@ -166,13 +166,13 @@ class TestBotoInstrumentor(TestBase): assert_span_http_status_code(spans[0], 200) self.assertEqual( spans[0].resource, - Resource(labels={"endpoint": "s3", "http_method": "put"}), + Resource(attributes={"endpoint": "s3", "http_method": "put"}), ) # get bucket self.assertEqual(spans[1].attributes["aws.operation"], "head_bucket") self.assertEqual( spans[1].resource, - Resource(labels={"endpoint": "s3", "http_method": "head"}), + Resource(attributes={"endpoint": "s3", "http_method": "head"}), ) # put object self.assertEqual( @@ -180,7 +180,7 @@ class TestBotoInstrumentor(TestBase): ) self.assertEqual( spans[2].resource, - Resource(labels={"endpoint": "s3", "http_method": "put"}), + Resource(attributes={"endpoint": "s3", "http_method": "put"}), ) @mock_lambda_deprecated @@ -223,7 +223,7 @@ class TestBotoInstrumentor(TestBase): assert_span_http_status_code(span, 200) self.assertEqual( span.resource, - Resource(labels={"endpoint": "lambda", "http_method": "get"}), + Resource(attributes={"endpoint": "lambda", "http_method": "get"}), ) self.assertEqual(span.attributes["http.method"], "GET") self.assertEqual(span.attributes["aws.region"], "us-east-2") @@ -241,7 +241,10 @@ class TestBotoInstrumentor(TestBase): self.assertEqual( span.resource, Resource( - labels={"endpoint": "sts", "http_method": "getfederationtoken"} + attributes={ + "endpoint": "sts", + "http_method": "getfederationtoken", + } ), ) self.assertEqual(span.attributes["aws.region"], "us-west-2") @@ -268,6 +271,6 @@ class TestBotoInstrumentor(TestBase): assert spans span = spans[0] self.assertEqual( - span.resource, Resource(labels={"endpoint": "elasticcache"}) + span.resource, Resource(attributes={"endpoint": "elasticcache"}) ) self.assertEqual(span.attributes["aws.region"], "us-west-2")