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 23
23
these attributes can be included in the Resource.*
24
24
25
25
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
27
28
`Resource` objects should only be done via the Resource API methods. Resource
28
29
attributes can also be passed at process invocation in the
29
30
:envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should register
@@ -175,6 +176,8 @@ def create(
175
176
) -> "Resource" :
176
177
"""Creates a new `Resource` from attributes.
177
178
179
+ `ResourceDetector` instances should not call this method.
180
+
178
181
Args:
179
182
attributes: Optional zero or more key-value pairs.
180
183
schema_url: Optional URL pointing to the schema
@@ -316,6 +319,7 @@ def __init__(self, raise_on_error: bool = False) -> None:
316
319
317
320
@abc .abstractmethod
318
321
def detect (self ) -> "Resource" :
322
+ """Don't call `Resource.create` here to avoid an infinite loop, instead instantiate `Resource` directly"""
319
323
raise NotImplementedError ()
320
324
321
325
You can’t perform that action at this time.
0 commit comments