Package com.tnsai.quality.sampling
Class ErrorAlwaysPolicy
java.lang.Object
com.tnsai.quality.sampling.ErrorAlwaysPolicy
- All Implemented Interfaces:
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:
EventLevel.WARN/EventLevel.ERROR/EventLevel.CRITICAL→ alwaysSamplingDecision.CaptureEventLevel.INFO/EventLevel.DEBUG→ coin-flip atinfoDebugRate, returnsSamplingDecision.CaptureDownsampledwhen captured
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublesample(SamplingInput input) Inspect an event's metadata and return whether to capture, drop, or capture-with-downsampling marker.static ErrorAlwaysPolicyConvenience: the documented production default of 10% INFO/DEBUG capture.
-
Constructor Details
-
ErrorAlwaysPolicy
public ErrorAlwaysPolicy(double infoDebugRate) - Parameters:
infoDebugRate- fraction in(0, 1]for INFO + DEBUG (use1.0to capture all and rely on level filtering elsewhere; use0.0…to silence chatter). Set very low for streaming-chunk-heavy workloads.- Throws:
IllegalArgumentException- if rate is outside(0, 1]
-
-
Method Details
-
withDefault
Convenience: the documented production default of 10% INFO/DEBUG capture. -
infoDebugRate
public double infoDebugRate() -
sample
Description copied from interface:EventSamplingPolicyInspect an event's metadata and return whether to capture, drop, or capture-with-downsampling marker.- Specified by:
samplein interfaceEventSamplingPolicy
-