...

Package ratemap

import "github.com/go-kit/kit/metrics/internal/ratemap"
Overview
Index

Overview ▾

Package ratemap implements a goroutine-safe map of string to float64. It can be embedded in implementations whose metrics support fixed sample rates, so that an additional parameter doesn't have to be tracked through the e.g. lv.Space object.

type RateMap

RateMap is a simple goroutine-safe map of string to float64.

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

func New

func New() *RateMap

New returns a new RateMap.

func (*RateMap) Get

func (m *RateMap) Get(name string) float64

Get retrieves the rate for the given name, or 1.0 if none is set. Get is safe for concurrent access by multiple goroutines.

func (*RateMap) Set

func (m *RateMap) Set(name string, rate float64)

Set writes the given name/rate pair to the map. Set is safe for concurrent access by multiple goroutines.