Skip to content

Commit

Permalink
Results from /fix:format
Browse files Browse the repository at this point in the history
  • Loading branch information
opentelemetrybot committed Mar 25, 2024
1 parent 475faa1 commit dad7d2e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions content/en/docs/languages/java/sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ title: Sampling
weight: 80
---

[Sampling](/docs/concepts/sampling/) is a process that restricts the amount of spans that are generated by a system. The exact sampler you should use depends on your specific needs, but in general, you should make a decision at the start of a trace and allow the sampling decision to propagate to other services.
[Sampling](/docs/concepts/sampling/) is a process that restricts the amount of
spans that are generated by a system. The exact sampler you should use depends
on your specific needs, but in general, you should make a decision at the start
of a trace and allow the sampling decision to propagate to other services.

A Sampler can be set on the tracer provider using the `setSampler` method, as follows:
A Sampler can be set on the tracer provider using the `setSampler` method, as
follows:

```java
import io.opentelemetry.sdk.trace.SdkTracerProvider;
Expand All @@ -25,12 +29,17 @@ public class Example {
}
```

`alwaysOn` and `alwaysOff` are self-explanatory values. `alwaysOn` means that every span is sampled, while alwaysOff means that no span is sampled. When you’re getting started, or in a development environment, use `alwaysOn`.
`alwaysOn` and `alwaysOff` are self-explanatory values. `alwaysOn` means that
every span is sampled, while alwaysOff means that no span is sampled. When
you’re getting started, or in a development environment, use `alwaysOn`.

Other samplers include:

- `traceIdRatioBased`, which samples a fraction of spans, based on the fraction given to the sampler. If you set `0.5`, half of all the spans are sampled.
- `parentBased`, which uses the parent span to make sampling decisions, if present.
By default, the tracer provider uses a parentBased sampler with the `alwaysOn` sampler.
- `traceIdRatioBased`, which samples a fraction of spans, based on the fraction
given to the sampler. If you set `0.5`, half of all the spans are sampled.
- `parentBased`, which uses the parent span to make sampling decisions, if
present. By default, the tracer provider uses a parentBased sampler with the
`alwaysOn` sampler.

When in a production environment, consider using the `parentBased` sampler with the `traceIdRatioBased` sampler.
When in a production environment, consider using the `parentBased` sampler with
the `traceIdRatioBased` sampler.

0 comments on commit dad7d2e

Please sign in to comment.