metrics

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics provides a lightweight in-process metrics registry with Prometheus text-format output. It requires zero external dependencies.

State lives in a Registry. The package-level functions delegate to Default, which is what the binaries use; tests that need isolation construct their own Registry (or call Reset) instead of doing before/after delta arithmetic against process-global counters.

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

View Source
const (
	ApprovalEvictedLRUResolved = "lru_resolved"
	ApprovalEvictedQueueFull   = "queue_full"
)

Well-known reason labels for IncApprovalEvicted. When the approval queue is at capacity, either an old resolved entry is dropped to make room (lru_resolved) or the request is refused with 503 because nothing was resolved (queue_full). Both paths increment this counter so operators can distinguish "we need a bigger queue" from "we need more approvers".

View Source
const (
	MigrationStatusRan     = "ran"
	MigrationStatusSkipped = "skipped"
	MigrationStatusFailed  = "failed"
)

Migration status values for SetMigrationStatus.

View Source
const (
	NotifyDroppedQueueFull = "queue_full"
)

Well-known reason labels for IncNotifyDropped. Kept bounded so the Prometheus series cardinality stays predictable.

View Source
const (
	RejectedBodyTooLarge = "body_too_large"
)

Well-known reason labels for IncRequestRejected. Other reasons are allowed but callers must keep the cardinality bounded.

View Source
const (
	SSEDroppedSlowConsumer = "slow_consumer"
)

