deprecation

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package deprecation is the AgentGuard helper for flagging features that are scheduled for removal. It does three things:

  1. 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).
  2. 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.
  3. 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

func Count(feature string) uint64

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

func Snapshot() map[string]uint64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL