Documentation
¶
Index ¶
- Constants
- func IsInitialized() bool
- func RecordCacheFill(ctx context.Context, role string, duration time.Duration, err error)
- func RecordCacheOperation(ctx context.Context, operation string, duration time.Duration, hit bool, ...)
- func RegisterManagerMetrics(statsProvider func() ManagerMetricsStats, poolName string) func()
- func ResetForTesting()
- type ManagerMetricsStats
Constants ¶
const ( FillLeader = "leader" FillFollower = "follower" )
Fill roles emitted as the cache.fill.role attribute.
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
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.