metrics

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 3 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 DB metrics struct to the context to allow keeping track of DB 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

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 DB calls during a request

func GetMetrics

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

GetMetrics returns the DB 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 DB

func (*CacheMetrics) HadCalls

func (m *CacheMetrics) HadCalls() bool

HadCalls returns true if there were any DB calls

Jump to

Keyboard shortcuts

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