Documentation
¶
Overview ¶
Package metrics provides a lightweight in-process metrics registry with Prometheus text-format output. It requires zero external dependencies.
Instrumented points on the hot path:
- agentguard_checks_total — counter, by decision label
- agentguard_request_duration_ms — histogram, end-to-end /v1/check
- agentguard_policy_eval_duration_ms — histogram, Engine.Check only
- agentguard_audit_write_duration_ms — histogram, Logger.Log only
- agentguard_pending_approvals — gauge, current queue depth
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ChecksTotal uint64 // all /v1/check requests AllowedTotal uint64 DeniedTotal uint64 ApprovalTotal uint64 // REQUIRE_APPROVAL decisions RateLimitedTotal uint64 // rate-limit denies )
View Source
var ( RequestDuration = newHistogram(durationBuckets) PolicyEvalDuration = newHistogram(durationBuckets) AuditWriteDuration = newHistogram(durationBuckets) )
Package-level histograms.
Functions ¶
func IncDecision ¶
func IncDecision(decision string)
IncDecision increments the appropriate decision counter.
func SetPendingApprovals ¶
func SetPendingApprovals(n int)
SetPendingApprovals sets the current queue depth gauge.
func WritePrometheus ¶
WritePrometheus writes all metrics to w in the Prometheus text exposition format (https://prometheus.io/docs/instrumenting/exposition_formats/).
Types ¶
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks a distribution using cumulative bucket counts. Each bucket counts observations with value ≤ the bucket bound, which is the Prometheus histogram convention.
Click to show internal directories.
Click to hide internal directories.