OpenTelemetryAutoConfiguration uses a simple probability sampler. With this strategy we can potentialy (if probability is not set to 100%) get inconsistent trace because some services decide not to sample their spans. More over a brave sampler has parent-based behavior by default.

From open telemetry sampler documentation:

/**
 * Returns a new TraceIdRatioBased {@link Sampler}. The ratio of sampling a trace is equal to that
 * of the specified ratio.
 *
 * <p>The algorithm used by the {@link Sampler} is undefined, notably it may or may not use parts
 * of the trace ID when generating a sampling decision. Currently, only the ratio of traces that
 * are sampled can be relied on, not how the sampled traces are determined. As such, it is
 * recommended to only use this {@link Sampler} for root spans using {@link
 * Sampler#parentBased(Sampler)}.
 *
 * @param ratio The desired ratio of sampling. Must be within [0.0, 1.0].
 * @return a new TraceIdRatioBased {@link Sampler}.
 * @throws IllegalArgumentException if {@code ratio} is out of range
 */
static Sampler traceIdRatioBased(double ratio) {
  return TraceIdRatioBasedSampler.create(ratio);
}

I think it would be nice if you replace

Sampler.traceIdRatioBased(properties.getSampling().getProbability())

with

Sampler rootSampler = Sampler.traceIdRatioBased(properties.getSampling().getProbability());
return Sampler.parentBased(rootSampler);

Comment From: philwebb

@shakuzen Do you have any advice for the suggested change?

Comment From: shakuzen

Yes, the proposed change is sensible. I suspect that's the behavior we intended and we merely missed that it was not the actual behavior. /cc @marcingrzejszczak @jonatan-ivanov

Comment From: marcingrzejszczak

Yes, we missed that, sorry