Skip to content

Commit a46b4c2

Browse files
authored
Update docs to specify to use Resource APIs to work with Resource (open-telemetry#1686)
1 parent 58a8e8c commit a46b4c2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

docs/examples/basic_tracer/resources.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
SimpleSpanProcessor,
2121
)
2222

23+
# Use Resource.create() instead of constructor directly
2324
resource = Resource.create({"service.name": "basic_service"})
2425

2526
trace.set_tracer_provider(TracerProvider(resource=resource))

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
these attributes can be included in the Resource.*
2424
2525
Resource objects are created with `Resource.create`, which accepts attributes
26-
(key-values). Resource attributes can also be passed at process invocation in
27-
the :envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should
28-
register your resource with the `opentelemetry.sdk.trace.TracerProvider` by
29-
passing them into their constructors. The `Resource` passed to a provider is
30-
available to the exporter, which can send on this information as it sees fit.
26+
(key-values). Resources should NOT be created via constructor, and working with
27+
`Resource` objects should only be done via the Resource API methods. Resource
28+
attributes can also be passed at process invocation in the
29+
:envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should register
30+
your resource with the `opentelemetry.sdk.trace.TracerProvider` by passing
31+
them into their constructors. The `Resource` passed to a provider is available
32+
to the exporter, which can send on this information as it sees fit.
3133
3234
.. code-block:: python
3335

0 commit comments

Comments
 (0)