Documentation
¶
Overview ¶
Package deprecation is the AgentGuard helper for flagging features that are scheduled for removal. It does three things:
- Logs a single WARN line the first time each deprecated feature is used in a given process (so a long-running server does not spam its log).
- Tracks a per-feature counter that is exported as agentguard_deprecations_used_total{feature="..."} by the metrics package. Scraping the counter before a planned removal release is the way to tell whether anyone is still relying on the feature.
- Keeps the stable feature-key convention in one place. Keys must match the "feature" column in docs/DEPRECATIONS.md — if you add a Warn() call, add the matching row in that table in the same commit.
The helper is deliberately process-local. Cross-restart aggregation happens through the scraped Prometheus counter, not through shared state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
Count returns the current usage count for the given feature. Primarily used by tests; runtime consumers should go through Snapshot().
func Reset ¶
func Reset()
Reset clears all feature counters. Test-only helper; not exported for production use because deprecation counters must survive the lifetime of the server process to be useful for scraping.
func Snapshot ¶
Snapshot returns a copy of all current feature counters. The metrics package consumes this to emit agentguard_deprecations_used_total. The returned map is owned by the caller.
func Warn ¶
func Warn(feature, msg string)
Warn records that a deprecated feature was used. The first call per feature key emits a WARN log line in the form:
WARN deprecation feature=<key> msg=<msg>
Subsequent calls with the same key only increment the counter. msg should include both the deprecated-in and removal-target releases plus a pointer to docs/DEPRECATIONS.md, so operators reading the log can act without digging through source.
Callers must use a stable key that matches the "feature" column in docs/DEPRECATIONS.md. The metric cardinality is bounded by that table.
Types ¶
This section is empty.