File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
opentelemetry-sdk/src/opentelemetry/sdk/resources Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 2323 these attributes can be included in the Resource.*
2424
2525Resource 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
2829attributes 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
You can’t perform that action at this time.
0 commit comments