Class TraceDurationFilter

java.lang.Object
io.opentelemetry.contrib.filter.TraceDurationFilter
All Implemented Interfaces:
TraceFilter

public final class TraceDurationFilter extends Object implements TraceFilter
A TraceFilter that matches when the wall-clock duration (max end - min start across all spans in the batch sharing a trace ID) exceeds a configurable threshold.
  • Constructor Details

    • TraceDurationFilter

      public TraceDurationFilter(Duration threshold)
      Creates a new TraceDurationFilter.
      Parameters:
      threshold - the trace duration threshold; traces with wall-clock duration strictly greater than this are considered interesting
  • Method Details

    • shouldKeep

      public boolean shouldKeep(String traceId, Collection<io.opentelemetry.sdk.trace.data.SpanData> spans)
      Description copied from interface: TraceFilter
      Evaluates whether the given trace (represented as all spans sharing a trace ID within the current batch) should be exported.
      Specified by:
      shouldKeep in interface TraceFilter
      Parameters:
      traceId - the trace ID
      spans - all spans in the current batch belonging to this trace
      Returns:
      true if this trace should be exported