local

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package local contains a simple often non-blocking (on Increment) thread-safe counters that can be used across multiple goroutines, with results collected at the end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter is a custom implementation of a counter.

func (*Counter) Close

func (c *Counter) Close()

Close processes any remaining queued increments. This should be called only after all Increments to this counter have been called or sent already.

func (*Counter) Init

func (c *Counter) Init(name, description, unit string, aggr aggregation.Aggregation, tagKeys ...string) error

Init should be called once before the Record method is called on this counter. Subsequent calls to Record() should provide the TagValues to the TagKeys in the same order specified in Init. TagKeys should be a closed set of values, for example FHIR Resource type. Counters should not store any PHI.

func (*Counter) MaybeGetResult

func (c *Counter) MaybeGetResult() map[string]int64

MaybeGetResult returns a copy of the results for this counter.

func (*Counter) Record

func (c *Counter) Record(_ context.Context, val int64, tagValues ...string) error

Record adds val to the counter. The tagValues must match the tagKeys provided in the call to Init. Init must be called before the first call to Record. Counters should not store any PHI.

type Latency

type Latency struct {
	// contains filtered or unexported fields
}

Latency is a custom implementation of distribution/histogram metric.

func (*Latency) Close

func (l *Latency) Close()

Close processes any remaining queued increments. This should be called only after all Increments to this latency have been called or sent already.

func (*Latency) Init

func (l *Latency) Init(name, description, unit string, buckets []float64, tagKeys ...string) error

Init should be called once before the Record method is called on this counter. Subsequent calls to Record() should provide the TagValues to the TagKeys in the same order specified in Init. TagKeys should be a closed set of values, for example FHIR Resource type. Counters should not store any PHI. The distribution is defined by the Buckets. For example, Buckets: [0, 3, 5] will create a distribution with 4 buckets where the last bucket is anything > 5. Dist: <0, >=0 <3, >=3 <5, >=5.

func (*Latency) MaybeGetResult

func (l *Latency) MaybeGetResult() map[string][]int

MaybeGetResult returns a copy of the results of the latency.

func (*Latency) Record

func (l *Latency) Record(ctx context.Context, val float64, tagValues ...string) error

Record adds 1 to the correct bucket in the distribution. The tagValues must match the tagKeys provided in the call to Init. Init must be called before the first call to Record. Counters should not store any PHI.

Jump to

Keyboard shortcuts

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