diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index 39210fdf3e2..5878f375d79 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -291,7 +291,7 @@ def get_aggregated_resources( :param timeout: Number of seconds to wait for each detector to return :return: """ - detectors_merged_resource = initial_resource or _EMPTY_RESOURCE + detectors_merged_resource = initial_resource or Resource.create() with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor: futures = [executor.submit(detector.detect) for detector in detectors] @@ -312,4 +312,4 @@ def get_aggregated_resources( detected_resource ) - return Resource.create().merge(detectors_merged_resource) + return detectors_merged_resource diff --git a/opentelemetry-sdk/tests/resources/test_resources.py b/opentelemetry-sdk/tests/resources/test_resources.py index a3b5044360f..25e8ddb8674 100644 --- a/opentelemetry-sdk/tests/resources/test_resources.py +++ b/opentelemetry-sdk/tests/resources/test_resources.py @@ -239,18 +239,16 @@ def test_aggregated_resources_no_detectors(self): ), ) - def test_aggregated_resources_with_static_resource(self): + def test_aggregated_resources_with_default_destroying_static_resource( + self, + ): static_resource = resources.Resource({"static_key": "static_value"}) self.assertEqual( resources.get_aggregated_resources( [], initial_resource=static_resource ), - resources._DEFAULT_RESOURCE.merge( - resources.Resource( - {resources.SERVICE_NAME: "unknown_service"}, "" - ) - ).merge(static_resource), + static_resource, ) resource_detector = mock.Mock(spec=resources.ResourceDetector) @@ -261,17 +259,11 @@ def test_aggregated_resources_with_static_resource(self): resources.get_aggregated_resources( [resource_detector], initial_resource=static_resource ), - resources._DEFAULT_RESOURCE.merge( - resources.Resource( - {resources.SERVICE_NAME: "unknown_service"}, "" - ) - ).merge( - resources.Resource( - { - "static_key": "try_to_overwrite_existing_value", - "key": "value", - } - ) + resources.Resource( + { + "static_key": "try_to_overwrite_existing_value", + "key": "value", + } ), )