diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ddc4e879b4..339d4b86741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Rename `IdsGenerator` to `IdGenerator` ([#1651])(https://github.com/open-telemetry/opentelemetry-python/pull/1651) +- Rename Resource's `create_empty` to `get_empty` + ([#1653])(https://github.com/open-telemetry/opentelemetry-python/pull/1653) ## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index c840e5f298e..a7fa6dd54c3 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -188,7 +188,7 @@ def create(attributes: typing.Optional[Attributes] = None) -> "Resource": return resource @staticmethod - def create_empty() -> "Resource": + def get_empty() -> "Resource": return _EMPTY_RESOURCE @property diff --git a/opentelemetry-sdk/tests/resources/test_resources.py b/opentelemetry-sdk/tests/resources/test_resources.py index 3effa5d2452..4151c2fbd8d 100644 --- a/opentelemetry-sdk/tests/resources/test_resources.py +++ b/opentelemetry-sdk/tests/resources/test_resources.py @@ -59,7 +59,7 @@ def test_create(self): self.assertEqual(resource.attributes, expected_with_envar) os.environ[resources.OTEL_RESOURCE_ATTRIBUTES] = "" - resource = resources.Resource.create_empty() + resource = resources.Resource.get_empty() self.assertEqual(resource, resources._EMPTY_RESOURCE) resource = resources.Resource.create(None) @@ -140,9 +140,7 @@ def test_service_name_using_process_name(self): def test_aggregated_resources_no_detectors(self): aggregated_resources = resources.get_aggregated_resources([]) - self.assertEqual( - aggregated_resources, resources.Resource.create_empty() - ) + self.assertEqual(aggregated_resources, resources.Resource.get_empty()) def test_aggregated_resources_with_static_resource(self): static_resource = resources.Resource({"static_key": "static_value"}) @@ -208,7 +206,7 @@ def test_resource_detector_ignore_error(self): resource_detector.raise_on_error = False self.assertEqual( resources.get_aggregated_resources([resource_detector]), - resources.Resource.create_empty(), + resources.Resource.get_empty(), ) def test_resource_detector_raise_error(self): @@ -245,7 +243,7 @@ def tearDown(self) -> None: def test_empty(self): detector = resources.OTELResourceDetector() os.environ[resources.OTEL_RESOURCE_ATTRIBUTES] = "" - self.assertEqual(detector.detect(), resources.Resource.create_empty()) + self.assertEqual(detector.detect(), resources.Resource.get_empty()) def test_one(self): detector = resources.OTELResourceDetector()