File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
sdk-extension/opentelemetry-sdk-extension-aws
src/opentelemetry/sdk/extension/aws/resource Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,12 @@ def detect(self) -> "Resource":
8484 # If can't get a token quick assume we are not on ec2
8585 try :
8686 token = _get_token (timeout = 1 )
87- except URLError :
87+ except URLError as exception :
88+ logger .debug (
89+ "%s failed to get token: %s" ,
90+ self .__class__ .__name__ ,
91+ exception ,
92+ )
8893 return Resource .get_empty ()
8994
9095 identity_dict = json .loads (_get_identity (token ))
Original file line number Diff line number Diff line change @@ -82,5 +82,14 @@ def test_simple_create(
8282 def test_empty_resource_if_token_returns_an_url_error (
8383 self , mock_get_token
8484 ):
85- actual = AwsEc2ResourceDetector ().detect ()
85+ with self .assertLogs (
86+ "opentelemetry.sdk.extension.aws.resource.ec2" , level = "DEBUG"
87+ ) as logger :
88+ actual = AwsEc2ResourceDetector ().detect ()
89+ self .assertEqual (
90+ logger .output ,
91+ [
92+ "DEBUG:opentelemetry.sdk.extension.aws.resource.ec2:AwsEc2ResourceDetector failed to get token: <urlopen error Something went wrong>"
93+ ],
94+ )
8695 self .assertDictEqual (actual .attributes .copy (), OrderedDict ())
You can’t perform that action at this time.
0 commit comments