metric

package
v0.0.0-...-09258bd Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: MIT Imports: 3 Imported by: 0

README

Collect metrics in development

We'll use a fully-fledged docker image with statsd, influxdb, grafana and sqlite in it.

version: 3

services:
 collector:
  image: samuelebistoletti/docker-statsd-influxdb-grafana
  ports:
    - 8125:8125/udp # statsd
    - 8086:8086     # influxdb
    - 3003:3003     # grafana
    - 8088:8088     # sqlite
  environment:
    GF_DATABASE_TYPE: sqlite3
  volumes:
    - grafana-backup:/var/lib/grafana

volumes:
  grafana-backup:

Sign into grafana (username: root, password: root) and add a new data source:

Data source type: InfluxDB

HTTP URL:    http://localhost:8086
HTTP Access: direct

InfluxDB database: telegraf
InfluxDB user:     telegraf
InfluxDB password: telegraf

Documentation

Overview

Package metric provides an easy way to collect and dispatch application metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	// Send will dispatch the metric.
	Send(Event) error

	// Close terminates potential persistent connections.
	Close() error
}

Dispatcher is the interface used by all metric implementations.

func NewNoopDispatcher

func NewNoopDispatcher() Dispatcher

NewNoopDispatcher creates a new noop dispatcher instance.

func NewStatsdDispatcher

func NewStatsdDispatcher(prefix, statsdAddr string) (Dispatcher, error)

NewStatsdDispatcher creates a new statsd dispatcher instance.

type Event

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

Event represents a metric in the system.

func Count

func Count(name string, value int, kvs ...KV) Event

Count generates a count metric representing a value in the system. Processed requests is an example of a counter.

func Gauge

func Gauge(name string, value float64, kvs ...KV) Event

Gauge generates a gauge metric representing a measure at a given time. Request time or concurrent connections are examples of gauges.

type KV

type KV struct {
	K string
	V interface{}
}

KV represents a tag for a particular metric.

Jump to

Keyboard shortcuts

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