// Module included in the following assemblies:
//
// * service_mesh/v2x/ossm-reference-jaeger.adoc

:_mod-docs-content-type: REFERENCE
[id="ossm-distr-tracing-config-sampling_{context}"]
= Distributed tracing sampling configuration options

The {JaegerName} Operator can be used to define sampling strategies that will be supplied to tracers that have been configured to use a remote sampler.

While all traces are generated, only a few are sampled. Sampling a trace marks the trace for further processing and storage.

[NOTE]
====
This is not relevant if a trace was started by the Envoy proxy, as the sampling decision is made there. The Jaeger sampling decision is only relevant when the trace is started by an application using the client.
====

When a service receives a request that contains no trace context, the client starts a new trace, assigns it a random trace ID, and makes a sampling decision based on the currently installed sampling strategy. The sampling decision propagates to all subsequent requests in the trace so that other services are not making the sampling decision again.

{JaegerShortName} libraries support the following samplers:

* *Probabilistic* - The sampler makes a random sampling decision with the probability of sampling equal to the value of the `sampling.param` property. For example, using `sampling.param=0.1` samples approximately 1 in 10 traces.

* *Rate Limiting* - The sampler uses a leaky bucket rate limiter to ensure that traces are sampled with a certain constant rate. For example, using `sampling.param=2.0` samples requests with the rate of 2 traces per second.

.Jaeger sampling options
[options="header"]
[cols="l, a, a, a"]
|===
|Parameter |Description |Values |Default value
|spec:
 sampling:
  options: {}
    default_strategy:
    service_strategy:
|Configuration options that define the sampling strategies for tracing.
|
|If you do not provide configuration, the Collectors will return the default probabilistic sampling policy with 0.001 (0.1%) probability for all services.

|default_strategy:
  type:
service_strategy:
  type:
|Sampling strategy to use. See descriptions above.
|Valid values are `probabilistic`, and `ratelimiting`.
|`probabilistic`

|default_strategy:
  param:
service_strategy:
  param:
|Parameters for the selected sampling strategy.
|Decimal and integer values (0, .1, 1, 10)
|1
|===

This example defines a default sampling strategy that is probabilistic, with a 50% chance of the trace instances being sampled.

.Probabilistic sampling example
[source,yaml]
----
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
  name: with-sampling
spec:
  sampling:
    options:
      default_strategy:
        type: probabilistic
        param: 0.5
      service_strategies:
        - service: alpha
          type: probabilistic
          param: 0.8
          operation_strategies:
            - operation: op1
              type: probabilistic
              param: 0.2
            - operation: op2
              type: probabilistic
              param: 0.4
        - service: beta
          type: ratelimiting
          param: 5
----

If there are no user-supplied configurations, the {JaegerShortName} uses the following settings:

.Default sampling
[source,yaml]
----
spec:
  sampling:
    options:
      default_strategy:
        type: probabilistic
        param: 1
----
