go-platform: github.com/micro/go-platform/metrics Index | Files

package metrics

import "github.com/micro/go-platform/metrics"

Package metrics is an interface for instrumentation.

Index

Package Files

context.go metrics.go options.go

Variables

var (
    DefaultNamespace     = "micro"
    DefaultBatchInterval = time.Second * 5
)

func NewContext Uses

func NewContext(ctx context.Context, c Metrics) context.Context

type Counter Uses

type Counter interface {
    // Increment by the given value
    Incr(d uint64)
    // Decrement by the given value
    Decr(d uint64)
    // Reset the counter
    Reset()
    // Label the counter
    WithFields(f Fields) Counter
}

type Fields Uses

type Fields map[string]string

type Gauge Uses

type Gauge interface {
    // Set the gauge value
    Set(d int64)
    // Reset the gauge
    Reset()
    // Label the gauge
    WithFields(f Fields) Gauge
}

type Histogram Uses

type Histogram interface {
    // Record a timing
    Record(d int64)
    // Reset the histogram
    Reset()
    // Label the histogram
    WithFields(f Fields) Histogram
}

type Metrics Uses

type Metrics interface {
    Close() error
    Init(...Option) error
    Counter(id string) Counter
    Gauge(id string) Gauge
    Histogram(id string) Histogram
    // Name
    String() string
}

Metrics provides a way to instrument application data

func FromContext Uses

func FromContext(ctx context.Context) (Metrics, bool)

type Option Uses

type Option func(o *Options)

func BatchInterval Uses

func BatchInterval(b time.Duration) Option

func Collectors Uses

func Collectors(c ...string) Option

func Namespace Uses

func Namespace(n string) Option

func WithFields Uses

func WithFields(f Fields) Option

type Options Uses

type Options struct {
    Namespace     string
    Fields        Fields
    Collectors    []string
    BatchInterval time.Duration
}

Package metrics imports 2 packages (graph) and is imported by 4 packages. Updated 2018-02-20. Refresh now. Tools for package owners.