zapx: Index | Files

package zmetrics

import ""

Package zmetrics (EXPERIMENTAL) provides a zap logger that can report metrics based on field names and field values.

TODO: examples


Package Files

collector.go core.go doc.go values.go

func Collect Uses

func Collect(l *zap.Logger, c *Collectors) *zap.Logger

Collect attaches collectors to the logger

func IncrementValue Uses

func IncrementValue(zapcore.Field) float64

IncrementValue returns 1 when a field is encountered

func NumericValue Uses

func NumericValue(f zapcore.Field) float64

NumericValue returns the numeric value of the field. It supports most basic numeric types such as Duration, Floats, and signed/unsigned integers.

func UnixNanoTimeValue Uses

func UnixNanoTimeValue(f zapcore.Field) float64

UnixNanoTimeValue returns the unix nanosecond value of a time field.

func UnixTimeValue Uses

func UnixTimeValue(f zapcore.Field) float64

UnixTimeValue returns the unix value of a time field.

type Collectors Uses

type Collectors struct {
    Histograms map[string]HistogramCollector
    Counters   map[string]CounterCollector
    Gauges     map[string]GaugeCollector

Collectors is a container for all your metrics collectors. It should not be modified after creation.

func (*Collectors) ExactMatch Uses

func (c *Collectors) ExactMatch(f zapcore.Field)

ExactMatch tries to match the given field exactly

type CounterCollector Uses

type CounterCollector struct {
    Value ValueFunc

CounterCollector defines a collector for counters

func NewCounter Uses

func NewCounter(m metrics.Counter, v ValueFunc) CounterCollector

NewCounter instantiates a new counter collector

type GaugeCollector Uses

type GaugeCollector struct {
    Value ValueFunc

GaugeCollector defines a collector for gauges

func NewGauge Uses

func NewGauge(m metrics.Gauge, v ValueFunc) GaugeCollector

NewGauge instantiates a new gauge collector

type HistogramCollector Uses

type HistogramCollector struct {
    Value ValueFunc

HistogramCollector defines a collector for histograms

func NewHistogram Uses

func NewHistogram(m metrics.Histogram, v ValueFunc) HistogramCollector

NewHistogram instantiates a new histogram collector

type ValueFunc Uses

type ValueFunc func(zapcore.Field) float64

ValueFunc returns the value associated with a field. Some default convenience implementations are provided (IncrementValue, NumericValue, etc.)

Package zmetrics imports 6 packages (graph). Updated 2019-09-25. Refresh now. Tools for package owners.