Skip to content

Commit 7eff6aa

Browse files
authored
Merge branch 'main' into remove-is-disabled-prints
2 parents 14f3a5d + 92f221c commit 7eff6aa

File tree

1 file changed

+5
-1
lines changed
  • opentelemetry-sdk/src/opentelemetry/sdk/resources

1 file changed

+5
-1
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
these attributes can be included in the Resource.*
2424
2525
Resource objects are created with `Resource.create`, which accepts attributes
26-
(key-values). Resources should NOT be created via constructor, and working with
26+
(key-values). Resources should NOT be created via constructor except by `ResourceDetector`
27+
instances which can't use `Resource.create` to avoid infinite loops. Working with
2728
`Resource` objects should only be done via the Resource API methods. Resource
2829
attributes can also be passed at process invocation in the
2930
:envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should register
@@ -175,6 +176,8 @@ def create(
175176
) -> "Resource":
176177
"""Creates a new `Resource` from attributes.
177178
179+
`ResourceDetector` instances should not call this method.
180+
178181
Args:
179182
attributes: Optional zero or more key-value pairs.
180183
schema_url: Optional URL pointing to the schema
@@ -316,6 +319,7 @@ def __init__(self, raise_on_error: bool = False) -> None:
316319

317320
@abc.abstractmethod
318321
def detect(self) -> "Resource":
322+
"""Don't call `Resource.create` here to avoid an infinite loop, instead instantiate `Resource` directly"""
319323
raise NotImplementedError()
320324

321325

0 commit comments

Comments
 (0)