tracking

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpGet           = "get"
	OpSet           = "set"
	OpDelete        = "delete"
	OpGetOrSet      = "getorset"
	OpCompareAndSet = "cas"
	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 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 Get operations)
  • 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