Package com.tnsai.quality.sampling
Class RuleBasedSamplingPolicy
java.lang.Object
com.tnsai.quality.sampling.RuleBasedSamplingPolicy
- All Implemented Interfaces:
EventSamplingPolicy
Rule-driven
EventSamplingPolicy (issue #82). Holds an ordered
list of RuleBasedSamplingPolicy.Rules and applies the first one that matches the
incoming SamplingInput; falls back to a configured default
decision when nothing matches.
Programmatic builder API; YAML-driven configuration is a separate
follow-up issue (a YAML loader can produce the same RuleBasedSamplingPolicy.Rule
list at startup).
Pattern matching
Each rule'seventKindPattern is a glob:
"*"— matches any kind"chat.*"— matcheschat.chunk,chat.complete, and so on (one component after the prefix)"tool.invoked"— exact match
Rules can also match on minimum severity (RuleBasedSamplingPolicy.Rule.minLevel)
and tenant id (RuleBasedSamplingPolicy.Rule.tenantId). Null fields are treated as
"any". Rules execute in registration order; first match wins.
- Since:
- 0.10.0 (issue #82 closeout)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumstatic final recordOne rule entry. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()rules()Returns an immutable view of the rules; useful for tests.sample(SamplingInput input) Inspect an event's metadata and return whether to capture, drop, or capture-with-downsampling marker.
-
Method Details
-
builder
-
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
-
rules
Returns an immutable view of the rules; useful for tests. -
defaultDecision
-