stats

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// EventAlertTypeInfo is the "info" AlertType for events
	EventAlertTypeInfo = "info"
	// EventAlertTypeError is the "error" AlertType for events
	EventAlertTypeError = "error"
	// EventAlertTypeWarning is the "warning" AlertType for events
	EventAlertTypeWarning = "warning"
	// EventAlertTypeSuccess is the "success" AlertType for events
	EventAlertTypeSuccess = "success"
)
View Source
const (
	// EventPriorityNormal is the "normal" Priority for events.
	EventPriorityNormal = "normal"
	// EventPriorityLow is the "low" Priority for events.
	EventPriorityLow = "low"
)
View Source
const (
	MetricNameHTTPRequest        string = string(logger.HTTPRequest)
	MetricNameHTTPRequestElapsed string = MetricNameHTTPRequest + ".elapsed"
	MetricNameDBQuery            string = string(logger.Query)
	MetricNameDBQueryElapsed     string = MetricNameDBQuery + ".elapsed"

	MetricNameWarning string = string(logger.Warning)
	MetricNameError   string = string(logger.Error)
	MetricNameFatal   string = string(logger.Fatal)

	TagRoute  string = "route"
	TagMethod string = "method"
	TagStatus string = "status"

	TagQuery    string = "query"
	TagEngine   string = "engine"
	TagDatabase string = "database"

	TagError string = "error"
	TagClass string = "class"

	RouteNotFound string = "not_found"

	ListenerNameStats string = "stats"
)

MetricNames are names we use when sending data to the collectors.

Variables

This section is empty.

Functions

func AddErrorListeners

func AddErrorListeners(log *logger.Logger, stats Collector)

AddErrorListeners adds error listeners.

func AddQueryListeners

func AddQueryListeners(log *logger.Logger, stats Collector)

AddQueryListeners adds db listeners.

func AddWebListeners

func AddWebListeners(log *logger.Logger, stats Collector)

AddWebListeners adds web listeners.

func Runtime

func Runtime(log *logger.Logger, collector Collector)

Runtime reports golang vm runtime stats.

func Tag

func Tag(key, value string) string

Tag creates a new tag.

Types

type Collector

type Collector interface {
	AddDefaultTag(string, string)
	DefaultTags() []string
	Count(name string, value int64, tags ...string) error
	Increment(name string, tags ...string) error
	Gauge(name string, value float64, tags ...string) error
	Histogram(name string, value float64, tags ...string) error
}

Collector is a stats collector.

type Event

type Event struct {
	// Title of the event.  Required.
	Title string
	// Text is the description of the event.  Required.
	Text string
	// Timestamp is a timestamp for the event.  If not provided, the dogstatsd
	// server will set this to the current time.
	Timestamp time.Time
	// Hostname for the event.
	Hostname string
	// AggregationKey groups this event with others of the same key.
	AggregationKey string
	// Priority of the event.  Can be statsd.Low or statsd.Normal.
	Priority string
	// SourceTypeName is a source type for the event.
	SourceTypeName string
	// AlertType can be statsd.Info, statsd.Error, statsd.Warning, or statsd.Success.
	// If absent, the default value applied by the dogstatsd server is Info.
	AlertType string
	// Tags for the event.
	Tags []string
}

Event is an event to be collected.

func (Event) Check

func (e Event) Check() error

Check verifies that an event is valid.

type EventCollector

type EventCollector interface {
	AddDefaultTag(key, value string)
	DefaultTags() []string
	SendEvent(Event) error
	CreateEvent(title, text string, tags ...string) Event
}

EventCollector is a collector for events.

type MockCollector

type MockCollector struct {
	Events chan MockMetric
	// contains filtered or unexported fields
}

MockCollector is a mocked collector for stats.

func NewMockCollector

func NewMockCollector() *MockCollector

NewMockCollector returns a new mock collector.

func (MockCollector) AddDefaultTag

func (mc MockCollector) AddDefaultTag(key, value string)

AddDefaultTag adds a default tag.

func (*MockCollector) Count

func (mc *MockCollector) Count(name string, value int64, tags ...string) error

Count adds a mock count event to the event stream.

func (MockCollector) DefaultTags

func (mc MockCollector) DefaultTags() []string

DefaultTags returns the default tags set.

func (*MockCollector) Gauge

func (mc *MockCollector) Gauge(name string, value float64, tags ...string) error

Gauge adds a mock count event to the event stream with value (1).

func (*MockCollector) Histogram

func (mc *MockCollector) Histogram(name string, value float64, tags ...string) error

Histogram adds a mock count event to the event stream with value (1).

func (*MockCollector) Increment

func (mc *MockCollector) Increment(name string, tags ...string) error

Increment adds a mock count event to the event stream with value (1).

type MockEventCollector

type MockEventCollector struct {
	Events chan Event
	// contains filtered or unexported fields
}

MockEventCollector is a mocked collector for stats.

func NewMockEventCollector

func NewMockEventCollector() *MockEventCollector

NewMockEventCollector returns a new mock collector.

func (MockEventCollector) AddDefaultTag

func (mec MockEventCollector) AddDefaultTag(key, value string)

AddDefaultTag adds a default tag.

func (MockEventCollector) CreateEvent

func (mec MockEventCollector) CreateEvent(title, text string, tags ...string) Event

CreateEvent creates a mock event with the default tags.

func (MockEventCollector) DefaultTags

func (mec MockEventCollector) DefaultTags() []string

DefaultTags returns the default tags set.

func (MockEventCollector) SendEvent

func (mec MockEventCollector) SendEvent(e Event) error

SendEvent sends an event.

type MockMetric

type MockMetric struct {
	Name      string
	Count     int64
	Gauge     float64
	Histogram float64
	Tags      []string
}

MockMetric is a mock metric.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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