metrics

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 4 Imported by: 0

README

GoDoc CircleCI

This library provides Go applications a simple way to report dimensional statistics with optional support for Influx line protocol.

Installation

go get github.com/itzg/go-metrics

Import

import (
	"github.com/itzg/go-metrics"
)

Documentation

Overview

Package metrics provides Go applications a simple way to report statistics.

Applications will start by creating a Registry and typically just one of those. One or more Measurement's will be created/obtained from the Registry each Measurement best aligns with a subsystem of the application since a measurement in turn contains one or more fields.

The fields of the measurement, counters and gauges, are what the application code will directly use to increment and provide values representing the activity of the application.

Reporters, which may be a subsystem of the application, will periodically utilize the Registry's Walk function to gather a snapshot of all registered metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter interface {
	Inc()
	Add(amount int64)
}

type FloatValueProvider

type FloatValueProvider func() float64

type IntValueProvider

type IntValueProvider func() int64

type Measurement

type Measurement interface {
	IntGauge(field string, valueProvider IntValueProvider)
	FloatGauge(field string, valueProvider FloatValueProvider)
	Counter(field string) Counter
	CumulativeCounter(field string) Counter
}

type Registry

type Registry interface {
	Measurement(name string, tags ...Tag) Measurement
	Walk(timestamp time.Time, consumer SnappedMeasurementConsumer)
}

func NewRegistry

func NewRegistry(tags ...Tag) Registry

type SnappedMeasurement

type SnappedMeasurement struct {
	Timestamp time.Time
	Name      string
	Tags      TagSet
	// Fields maps named fields to either an int64, float64, string, bool
	Fields map[string]interface{}
}

type SnappedMeasurementConsumer

type SnappedMeasurementConsumer func(m *SnappedMeasurement)

type Tag

type Tag struct {
	Key, Value string
}

Tag represents a single tag (or dimension) of a measurement-series. It is recommended that you use the abbreviated struct literal form to construct tag entries, such as:

Tag{"stack","prod"}

but you can always specify the field names for clarity:

Tag{Key:"stack", Value:"prod"}

func T added in v0.1.1

func T(key, value string) Tag

T is a helper function to create a Tag

type TagSet

type TagSet []Tag

func JoinTags

func JoinTags(tags ...Tag) TagSet

JoinTags joins individual tags into a TagSet

func (TagSet) HashKey

func (t TagSet) HashKey() string

func (*TagSet) Len

func (t *TagSet) Len() int

func (*TagSet) Less

func (t *TagSet) Less(i, j int) bool

func (TagSet) Merge

func (t TagSet) Merge(more TagSet) TagSet

Merge builds a new TagSet populated with the receiver's tags and then the given tags. The receiver can be nil.

func (*TagSet) Swap

func (t *TagSet) Swap(i, j int)

func (*TagSet) With

func (t *TagSet) With(tag Tag) TagSet

Directories

Path Synopsis
reporters

Jump to

Keyboard shortcuts

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