Documentation
¶
Overview ¶
Package pathfilter implements the Phase A "path-filter" plugin: an ObserveOnFinalize plugin that drops traces whose Path matches any operator-configured pattern.
Pattern semantics match the display-side filter the viewer already uses (see ROADMAP § 4 "path noise filter" + commit 5cbdda1):
- Exact match: pattern "/api/v1/auth/me" matches Path "/api/v1/auth/me" only.
- Prefix match via trailing "*": pattern "/api/v1/*" matches "/api/v1", "/api/v1/auth/me", "/api/v1/anything".
- The lone pattern "*" disables the plugin (matches everything; would drop every trace — operators almost certainly don't want this, so we treat it as a config bug and reject it at Init).
Why match the display-side semantics: the viewer's path input and the capture-side skip both want to express the same operator intent ("ignore admin UI polling on /api/v1/*"). Identical syntax means the operator copies the same string into both places. Glob libraries (path.Match, doublestar) would be over-engineered for the v0 surface — two cases is enough.
Index ¶
Constants ¶
const Name = "path-filter"
Name is the plugin identifier used in config and telemetry.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Patterns is the list of paths to drop from recording. Exact match
// or trailing-"*" prefix match per the package doc.
Patterns []string `yaml:"patterns"`
}
Config is the YAML subtree under plugins.config.path-filter.
Defaults: zero value (Patterns: nil) is a no-op plugin that records every trace. The operator opts in by listing patterns.
type Pattern ¶ added in v0.1.2
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a parsed Config.Patterns entry. Exported so sibling plugins (e.g. internal/plugin/builtin/capturefilter) can reuse the compile + match logic without owning a duplicate copy of the parser.
Fields are package-private — callers use Matches.
func Compile ¶ added in v0.1.2
Compile parses operator-supplied pattern strings into Patterns, enforcing the same validation pathfilter.Plugin.Init enforces:
- Empty strings are rejected.
- The lone "*" pattern is rejected (would match everything).
- Trailing "*" → prefix match on the leading body.
- No "*" → exact match.
patterns is the operator-facing []string. The slice may be nil or empty; either yields a nil result + nil error so callers can use the same code path for "no patterns configured" as for "operator listed patterns".
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is the path-filter implementation. It satisfies plugin.Plugin and plugin.ObserveOnFinalize. Construction is trivial; the patterns are compiled in Init.
func New ¶
func New() *Plugin
New returns an uninitialized Plugin. The caller (Registry) MUST call Init before invoking OnFinalize — calling OnFinalize on a fresh Plugin yields shouldRecord=true (no patterns means nothing matches).
func (*Plugin) Init ¶
Init parses cfg into compiled patterns. cfg is the raw map form produced by YAML unmarshaling at the plugin.Registry layer.
Accepted shape:
{"patterns": ["/api/v1/*", "/api/v1/auth/me"]}
nil cfg = no patterns = the plugin is a no-op; an absent block is the same as an explicit empty block.
Returns an error on:
- Wrong type for "patterns" (not a list or list elements not strings).
- The lone pattern "*" (operator config bug — would drop every trace).
func (*Plugin) OnFinalize ¶
OnFinalize returns shouldRecord=false when tr.Path matches any of the configured patterns, shouldRecord=true otherwise. The error return is always nil for path-filter — pattern matching cannot fail at runtime once patterns compile cleanly in Init.
The context is accepted to honor the plugin interface contract but is not consulted; matching is non-blocking and cheap.
Renamed from BeforeRecord per plugin-b-c-spec §7.3 (Phase A migration).