|
60 | 60 | with trace.get_tracer(__name__).start_as_current_span("Test Span"):
|
61 | 61 | ...
|
62 | 62 |
|
63 |
| -The tracer sampler can also be configured via environment variables ``OTEL_TRACE_SAMPLER`` and ``OTEL_TRACE_SAMPLER_ARG`` (only if applicable). |
64 |
| -The list of known values for ``OTEL_TRACE_SAMPLER`` are: |
| 63 | +The tracer sampler can also be configured via environment variables ``OTEL_TRACES_SAMPLER`` and ``OTEL_TRACES_SAMPLER_ARG`` (only if applicable). |
| 64 | +The list of known values for ``OTEL_TRACES_SAMPLER`` are: |
65 | 65 |
|
66 | 66 | * always_on - Sampler that always samples spans, regardless of the parent span's sampling decision.
|
67 | 67 | * always_off - Sampler that never samples spans, regardless of the parent span's sampling decision.
|
|
70 | 70 | * parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
|
71 | 71 | * parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.
|
72 | 72 |
|
73 |
| -Sampling probability can be set with ``OTEL_TRACE_SAMPLER_ARG`` if the sampler is traceidratio or parentbased_traceidratio, when not provided rate will be set to 1.0 (maximum rate possible). |
| 73 | +Sampling probability can be set with ``OTEL_TRACES_SAMPLER_ARG`` if the sampler is traceidratio or parentbased_traceidratio, when not provided rate will be set to 1.0 (maximum rate possible). |
74 | 74 |
|
75 | 75 |
|
76 |
| -Prev example but with environment vairables. Please make sure to set the env ``OTEL_TRACE_SAMPLER=traceidratio`` and ``OTEL_TRACE_SAMPLER_ARG=0.001``. |
| 76 | +Prev example but with environment vairables. Please make sure to set the env ``OTEL_TRACES_SAMPLER=traceidratio`` and ``OTEL_TRACES_SAMPLER_ARG=0.001``. |
77 | 77 |
|
78 | 78 | .. code:: python
|
79 | 79 |
|
|
105 | 105 | # pylint: disable=unused-import
|
106 | 106 | from opentelemetry.context import Context
|
107 | 107 | from opentelemetry.sdk.environment_variables import (
|
108 |
| - OTEL_TRACE_SAMPLER, |
109 |
| - OTEL_TRACE_SAMPLER_ARG, |
| 108 | + OTEL_TRACES_SAMPLER, |
| 109 | + OTEL_TRACES_SAMPLER_ARG, |
110 | 110 | )
|
111 | 111 | from opentelemetry.trace import Link, get_current_span
|
112 | 112 | from opentelemetry.trace.span import TraceState
|
@@ -370,17 +370,17 @@ def __init__(self, rate: float):
|
370 | 370 |
|
371 | 371 | def _get_from_env_or_default() -> Sampler:
|
372 | 372 | trace_sampler = os.getenv(
|
373 |
| - OTEL_TRACE_SAMPLER, "parentbased_always_on" |
| 373 | + OTEL_TRACES_SAMPLER, "parentbased_always_on" |
374 | 374 | ).lower()
|
375 | 375 | if trace_sampler not in _KNOWN_SAMPLERS:
|
376 | 376 | _logger.warning("Couldn't recognize sampler %s.", trace_sampler)
|
377 | 377 | trace_sampler = "parentbased_always_on"
|
378 | 378 |
|
379 | 379 | if trace_sampler in ("traceidratio", "parentbased_traceidratio"):
|
380 | 380 | try:
|
381 |
| - rate = float(os.getenv(OTEL_TRACE_SAMPLER_ARG)) |
| 381 | + rate = float(os.getenv(OTEL_TRACES_SAMPLER_ARG)) |
382 | 382 | except ValueError:
|
383 |
| - _logger.warning("Could not convert TRACE_SAMPLER_ARG to float.") |
| 383 | + _logger.warning("Could not convert TRACES_SAMPLER_ARG to float.") |
384 | 384 | rate = 1.0
|
385 | 385 | return _KNOWN_SAMPLERS[trace_sampler](rate)
|
386 | 386 |
|
|
0 commit comments