Documentation
¶
Index ¶
- Constants
- func AddErrorListeners(log *logger.Logger, stats Collector)
- func AddQueryListeners(log *logger.Logger, stats Collector)
- func AddWebListeners(log *logger.Logger, stats Collector)
- func Runtime(log *logger.Logger, collector Collector)
- func Tag(key, value string) string
- type Collector
- type Event
- type EventCollector
- type MockCollector
- func (mc MockCollector) AddDefaultTag(key, value string)
- func (mc *MockCollector) Count(name string, value int64, tags ...string) error
- func (mc MockCollector) DefaultTags() []string
- func (mc *MockCollector) Gauge(name string, value float64, tags ...string) error
- func (mc *MockCollector) Histogram(name string, value float64, tags ...string) error
- func (mc *MockCollector) Increment(name string, tags ...string) error
- type MockEventCollector
- type MockMetric
Constants ¶
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" )
const ( // EventPriorityNormal is the "normal" Priority for events. EventPriorityNormal = "normal" // EventPriorityLow is the "low" Priority for events. EventPriorityLow = "low" )
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 ¶
AddErrorListeners adds error listeners.
func AddQueryListeners ¶
AddQueryListeners adds db listeners.
func AddWebListeners ¶
AddWebListeners adds web listeners.
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.
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).
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.