tracking

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FillLeader   = "leader"
	FillFollower = "follower"
)

Fill roles emitted as the cache.fill.role attribute.

View Source
const (
	OpGet              = "get"
	OpSet              = "set"
	OpDelete           = "delete"
	OpGetOrSet         = "getorset"
	OpCompareAndSet    = "cas"
	OpCompareAndDelete = "cad"
	OpHealth           = "ping"
)

Cache operation names

Variables

This section is empty.

Functions

func IsInitialized

func IsInitialized() bool

IsInitialized returns true if cache metrics have been initialized.

func RecordCacheFill added in v0.62.0

func RecordCacheFill(ctx context.Context, role string, duration time.Duration, err error)

RecordCacheFill records one load-through fill: role is FillLeader or FillFollower, duration spans the fill from miss to outcome, and err is the fill's error if any. The tenant on ctx, when present, becomes db.namespace.

func RecordCacheOperation

func RecordCacheOperation(ctx context.Context, operation string, duration time.Duration, hit bool, err error, namespace string)

RecordCacheOperation records cache operation metrics. This should be called after each cache operation.

Parameters:

  • ctx: context for metric recording
  • operation: operation name (get, set, delete, cas, etc.)
  • duration: operation duration
  • hit: whether this was a cache hit (for lookup operations: get and getorset)
  • err: error if operation failed
  • namespace: optional tenant identifier

func RegisterManagerMetrics

func RegisterManagerMetrics(statsProvider func() ManagerMetricsStats, poolName string) func()

RegisterManagerMetrics registers observable metrics for cache manager. The statsProvider function is called during each metrics collection cycle. Returns a cleanup function to unregister the metrics.

Metrics registered:

  • cache.manager.active_caches: Current number of active cache instances
  • cache.manager.total_created: Total caches created since manager start
  • cache.manager.evictions: Total evictions due to LRU policy
  • cache.manager.idle_cleanups: Total cleanups due to idle timeout
  • cache.manager.errors: Total initialization and close errors

func ResetForTesting

func ResetForTesting()

ResetForTesting resets the metric state for testing purposes.

Types

type ManagerMetricsStats

type ManagerMetricsStats struct {
	ActiveCaches int
	TotalCreated int
	Evictions    int
	IdleCleanups int
	Errors       int
}

ManagerMetricsStats holds the stats needed for manager metrics.

Jump to

Keyboard shortcuts

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