|
19 | 19 | Simple configuration manager
|
20 | 20 |
|
21 | 21 | This is a configuration manager for the Tracer and Meter providers. It reads
|
22 |
| -configuration from environment variables prefixed with OPENTELEMETRY_PYTHON_: |
| 22 | +configuration from environment variables prefixed with |
| 23 | +``OPENTELEMETRY_PYTHON_``: |
23 | 24 |
|
24 |
| -1. OPENTELEMETRY_PYTHON_TRACER_PROVIDER |
25 |
| -2. OPENTELEMETRY_PYTHON_METER_PROVIDER |
| 25 | +1. ``OPENTELEMETRY_PYTHON_TRACER_PROVIDER`` |
| 26 | +2. ``OPENTELEMETRY_PYTHON_METER_PROVIDER`` |
26 | 27 |
|
27 | 28 | The value of these environment variables should be the name of the entry point
|
28 | 29 | that points to the class that implements either provider. This OpenTelemetry
|
29 | 30 | API package provides one entry point for each, which can be found in the
|
30 |
| -setup.py file: |
31 |
| -
|
32 |
| -entry_points={ |
33 |
| - ... |
34 |
| - "opentelemetry_meter_provider": [ |
35 |
| - "default_meter_provider = " |
36 |
| - "opentelemetry.metrics:DefaultMeterProvider" |
37 |
| - ], |
38 |
| - "opentelemetry_tracer_provider": [ |
39 |
| - "default_tracer_provider = " |
40 |
| - "opentelemetry.trace:DefaultTracerProvider" |
41 |
| - ], |
42 |
| -} |
| 31 | +setup.py file:: |
| 32 | +
|
| 33 | + entry_points={ |
| 34 | + ... |
| 35 | + "opentelemetry_meter_provider": [ |
| 36 | + "default_meter_provider = " |
| 37 | + "opentelemetry.metrics:DefaultMeterProvider" |
| 38 | + ], |
| 39 | + "opentelemetry_tracer_provider": [ |
| 40 | + "default_tracer_provider = " |
| 41 | + "opentelemetry.trace:DefaultTracerProvider" |
| 42 | + ], |
| 43 | + } |
43 | 44 |
|
44 | 45 | To use the meter provider above, then the
|
45 |
| -OPENTELEMETRY_PYTHON_METER_PROVIDER should be set to |
| 46 | +``OPENTELEMETRY_PYTHON_METER_PROVIDER`` should be set to |
46 | 47 | "default_meter_provider" (this is not actually necessary since the
|
47 | 48 | OpenTelemetry API provided providers are the default ones used if no
|
48 | 49 | configuration is found in the environment variables).
|
|
52 | 53 | be instantiated as many times as needed without concern because it will
|
53 | 54 | always produce the same instance. Its attributes are lazy loaded and they
|
54 | 55 | hold an instance of their corresponding provider. So, for example, to get
|
55 |
| -the configured meter provider: |
| 56 | +the configured meter provider:: |
56 | 57 |
|
57 |
| -from opentelemetry.configuration import Configuration |
| 58 | + from opentelemetry.configuration import Configuration |
| 59 | +
|
| 60 | + tracer_provider = Configuration().tracer_provider |
58 | 61 |
|
59 |
| -tracer_provider = Configuration().tracer_provider |
60 | 62 | """
|
61 | 63 |
|
62 | 64 | from logging import getLogger
|
|
0 commit comments