Class SamplingLogExporter
-
- All Implemented Interfaces:
-
io.opentelemetry.sdk.logs.export.LogRecordExporter
,java.io.Closeable
,java.lang.AutoCloseable
public final class SamplingLogExporter implements LogRecordExporter
A LogRecordExporter that applies sampling logic before delegating to an OtlpHttpLogRecordExporter.
This exporter wraps an OtlpHttpLogRecordExporter and uses a ExportSampler to determine which log records should be exported based on configurable sampling rules. Log records 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 SamplingLogExporter(LogRecordExporter delegate, ExportSampler sampler)
-
Method Summary
Modifier and Type Method Description CompletableResultCode
export(Collection<LogRecordData> logs)
Exports log records after applying sampling logic. CompletableResultCode
flush()
Flushes any pending log records in the underlying exporter. CompletableResultCode
shutdown()
Shuts down the underlying exporter and releases any resources. -
-
Constructor Detail
-
SamplingLogExporter
SamplingLogExporter(LogRecordExporter delegate, ExportSampler sampler)
- Parameters:
delegate
- The underlying OtlpHttpLogRecordExporter that handles the actual exportsampler
- The custom sampler that determines which log records to export
-
-
Method Detail
-
export
CompletableResultCode export(Collection<LogRecordData> logs)
Exports log records after applying sampling logic.
This method filters the provided log records using the configured sampler, then delegates the export of sampled records to the underlying OtlpHttpLogRecordExporter. If no log records pass the sampling criteria, the export is considered successful without sending any data.
- Parameters:
logs
- The collection of log records to potentially export- Returns:
A CompletableResultCode indicating the success or failure of the export operation
-
flush
CompletableResultCode flush()
Flushes any pending log records in the underlying exporter.
- Returns:
A CompletableResultCode indicating the success or failure of the flush operation
-
shutdown
CompletableResultCode shutdown()
Shuts down the underlying exporter and releases any resources.
- Returns:
A CompletableResultCode indicating the success or failure of the shutdown operation
-
-
-
-