diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aebb9fbe19..66e3a562834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Removed documentation of custom sampler feature while circular dependency bug is explored + ([#3014](https://github.com/open-telemetry/opentelemetry-python/pull/3014)) - Add logarithm and exponent mappings ([#2960](https://github.com/open-telemetry/opentelemetry-python/pull/2960)) - Add and use missing metrics environment variables diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py index 38a3338b02f..c5b96688c91 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py @@ -64,7 +64,7 @@ ... The tracer sampler can also be configured via environment variables ``OTEL_TRACES_SAMPLER`` and ``OTEL_TRACES_SAMPLER_ARG`` (only if applicable). -The list of built-in values for ``OTEL_TRACES_SAMPLER`` are: +The list of known values for ``OTEL_TRACES_SAMPLER`` are: * always_on - Sampler that always samples spans, regardless of the parent span's sampling decision. * always_off - Sampler that never samples spans, regardless of the parent span's sampling decision. @@ -73,7 +73,7 @@ * parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples. * parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate. -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). +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). Prev example but with environment variables. Please make sure to set the env ``OTEL_TRACES_SAMPLER=traceidratio`` and ``OTEL_TRACES_SAMPLER_ARG=0.001``. @@ -96,38 +96,6 @@ # created spans will now be sampled by the TraceIdRatioBased sampler with rate 1/1000. with trace.get_tracer(__name__).start_as_current_span("Test Span"): ... - -In order to create a configurable custom sampler, create an entry point for the custom sampler factory method under the entry point group, ``opentelemetry_traces_sampler``. The custom sampler factory -method must be of type ``Callable[[str], Sampler]``, taking a single string argument and returning a Sampler object. The single input will come from the string value of the -``OTEL_TRACES_SAMPLER_ARG`` environment variable. If ``OTEL_TRACES_SAMPLER_ARG`` is not configured, the input will be an empty string. For example: - -.. code:: python - - setup( - ... - entry_points={ - ... - "opentelemetry_traces_sampler": [ - "custom_sampler_name = path.to.sampler.factory.method:CustomSamplerFactory.get_sampler" - ] - } - ) - # ... - class CustomRatioSampler(Sampler): - def __init__(rate): - # ... - # ... - class CustomSamplerFactory: - @staticmethod - get_sampler(sampler_argument): - try: - rate = float(sampler_argument) - return CustomSampler(rate) - except ValueError: # In case argument is empty string. - return CustomSampler(0.5) - -In order to configure you application with a custom sampler's entry point, set the ``OTEL_TRACES_SAMPLER`` environment variable to the key name of the entry point. For example, to configured the -above sampler, set ``OTEL_TRACES_SAMPLER=custom_sampler_name`` and ``OTEL_TRACES_SAMPLER_ARG=0.5``. """ import abc import enum