sdk: rename resource labels to attributes (#1082)

This aligns with the specification for Resources
This commit is contained in:
alrex 2020-09-09 08:23:18 -07:00 committed by GitHub
parent 0d18297f96
commit beebaaf86d
2 changed files with 16 additions and 11 deletions

View File

@ -126,13 +126,15 @@ class BotoInstrumentor(BaseInstrumentor):
if args: if args:
http_method = args[0] http_method = args[0]
span.resource = Resource( span.resource = Resource(
labels={ attributes={
"endpoint": endpoint_name, "endpoint": endpoint_name,
"http_method": http_method.lower(), "http_method": http_method.lower(),
} }
) )
else: else:
span.resource = Resource(labels={"endpoint": endpoint_name}) span.resource = Resource(
attributes={"endpoint": endpoint_name}
)
add_span_arg_tags( add_span_arg_tags(
span, endpoint_name, args, args_name, traced_args, span, endpoint_name, args, args_name, traced_args,

View File

@ -73,7 +73,7 @@ class TestBotoInstrumentor(TestBase):
self.assertEqual( self.assertEqual(
span.resource, span.resource,
Resource( Resource(
labels={"endpoint": "ec2", "http_method": "runinstances"} attributes={"endpoint": "ec2", "http_method": "runinstances"}
), ),
) )
self.assertEqual(span.attributes["http.method"], "POST") self.assertEqual(span.attributes["http.method"], "POST")
@ -131,7 +131,7 @@ class TestBotoInstrumentor(TestBase):
assert_span_http_status_code(span, 200) assert_span_http_status_code(span, 200)
self.assertEqual( self.assertEqual(
span.resource, 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["http.method"], "HEAD")
self.assertEqual(span.attributes["aws.operation"], "head_bucket") self.assertEqual(span.attributes["aws.operation"], "head_bucket")
@ -146,7 +146,7 @@ class TestBotoInstrumentor(TestBase):
span = spans[2] span = spans[2]
self.assertEqual( self.assertEqual(
span.resource, span.resource,
Resource(labels={"endpoint": "s3", "http_method": "head"}), Resource(attributes={"endpoint": "s3", "http_method": "head"}),
) )
@mock_s3_deprecated @mock_s3_deprecated
@ -166,13 +166,13 @@ class TestBotoInstrumentor(TestBase):
assert_span_http_status_code(spans[0], 200) assert_span_http_status_code(spans[0], 200)
self.assertEqual( self.assertEqual(
spans[0].resource, spans[0].resource,
Resource(labels={"endpoint": "s3", "http_method": "put"}), Resource(attributes={"endpoint": "s3", "http_method": "put"}),
) )
# get bucket # get bucket
self.assertEqual(spans[1].attributes["aws.operation"], "head_bucket") self.assertEqual(spans[1].attributes["aws.operation"], "head_bucket")
self.assertEqual( self.assertEqual(
spans[1].resource, spans[1].resource,
Resource(labels={"endpoint": "s3", "http_method": "head"}), Resource(attributes={"endpoint": "s3", "http_method": "head"}),
) )
# put object # put object
self.assertEqual( self.assertEqual(
@ -180,7 +180,7 @@ class TestBotoInstrumentor(TestBase):
) )
self.assertEqual( self.assertEqual(
spans[2].resource, spans[2].resource,
Resource(labels={"endpoint": "s3", "http_method": "put"}), Resource(attributes={"endpoint": "s3", "http_method": "put"}),
) )
@mock_lambda_deprecated @mock_lambda_deprecated
@ -223,7 +223,7 @@ class TestBotoInstrumentor(TestBase):
assert_span_http_status_code(span, 200) assert_span_http_status_code(span, 200)
self.assertEqual( self.assertEqual(
span.resource, 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["http.method"], "GET")
self.assertEqual(span.attributes["aws.region"], "us-east-2") self.assertEqual(span.attributes["aws.region"], "us-east-2")
@ -241,7 +241,10 @@ class TestBotoInstrumentor(TestBase):
self.assertEqual( self.assertEqual(
span.resource, span.resource,
Resource( Resource(
labels={"endpoint": "sts", "http_method": "getfederationtoken"} attributes={
"endpoint": "sts",
"http_method": "getfederationtoken",
}
), ),
) )
self.assertEqual(span.attributes["aws.region"], "us-west-2") self.assertEqual(span.attributes["aws.region"], "us-west-2")
@ -268,6 +271,6 @@ class TestBotoInstrumentor(TestBase):
assert spans assert spans
span = spans[0] span = spans[0]
self.assertEqual( self.assertEqual(
span.resource, Resource(labels={"endpoint": "elasticcache"}) span.resource, Resource(attributes={"endpoint": "elasticcache"})
) )
self.assertEqual(span.attributes["aws.region"], "us-west-2") self.assertEqual(span.attributes["aws.region"], "us-west-2")