Class RuleBasedSamplingPolicy

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

public final class RuleBasedSamplingPolicy extends Object implements 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's eventKindPattern is a glob:
  • "*" — matches any kind
  • "chat.*" — matches chat.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)