Documentation ¶
Index ¶
- Constants
- Variables
- func APIRequestAndTimeGRPC(request string, startTime time.Time)
- func APIRequestAndTimeGraphQL(request string, time float64)
- func APIRequestAndTimeREST(request string, time float64)
- func EthCallInc(labelValues ...string)
- func EvtForwardInc(labelValues ...string)
- func OrderCounterInc(labelValues ...string)
- func OrderGaugeAdd(n int, labelValues ...string)
- func Start(conf Config)
- func StartAPIRequestAndTimeGRPC(request string) func()
- func StartSnapshot(engine string) func()
- func UnconfirmedTxGaugeSet(n int)
- type Config
- type InstrumentOption
- func AgeBuckets(ab uint32) InstrumentOption
- func Buckets(b []float64) InstrumentOption
- func BufCap(bc uint32) InstrumentOption
- func Help(help string) InstrumentOption
- func Labels(labels map[string]string) InstrumentOption
- func MaxAge(m time.Duration) InstrumentOption
- func Namespace(ns string) InstrumentOption
- func Objectives(obj map[float64]float64) InstrumentOption
- func Subsystem(s string) InstrumentOption
- func Vectors(labels ...string) InstrumentOption
- type MetricInstrument
- type TimeCounter
Constants ¶
const ( // Gauge ... Gauge instrument = iota // Counter ... Counter // Histogram ... Histogram // Summary ... Summary )
Variables ¶
var ( // ErrInstrumentNotSupported signals the specified instrument is not yet supported. ErrInstrumentNotSupported = errors.New("instrument type unsupported") // ErrInstrumentTypeMismatch signal the type of the instrument is not expected. ErrInstrumentTypeMismatch = errors.New("instrument is not of the expected type") )
Functions ¶
func APIRequestAndTimeGRPC ¶
APIRequestAndTimeGRPC updates the metrics for GRPC API calls.
func APIRequestAndTimeGraphQL ¶
APIRequestAndTimeGraphQL updates the metrics for GraphQL API calls.
func APIRequestAndTimeREST ¶
APIRequestAndTimeREST updates the metrics for REST API calls.
func EthCallInc ¶
func EthCallInc(labelValues ...string)
EthCallInc increments the eth call counter.
func EvtForwardInc ¶
func EvtForwardInc(labelValues ...string)
EvtForwardInc increments the evt forward counter.
func OrderCounterInc ¶
func OrderCounterInc(labelValues ...string)
OrderCounterInc increments the order counter.
func OrderGaugeAdd ¶
OrderGaugeAdd increment the order gauge.
func StartAPIRequestAndTimeGRPC ¶
func StartAPIRequestAndTimeGRPC(request string) func()
StartAPIRequestAndTimeGRPC updates the metrics for GRPC API calls.
func StartSnapshot ¶
func StartSnapshot(engine string) func()
func UnconfirmedTxGaugeSet ¶
func UnconfirmedTxGaugeSet(n int)
UnconfirmedTxGaugeSet update the number of unconfirmed transactions.
Types ¶
type Config ¶
type Config struct { Level encoding.LogLevel `long:"log-level" description:" "` Timeout encoding.Duration `long:"timeout" description:" "` Port int `long:"port" description:" "` Path string `long:"path" description:" "` Enabled encoding.Bool `long:"enabled" description:" "` }
Config represents the configuration of the metric package.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
type InstrumentOption ¶
type InstrumentOption func(o *instrumentOpts)
InstrumentOption - vararg for instrument options setting.
func AgeBuckets ¶
func AgeBuckets(ab uint32) InstrumentOption
AgeBuckets - specific to summary type.
func Labels ¶
func Labels(labels map[string]string) InstrumentOption
Labels set labels for instrument (similar to vector, but with given values).
func Objectives ¶
func Objectives(obj map[float64]float64) InstrumentOption
Objectives - specific to summary type.
func Vectors ¶
func Vectors(labels ...string) InstrumentOption
Vectors - configuration used to create a vector of a given interface, slice of label names.
type MetricInstrument ¶
type MetricInstrument interface { Gauge() (prometheus.Gauge, error) GaugeVec() (*prometheus.GaugeVec, error) Counter() (prometheus.Counter, error) CounterVec() (*prometheus.CounterVec, error) Histogram() (prometheus.Histogram, error) HistogramVec() (*prometheus.HistogramVec, error) Summary() (prometheus.Summary, error) SummaryVec() (*prometheus.SummaryVec, error) }
MetricInstrument - template interface for mi type return value - only mock if needed, and only mock the funcs you use.
type TimeCounter ¶
type TimeCounter struct {
// contains filtered or unexported fields
}
TimeCounter holds a time.Time and a list of label values, hiding the start time from being accidentally overwritten, and removing the need to duplicate the label values.
func NewTimeCounter ¶
func NewTimeCounter(labelValues ...string) *TimeCounter
NewTimeCounter returns a new TimeCounter, with the start time already recorded.
func (*TimeCounter) EngineTimeCounterAdd ¶
func (tc *TimeCounter) EngineTimeCounterAdd()
EngineTimeCounterAdd is used to time a function. e.g.
func DoSomething() { timer := metrics.NewTimeCounter("x", "y", "z") // do something timer.EngineTimeCounterAdd() }