metrics

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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 {
	// contains filtered or unexported fields
}

CacheMetrics keeps track of cache calls during a request

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) GetCounters added in v1.3.0

func (m *CacheMetrics) GetCounters() (int, int, int)

GetCounters returns the number of cache calls, hits and misses

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