Skip to content

Commit

Permalink
opentelemetry-sdk: clarify Resource.create usage
Browse files Browse the repository at this point in the history
After #3181 ResourceDetector instances cannot call Resource.create
otherwise when using auto-instrumentation you'll go into an infinite loop
trying to load resource detectors.
  • Loading branch information
xrmx committed Dec 23, 2024
1 parent 33acdf3 commit f8b865c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
these attributes can be included in the Resource.*
Resource objects are created with `Resource.create`, which accepts attributes
(key-values). Resources should NOT be created via constructor, and working with
(key-values). Resources should NOT be created via constructor yet ResourceDetector
instance can't use `Resource.create` to avoid infinite loops. Working with
`Resource` objects should only be done via the Resource API methods. Resource
attributes can also be passed at process invocation in the
:envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should register
Expand Down Expand Up @@ -175,6 +176,8 @@ def create(
) -> "Resource":
"""Creates a new `Resource` from attributes.
This is supposed to be called by the SDK and not by ResourceDetector instances.
Args:
attributes: Optional zero or more key-value pairs.
schema_url: Optional URL pointing to the schema
Expand Down

0 comments on commit f8b865c

Please sign in to comment.