SSEDroppedSlowConsumer labels a broadcast that was discarded because the per-subscriber channel was full (the subscriber isn't draining fast enough). This is the fail-fast drop in broadcastLocked's default case.

Variables

View Source
var Default = NewRegistry()

Default is the process-wide registry the package-level functions delegate to. Swap or Reset it only in tests.

Functions

func AddAuditBufferedDrainedFromOverflow added in v0.9.0

func AddAuditBufferedDrainedFromOverflow(n uint64)

func AddAuditReplayEntries added in v0.5.0

func AddAuditReplayEntries(n uint64)

func AddLLMProxyStreamsActive added in v0.9.0

func AddLLMProxyStreamsActive(d int64) int64

func AddNotifyDespooled added in v0.9.0

func AddNotifyDespooled(n uint64)

func AllowedTotal

func AllowedTotal() uint64

func ApprovalEvictedFor added in v0.5.0

func ApprovalEvictedFor(reason string) uint64

func ApprovalReplayMismatchTotal added in v0.5.0

func ApprovalReplayMismatchTotal() uint64

func ApprovalTotal

func ApprovalTotal() uint64

func AuditBufferedDrainedFromOverflowTotal added in v0.9.0

func AuditBufferedDrainedFromOverflowTotal() uint64

func AuditBufferedDroppedToOverflowTotal added in v0.9.0

func AuditBufferedDroppedToOverflowTotal() uint64

func AuditCorruptLinesTotal added in v0.5.0

func AuditCorruptLinesTotal() uint64

func AuditReplayEntriesTotal added in v0.5.0

func AuditReplayEntriesTotal() uint64

func AuditRotationsTotal added in v0.5.0

func AuditRotationsTotal() uint64

func ChecksTotal

func ChecksTotal() uint64

func DecSSESubscribers added in v0.5.0

func DecSSESubscribers()

func DeniedTotal

func DeniedTotal() uint64

func IncApprovalEvicted added in v0.5.0

func IncApprovalEvicted(reason string)

func IncApprovalReplayMismatch added in v0.5.0

func IncApprovalReplayMismatch()

func IncAuditBufferedDroppedToOverflow added in v0.9.0

func IncAuditBufferedDroppedToOverflow()

func IncAuditCorruptLine added in v0.5.0

func IncAuditCorruptLine()

func IncAuditRotation added in v0.5.0

func IncAuditRotation()

func IncDecision

func IncDecision(decision string)

func IncLLMProxyBufferOverflow added in v0.5.0

func IncLLMProxyBufferOverflow(provider string)

func IncLLMProxyNonStreamingOverflow added in v0.5.0

func IncLLMProxyNonStreamingOverflow(provider string)

func IncLLMProxyProtocolViolation added in v0.9.0

func IncLLMProxyProtocolViolation(provider string)

func IncLLMProxyStreamsRejected added in v0.5.0

func IncLLMProxyStreamsRejected()

func IncNotifyDropped added in v0.5.0

func IncNotifyDropped(notifier, reason string)

func IncNotifySpooled added in v0.9.0

func IncNotifySpooled()

func IncRateLimitBucketEvicted added in v0.5.0

func IncRateLimitBucketEvicted(scope string)

func IncRateLimited

func IncRateLimited()

func IncRequestRejected added in v0.5.0

func IncRequestRejected(reason string)

func IncSSEEventDropped added in v0.5.0

func IncSSEEventDropped(reason string)

func IncSSESubscribers added in v0.5.0

func IncSSESubscribers()

func LLMProxyBufferOverflowFor added in v0.5.0

func LLMProxyBufferOverflowFor(provider string) uint64

func LLMProxyNonStreamingOverflowFor added in v0.5.0

func LLMProxyNonStreamingOverflowFor(provider string) uint64

func LLMProxyProtocolViolationFor added in v0.9.0

func LLMProxyProtocolViolationFor(provider string) uint64

func LLMProxyStreamsActive added in v0.5.0

func LLMProxyStreamsActive() int64

func LLMProxyStreamsRejectedTotal added in v0.5.0

func LLMProxyStreamsRejectedTotal() uint64

func MigrationStatusFor added in v0.5.0

func MigrationStatusFor(from, to, status string) int64

func NotifyDespooledTotal added in v0.9.0

func NotifyDespooledTotal() uint64

func NotifyDroppedFor added in v0.5.0

func NotifyDroppedFor(notifier, reason string) uint64

func NotifyDroppedSnapshot added in v0.5.0

func NotifyDroppedSnapshot() map[notifyDroppedKey]uint64

func NotifySpooledTotal added in v0.9.0

func NotifySpooledTotal() uint64

func ObserveAuditWriteDuration added in v0.9.0

func ObserveAuditWriteDuration(ms float64)

func ObserveNotifyDispatch added in v0.5.0

func ObserveNotifyDispatch(notifier string, seconds float64)

func ObservePolicyEvalDuration added in v0.9.0

func ObservePolicyEvalDuration(ms float64)

func ObserveRequestDuration added in v0.9.0

func ObserveRequestDuration(ms float64)

func RateLimitBucketEvictedFor added in v0.5.0

func RateLimitBucketEvictedFor(scope string) uint64

func RateLimitedTotal

func RateLimitedTotal() uint64

func RequestRejectedSnapshot added in v0.5.0

func RequestRejectedSnapshot() map[string]uint64

func Reset added in v0.9.0

func Reset()

Reset zeroes the Default registry. Test helper.

func SSEEventDroppedFor added in v0.5.0

func SSEEventDroppedFor(reason string) uint64

func SetAuditBufferedQueueDepth added in v0.9.0

func SetAuditBufferedQueueDepth(n int64)

func SetAuditReplayDuration added in v0.5.0

func SetAuditReplayDuration(d time.Duration)

func SetLLMProxyStreamsActive added in v0.5.0

func SetLLMProxyStreamsActive(n int64)

func SetMigrationStatus added in v0.5.0

func SetMigrationStatus(from, to, status string, value int64)

func SetNotifyQueueDepth added in v0.5.0

func SetNotifyQueueDepth(n int)

func SetPendingApprovals

func SetPendingApprovals(n int)

func SetRateLimitBuckets added in v0.5.0

func SetRateLimitBuckets(n int)

func WritePrometheus

func WritePrometheus(w io.Writer)

WritePrometheus writes the Default registry in Prometheus text format.

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.

func (*Histogram) Observe

func (h *Histogram) Observe(ms float64)

Observe records one observation in milliseconds.

func (*Histogram) Snapshot

func (h *Histogram) Snapshot() (buckets []float64, counts []uint64, sum float64, total uint64)

Snapshot returns a copy of internal state under the lock.

type Registry added in v0.9.0

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds every metric series for one logical process. The binaries use the package-level Default; tests construct their own via NewRegistry for isolation.

Deprecation-usage counters are the one exception: they live in pkg/deprecation's process-global state and are only read at exposition time, so they are shared across registries and unaffected by Reset.

func NewRegistry added in v0.9.0

func NewRegistry() *Registry

NewRegistry returns an empty Registry with all series initialised.

func (*Registry) AddAuditBufferedDrainedFromOverflow added in v0.9.0

func (r *Registry) AddAuditBufferedDrainedFromOverflow(n uint64)

AddAuditBufferedDrainedFromOverflow counts entries the recovery goroutine pushed back from the overflow file into the queue.

func (*Registry) AddAuditReplayEntries added in v0.9.0

func (r *Registry) AddAuditReplayEntries(n uint64)

AddAuditReplayEntries records entries processed during replay. Cumulative across multiple replays in pathological re-entrance, but in the normal single-replay-per-process case just equals that one replay's count.

func (*Registry) AddLLMProxyStreamsActive added in v0.9.0

func (r *Registry) AddLLMProxyStreamsActive(delta int64) int64

AddLLMProxyStreamsActive applies a delta (+1 admit, -1 release) to the active-streams gauge. Preferred over SetLLMProxyStreamsActive on concurrent paths: deltas compose atomically, while storing a captured snapshot lets a slower admit clobber a newer value and under-report live streams.

func (*Registry) AddNotifyDespooled added in v0.9.0

func (r *Registry) AddNotifyDespooled(n uint64)

AddNotifyDespooled counts spooled events re-enqueued for dispatch.

func (*Registry) AllowedTotal added in v0.9.0

func (r *Registry) AllowedTotal() uint64

func (*Registry) ApprovalEvictedFor added in v0.9.0

func (r *Registry) ApprovalEvictedFor(reason string) uint64

ApprovalEvictedFor returns the count for a specific reason (for tests).

func (*Registry) ApprovalReplayMismatchTotal added in v0.9.0

func (r *Registry) ApprovalReplayMismatchTotal() uint64

func (*Registry) ApprovalTotal added in v0.9.0

func (r *Registry) ApprovalTotal() uint64

func (*Registry) AuditBufferedDrainedFromOverflowTotal added in v0.9.0

func (r *Registry) AuditBufferedDrainedFromOverflowTotal() uint64

AuditBufferedDrainedFromOverflowTotal returns the drain counter (for tests).

func (*Registry) AuditBufferedDroppedToOverflowTotal added in v0.9.0

func (r *Registry) AuditBufferedDroppedToOverflowTotal() uint64

AuditBufferedDroppedToOverflowTotal returns the spill counter (for tests).

func (*Registry) AuditCorruptLinesTotal added in v0.9.0

func (r *Registry) AuditCorruptLinesTotal() uint64

AuditCorruptLinesTotal returns the corrupt-line counter (for tests).

func (*Registry) AuditReplayEntriesTotal added in v0.9.0

func (r *Registry) AuditReplayEntriesTotal() uint64

AuditReplayEntriesTotal returns the replay-entries counter (for tests).

func (*Registry) AuditRotationsTotal added in v0.9.0

func (r *Registry) AuditRotationsTotal() uint64

AuditRotationsTotal returns the rotation counter (for tests).

func (*Registry) ChecksTotal added in v0.9.0

func (r *Registry) ChecksTotal() uint64

Read accessors for the decision counters. These replaced the exported raw uint64 vars (pre-v0.6.1 callers did metrics.X()).

func (*Registry) DecSSESubscribers added in v0.9.0

func (r *Registry) DecSSESubscribers()

DecSSESubscribers is the counterpart to IncSSESubscribers.

func (*Registry) DeniedTotal added in v0.9.0

func (r *Registry) DeniedTotal() uint64

func (*Registry) IncApprovalEvicted added in v0.9.0

func (r *Registry) IncApprovalEvicted(reason string)

IncApprovalEvicted increments agentguard_approvals_evicted_total{reason=...}. Cardinality is bounded to the ApprovalEvicted* constants above.

func (*Registry) IncApprovalReplayMismatch added in v0.9.0

func (r *Registry) IncApprovalReplayMismatch()

IncApprovalReplayMismatch increments agentguard_approval_replay_mismatch_total. Called from pkg/proxy.handleCheck when the approval-id round-trip lookup hits an entry but the retry request's shape differs from the original.

The counter tracks /v1/check requests that carried an approval_id whose corresponding PendingAction.Request did not match the retry's operationally-meaningful fields (agent_id / scope / command / path / domain / url / action). Mismatches are NOT short-circuited to the cached decision — the request falls through to normal Engine.Check evaluation. This metric is the security signal: legitimate retries match shape and never increment it; a non-zero rate means either a buggy gateway is reusing ids across distinct actions or an attacker who learned an approved id is replaying it against unrelated commands.

See V05 audit B1 (R-Sec H1, R-Stub C3) for the underlying gating- bypass finding the validator closes.

func (*Registry) IncAuditBufferedDroppedToOverflow added in v0.9.0

func (r *Registry) IncAuditBufferedDroppedToOverflow()

IncAuditBufferedDroppedToOverflow counts an audit entry spilled to the BufferedAsyncLogger's overflow file (queue saturated, shutdown race, or underlying-logger failure). The entry is durable on disk, not lost; a sustained non-zero rate means the queue/worker sizing can't keep up.

func (*Registry) IncAuditCorruptLine added in v0.9.0

func (r *Registry) IncAuditCorruptLine()

IncAuditCorruptLine bumps agentguard_audit_corrupt_lines_total: audit log lines that failed JSON parse during Query() and were skipped. Rare in practice — the usual cause is a crash between the write syscall and the newline flush, or disk corruption. Kept visible via /metrics so operators can spot silent audit-file degradation instead of discovering it when a query returns fewer entries than expected.

func (*Registry) IncAuditRotation added in v0.9.0

func (r *Registry) IncAuditRotation()

IncAuditRotation increments agentguard_audit_rotations_total. Called from the FileLogger rotation success path after the new live file is open.

func (*Registry) IncDecision added in v0.9.0

func (r *Registry) IncDecision(decision string)

IncDecision increments the appropriate decision counter.

func (*Registry) IncLLMProxyBufferOverflow added in v0.9.0

func (r *Registry) IncLLMProxyBufferOverflow(provider string)

IncLLMProxyBufferOverflow increments agentguard_llmproxy_buffer_overflow_total{provider=...}. Provider MUST be "openai" or "anthropic" — the LLM proxy enforces that upstream so cardinality stays bounded. The proxy buffers streaming tool_call deltas up to --max-buffer-bytes; if accumulated arguments exceed that cap before finish_reason arrives, the call is denied as a synthetic refusal (operators want this visible). See pkg/llmproxy/streaming.go for the call sites.

func (*Registry) IncLLMProxyNonStreamingOverflow added in v0.9.0

func (r *Registry) IncLLMProxyNonStreamingOverflow(provider string)

IncLLMProxyNonStreamingOverflow increments agentguard_llmproxy_non_streaming_overflow_total{provider=...}. Distinct from the streaming overflow counter so dashboards can break out the two failure modes (the streaming counter measures runaway tool_call argument accumulation; this one measures upstream response bodies that are simply too large to safely inspect for tool_calls). F9 (B2) wires the non-streaming forwarders.

func (*Registry) IncLLMProxyProtocolViolation added in v0.9.0

func (r *Registry) IncLLMProxyProtocolViolation(provider string)

IncLLMProxyProtocolViolation increments agentguard_llmproxy_protocol_violation_total{provider=...}. Security audit finding H1: a structurally unsafe stream (e.g. a second Anthropic tool_use content block opened before the first closed) is refused fail-closed rather than partially gated. A non-zero rate here means the proxy refused a stream whose block ordering could otherwise have smuggled an ungated tool call past the gate. See pkg/llmproxy/streaming.go.

func (*Registry) IncLLMProxyStreamsRejected added in v0.9.0

func (r *Registry) IncLLMProxyStreamsRejected()

IncLLMProxyStreamsRejected bumps agentguard_llmproxy_streams_rejected_total. Called once per streaming request that was refused with 503 because the global cap was already at MaxConcurrentStreams.

func (*Registry) IncNotifyDropped added in v0.9.0

func (r *Registry) IncNotifyDropped(notifier, reason string)

IncNotifyDropped increments the labeled counter for a notification drop. notifier should be a bounded-cardinality notifier type ("webhook"/"slack"/"console"/"log"); reason should be a stable NotifyDropped* constant. Callers MUST NOT pass agent- or user-supplied strings here — that would explode Prometheus cardinality.

func (*Registry) IncNotifySpooled added in v0.9.0

func (r *Registry) IncNotifySpooled()

IncNotifySpooled counts a notification event written to the on-disk spool because the dispatch queue was full (durable, will be retried by the recovery loop — NOT a drop).

func (*Registry) IncRateLimitBucketEvicted added in v0.9.0

func (r *Registry) IncRateLimitBucketEvicted(scope string)

IncRateLimitBucketEvicted increments agentguard_ratelimit_bucket_evictions_total{scope=...}. Cardinality is bounded by the set of policy scopes (typically < 20 across a deployment).

func (*Registry) IncRateLimited added in v0.9.0

func (r *Registry) IncRateLimited()

IncRateLimited increments the rate-limit-specific counter.

It used to also bump the checks/denied totals, which double-counted rate-limited requests because logAndRespond unconditionally calls IncDecision("DENY") for the synthetic rate-limit DENY result. As of v0.5 the unified logAndRespond path owns those totals for every decision (including the synthetic rate-limit DENY); IncRateLimited only touches the rate-limit-specific series.

Closes R3 #21 (audit finding "rate-limited requests double-count ChecksTotal and DeniedTotal").

func (*Registry) IncRequestRejected added in v0.9.0

func (r *Registry) IncRequestRejected(reason string)

IncRequestRejected increments agentguard_request_rejected_total{reason=...}. Keyed by a short, bounded-cardinality reason string.

func (*Registry) IncSSEEventDropped added in v0.9.0

func (r *Registry) IncSSEEventDropped(reason string)

IncSSEEventDropped bumps the labeled counter for an SSE broadcast drop. Reasons are a bounded string set; slow_consumer is the only reason the current broadcast path produces.

func (*Registry) IncSSESubscribers added in v0.9.0

func (r *Registry) IncSSESubscribers()

IncSSESubscribers is called on Subscribe. Matching dec runs on Unsubscribe so the gauge stays accurate even if a client drops without the server side noticing (Unsubscribe is always called from the SSE handler's defer). Maintained via inc/dec rather than a scrape-time read so the /metrics handler doesn't have to take the ApprovalQueue lock.

func (*Registry) LLMProxyBufferOverflowFor added in v0.9.0

func (r *Registry) LLMProxyBufferOverflowFor(provider string) uint64

LLMProxyBufferOverflowFor returns the current count (for tests).

func (*Registry) LLMProxyNonStreamingOverflowFor added in v0.9.0

func (r *Registry) LLMProxyNonStreamingOverflowFor(provider string) uint64

LLMProxyNonStreamingOverflowFor returns the current count (for tests).

func (*Registry) LLMProxyProtocolViolationFor added in v0.9.0

func (r *Registry) LLMProxyProtocolViolationFor(provider string) uint64

LLMProxyProtocolViolationFor returns the current count (for tests).

func (*Registry) LLMProxyStreamsActive added in v0.9.0

func (r *Registry) LLMProxyStreamsActive() int64

LLMProxyStreamsActive returns the current active-streams gauge value (for tests).

func (*Registry) LLMProxyStreamsRejectedTotal added in v0.9.0

func (r *Registry) LLMProxyStreamsRejectedTotal() uint64

LLMProxyStreamsRejectedTotal returns the rejected-streams counter (for tests).

func (*Registry) MigrationStatusFor added in v0.9.0

func (r *Registry) MigrationStatusFor(from, to, status string) int64

MigrationStatusFor returns the gauge value for a (from, to, status) triple (for tests).

func (*Registry) NotifyDespooledTotal added in v0.9.0

func (r *Registry) NotifyDespooledTotal() uint64

NotifyDespooledTotal returns the despooled counter (for tests).

func (*Registry) NotifyDroppedFor added in v0.9.0

func (r *Registry) NotifyDroppedFor(notifier, reason string) uint64

NotifyDroppedFor returns the count for a specific (notifier, reason) pair (for tests).

func (*Registry) NotifyDroppedSnapshot added in v0.9.0

func (r *Registry) NotifyDroppedSnapshot() map[notifyDroppedKey]uint64

NotifyDroppedSnapshot returns a copy of the current counts (for tests).

func (*Registry) NotifySpooledTotal added in v0.9.0

func (r *Registry) NotifySpooledTotal() uint64

NotifySpooledTotal returns the spooled counter (for tests).

func (*Registry) ObserveAuditWriteDuration added in v0.9.0

func (r *Registry) ObserveAuditWriteDuration(ms float64)

ObserveAuditWriteDuration records one Logger.Log latency in ms.

func (*Registry) ObserveNotifyDispatch added in v0.9.0

func (r *Registry) ObserveNotifyDispatch(notifier string, seconds float64)

ObserveNotifyDispatch records a dispatch latency in seconds for the named notifier type. A missing histogram is created lazily; cardinality is bounded to the notifierType() domain in pkg/notify (webhook|slack|console|log|unknown).

func (*Registry) ObservePolicyEvalDuration added in v0.9.0

func (r *Registry) ObservePolicyEvalDuration(ms float64)

ObservePolicyEvalDuration records one Engine.Check latency in ms.

func (*Registry) ObserveRequestDuration added in v0.9.0

func (r *Registry) ObserveRequestDuration(ms float64)

ObserveRequestDuration records one end-to-end /v1/check latency in ms.

func (*Registry) RateLimitBucketEvictedFor added in v0.9.0

func (r *Registry) RateLimitBucketEvictedFor(scope string) uint64

RateLimitBucketEvictedFor returns the eviction count for a scope (for tests).

func (*Registry) RateLimitedTotal added in v0.9.0

func (r *Registry) RateLimitedTotal() uint64

func (*Registry) RequestRejectedSnapshot added in v0.9.0

func (r *Registry) RequestRejectedSnapshot() map[string]uint64

RequestRejectedSnapshot returns a copy of the current counts (for tests).

func (*Registry) Reset added in v0.9.0

func (r *Registry) Reset()

Reset zeroes every series in the registry. Test helper — production code never resets metrics. Deprecation counters live in pkg/deprecation and are not touched.

func (*Registry) SSEEventDroppedFor added in v0.9.0

func (r *Registry) SSEEventDroppedFor(reason string) uint64

SSEEventDroppedFor returns the count for a specific reason (for tests).

func (*Registry) SetAuditBufferedQueueDepth added in v0.9.0

func (r *Registry) SetAuditBufferedQueueDepth(n int64)

SetAuditBufferedQueueDepth updates the buffered-audit queue gauge. Maintained by the BufferedAsyncLogger on enqueue/dequeue.

func (*Registry) SetAuditReplayDuration added in v0.9.0

func (r *Registry) SetAuditReplayDuration(d time.Duration)

SetAuditReplayDuration records the duration of the startup audit replay. Expressed in seconds in the Prometheus output; nanoseconds are stored atomically under the hood so the setter is a single instruction. Gauge, not histogram: replay is a one-shot startup event.

func (*Registry) SetLLMProxyStreamsActive added in v0.9.0

func (r *Registry) SetLLMProxyStreamsActive(n int64)

SetLLMProxyStreamsActive updates the active-streams gauge. Called from the llmproxy server on every stream entry/exit (which atomically also updates the underlying server-side counter — this metric mirrors that counter). 0 is a valid value (no streams in flight). The gauge is sampled by the llmproxy server, not the central server, so it lives in its own process — but it ships through the same metrics surface so a single Prometheus scrape config covers both binaries when the llmproxy mounts /metrics. Closes R-Sec H3.

func (*Registry) SetMigrationStatus added in v0.9.0

func (r *Registry) SetMigrationStatus(from, to, status string, value int64)

SetMigrationStatus updates the migration-status gauge for a given (from, to, status) triple. Value is 1 for the current outcome and 0 for the others — Prometheus can then do `max by (from,to) (...)`. Callers typically record one ran/skipped/failed value per migration per startup.

func (*Registry) SetNotifyQueueDepth added in v0.9.0

func (r *Registry) SetNotifyQueueDepth(n int)

SetNotifyQueueDepth updates the notify dispatch queue depth gauge. Set from the dispatcher on each Send attempt; a scrape-time read would race with enqueue without additional locking.

func (*Registry) SetPendingApprovals added in v0.9.0

func (r *Registry) SetPendingApprovals(n int)

SetPendingApprovals sets the current queue depth gauge.

func (*Registry) SetRateLimitBuckets added in v0.9.0

func (r *Registry) SetRateLimitBuckets(n int)

SetRateLimitBuckets updates the rate-limit bucket gauge. Called from the /metrics handler with Limiter.BucketCount() so operators can see bucket growth without exporting the limiter internals.

func (*Registry) WritePrometheus added in v0.9.0

func (r *Registry) WritePrometheus(w io.Writer)

WritePrometheus writes all metrics to w in the Prometheus text exposition format (https://prometheus.io/docs/instrumenting/exposition_formats/).

Jump to

Keyboard shortcuts

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