Class SamplingTraceExporter
-
- All Implemented Interfaces:
-
io.opentelemetry.sdk.trace.export.SpanExporter
,java.io.Closeable
,java.lang.AutoCloseable
public final class SamplingTraceExporter implements SpanExporter
A SpanExporter that applies sampling logic before delegating to an OtlpHttpLogRecordExporter.
This exporter wraps an OtlpHttpSpanExporter and uses a ExportSampler to determine which spans should be exported based on configurable sampling rules. Spans that don't match the sampling criteria are filtered out, reducing the volume of telemetry data sent to the observability backend.
-
-
Constructor Summary
Constructors Constructor Description SamplingTraceExporter(OtlpHttpSpanExporter delegate, ExportSampler sampler)
-
Method Summary
Modifier and Type Method Description CompletableResultCode
export(Collection<SpanData> spans)
Exports spans after applying sampling logic. CompletableResultCode
flush()
Flushes any pending spans in the underlying exporter. CompletableResultCode
shutdown()
Shuts down the exporter and releases any resources. -
-
Constructor Detail
-
SamplingTraceExporter
SamplingTraceExporter(OtlpHttpSpanExporter delegate, ExportSampler sampler)
- Parameters:
delegate
- The underlying OtlpHttpSpanExporter that handles the actual exportsampler
- The custom sampler that determines which spans to export
-
-
Method Detail
-
export
CompletableResultCode export(Collection<SpanData> spans)
Exports spans after applying sampling logic.
This method filters the provided spans using the configured sampler, then delegates the export of sampled spans to the underlying OTLP exporter. If no spans pass the sampling criteria, the export is considered successful without sending any data.
- Parameters:
spans
- The collection of spans to potentially export- Returns:
A CompletableResultCode indicating the success or failure of the export operation
-
flush
CompletableResultCode flush()
Flushes any pending spans in the underlying exporter.
- Returns:
A CompletableResultCode indicating the success or failure of the flush operation
-
shutdown
CompletableResultCode shutdown()
Shuts down the exporter and releases any resources.
- Returns:
A CompletableResultCode indicating the success or failure of the shutdown operation
-
-
-
-