Skip to content

Commit da7b9f9

Browse files
committed
Aaron's feedback
1 parent 873f402 commit da7b9f9

File tree

1 file changed

+7
-7
lines changed
  • opentelemetry-sdk/src/opentelemetry/sdk/trace

1 file changed

+7
-7
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
* parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
7474
* parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.
7575
76-
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).
76+
Sampling probability can be set with ``OTEL_TRACES_SAMPLER_ARG`` if the sampler is traceidratio or parentbased_traceidratio. Rate must be in the range [0.0,1.0]. When not provided rate will be set to 1.0 (maximum rate possible).
7777
7878
Prev example but with environment variables. Please make sure to set the env ``OTEL_TRACES_SAMPLER=traceidratio`` and ``OTEL_TRACES_SAMPLER_ARG=0.001``.
7979
@@ -112,16 +112,16 @@
112112
]
113113
}
114114
)
115-
...
115+
# ...
116116
class CustomRatioSampler(Sampler):
117117
def __init__(rate):
118-
...
119-
...
118+
# ...
119+
# ...
120120
class CustomSamplerFactory:
121121
@staticmethod
122-
get_sampler(sampler_argument_str):
122+
get_sampler(sampler_argument):
123123
try:
124-
rate = float(sampler_argument_str)
124+
rate = float(sampler_argument)
125125
return CustomSampler(rate)
126126
except ValueError: # In case argument is empty string.
127127
return CustomSampler(0.5)
@@ -437,7 +437,7 @@ def _get_from_env_or_default() -> Sampler:
437437
return trace_sampler
438438
except Exception as exc:
439439
_logger.warning(
440-
"Failed to initialize custom sampler, %s: %s",
440+
"Using default sampler. Failed to initialize custom sampler, %s: %s",
441441
trace_sampler_name,
442442
exc,
443443
)

0 commit comments

Comments
 (0)