metrics

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitContext

func InitContext(ctx context.Context) context.Context

InitContext adds a cache metrics struct to the context to allow keeping track of cache calls during a request

func RecordCacheDelete

func RecordCacheDelete(ctx context.Context, start time.Time)

RecordCacheDelete records a deletion from the cache

func RecordCacheHit

func RecordCacheHit(ctx context.Context, duration time.Duration)

RecordCacheHit records a cache hit

func RecordCacheMiss

func RecordCacheMiss(ctx context.Context, duration time.Duration)

RecordCacheMiss records a cache miss

func RecordCacheStore

func RecordCacheStore(ctx context.Context, start time.Time)

RecordCacheStore records store data in the cache

func RecordMultiGet

func RecordMultiGet(ctx context.Context, hits, misses int, duration time.Duration)

RecordMultiGet records getting multiple objects from the cache

func ResetContext

func ResetContext(ctx context.Context) context.Context

ResetContext resets/adds a cache metrics struct to the context to allow keeping track of cache calls during a request

Types

type CacheMetrics

type CacheMetrics struct {
	Calls             int
	Hits              int
	Misses            int
	Deletions         int
	GetLatencies      time.Duration
	StoreLatencies    time.Duration
	DeletionLatencies time.Duration
}

CacheMetrics keeps track of cache calls during a request We don't take a lock to access these fields as we perform read only once per request at the end, effectively single threaded

func GetMetrics

func GetMetrics(ctx context.Context) (*CacheMetrics, error)

GetMetrics returns the cache metrics structure from the context, errors out if it is not there.

func (*CacheMetrics) GetTotalDuration

func (m *CacheMetrics) GetTotalDuration() time.Duration

GetTotalDuration returns the sum of the time spend calling the cache

func (*CacheMetrics) HadCalls

func (m *CacheMetrics) HadCalls() bool

HadCalls returns true if there were any cache calls

Jump to

Keyboard shortcuts

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