Class ErrorAlwaysPolicy

java.lang.Object
com.tnsai.quality.sampling.ErrorAlwaysPolicy
All Implemented Interfaces:
EventSamplingPolicy

public final class ErrorAlwaysPolicy extends Object implements EventSamplingPolicy
Sampling policy that always captures problems and head-samples everything else at a single rate (issue #82).

Simpler than PriorityBasedSamplingPolicy — there's no per-level rate map, just one threshold:

Use this when the operational rule is "I never want to lose an error, but everything else is firehose noise" — typical production default for an agent that already classifies problems with the right level.

Since:
0.9.0 (issue #82)
  • Constructor Details

    • ErrorAlwaysPolicy

      public ErrorAlwaysPolicy(double infoDebugRate)
      Parameters:
      infoDebugRate - fraction in (0, 1] for INFO + DEBUG (use 1.0 to capture all and rely on level filtering elsewhere; use 0.0… to silence chatter). Set very low for streaming-chunk-heavy workloads.
      Throws:
      IllegalArgumentException - if rate is outside (0, 1]
  • Method Details

    • withDefault

      public static ErrorAlwaysPolicy withDefault()
      Convenience: the documented production default of 10% INFO/DEBUG capture.
    • infoDebugRate

      public double infoDebugRate()
    • sample

      public SamplingDecision sample(SamplingInput input)
      Description copied from interface: EventSamplingPolicy
      Inspect an event's metadata and return whether to capture, drop, or capture-with-downsampling marker.
      Specified by:
      sample in interface EventSamplingPolicy