blob: 522c46893cd7d5934b66c72850ca486cb7d41b5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
import java.util.function.Supplier;
/**
* Trace exporter which only exports a subset of traces as decided by the provided sampling strategy.
*/
public class SamplingTraceExporter implements TraceExporter {
private final TraceExporter wrappedExporter;
private final SamplingStrategy samplingStrategy;
public SamplingTraceExporter(TraceExporter wrappedExporter, SamplingStrategy samplingStrategy) {
this.wrappedExporter = wrappedExporter;
this.samplingStrategy = samplingStrategy;
}
@Override
public void maybeExport(Supplier<TraceDescription> traceDescriptionSupplier) {
if (samplingStrategy.shouldSample()) {
wrappedExporter.maybeExport(traceDescriptionSupplier);
}
}
}
|