Skip to content

Commit 8957f41

Browse files
committed
Fix documentation
1 parent 0856702 commit 8957f41

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

  • opentelemetry-api/src/opentelemetry/configuration
  • opentelemetry-auto-instrumentation/src/opentelemetry/auto_instrumentation

opentelemetry-api/src/opentelemetry/configuration/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,18 @@
7474
7575
To use the meter provider above, then the
7676
``OPENTELEMETRY_PYTHON_METER_PROVIDER`` should be set to
77-
"default_meter_provider" (this is not actually necessary since the
77+
``"default_meter_provider"`` (this is not actually necessary since the
7878
OpenTelemetry API provided providers are the default ones used if no
7979
configuration is found in the environment variables).
80+
81+
This object can be used by any OpenTelemetry component, native or external.
82+
For that reason, the ``Configuration`` object is designed to be immutable.
83+
If a component would change the value of one of the ``Configuration`` object
84+
attributes then another component that relied on that value may break, leading
85+
to bugs that are very hard to debug. To avoid this situation, the preferred
86+
approach for components that need a different value than the one provided by
87+
the ``Configuration`` object is to implement a mechanism that allows the user
88+
to override this value instead of changing it.
8089
"""
8190

8291
from os import environ

opentelemetry-auto-instrumentation/src/opentelemetry/auto_instrumentation/instrumentor.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,13 @@ def instrument(self, **kwargs):
6464
mechanism) that will be used later by the code in the ``instrument``
6565
implementation via the global ``Configuration`` object.
6666
67-
When this method is to be called directly in the user code, ``kwargs``
68-
should be used to pass attributes that will override the configuration
69-
values read by the ``Configuration`` object.
70-
71-
In this way, calling this method directly without passing any optional
72-
values should do the very same thing that the
73-
``opentelemetry-auto-instrumentation`` command does. The idea behind
74-
this approach is also to keep the ``Configuration`` object immutable.
75-
76-
This is necessary because this object is used by all the OpenTelemetry
77-
components and any change to one of its attributes could break another
78-
component, leading to very hard to debug bugs.
67+
The ``instrument`` methods ``kwargs`` should default to values from the
68+
``Configuration`` object.
69+
70+
This means that calling this method directly without passing any
71+
optional values should do the very same thing that the
72+
``opentelemetry-auto-instrumentation`` command does. This approach is
73+
followed because the ``Configuration`` object is immutable.
7974
"""
8075

8176
if not self._is_instrumented:
@@ -88,7 +83,11 @@ def instrument(self, **kwargs):
8883
return None
8984

9085
def uninstrument(self, **kwargs):
91-
"""Uninstrument the library"""
86+
"""Uninstrument the library
87+
88+
See ``BaseInstrumentor.instrument`` for more information regarding the
89+
usage of ``kwargs``.
90+
"""
9291

9392
if self._is_instrumented:
9493
result = self._uninstrument(**kwargs)

0 commit comments

Comments
 (0)