Documentation ¶
Index ¶
- func ReportConnError(mc MetricsClientInterface, err error)
- type MetricsClientInterface
- type MockMetricsClient
- func (m *MockMetricsClient) Gauge(metric string, value float64, rate float64) error
- func (m *MockMetricsClient) GetCount(metric string, tags map[string]string) (uint64, error)
- func (m *MockMetricsClient) GetValues(metric string, tags map[string]string) ([]float64, error)
- func (m *MockMetricsClient) Histogram(metric string, value float64, rate float64) error
- func (m *MockMetricsClient) HistogramWithTags(metric string, value float64, tags map[string]string, rate float64) error
- func (m *MockMetricsClient) Incr(metric string, rate float64) error
- func (m *MockMetricsClient) IncrWithTags(metric string, tags map[string]string, rate float64) error
- func (m *MockMetricsClient) Timing(metric string, d time.Duration, rate float64) error
- func (m *MockMetricsClient) TimingWithTags(metric string, d time.Duration, tags map[string]string, rate float64) error
- type PrometheusMetricsClient
- func (mc *PrometheusMetricsClient) AddMetricTags(metric string, additionalTags map[string]string) error
- func (mc *PrometheusMetricsClient) Gauge(metric string, value float64, _ float64) error
- func (mc *PrometheusMetricsClient) GetMetricTags(metric string) map[string]string
- func (mc *PrometheusMetricsClient) Histogram(metric string, value float64, rate float64) error
- func (mc *PrometheusMetricsClient) HistogramWithTags(metric string, value float64, additionalTags map[string]string, _ float64) error
- func (mc *PrometheusMetricsClient) Incr(metric string, rate float64) error
- func (mc *PrometheusMetricsClient) IncrWithTags(metric string, additionalTags map[string]string, _ float64) error
- func (mc *PrometheusMetricsClient) SetStarted()
- func (mc *PrometheusMetricsClient) Timing(metric string, duration time.Duration, rate float64) error
- func (mc *PrometheusMetricsClient) TimingWithTags(metric string, d time.Duration, additionalTags map[string]string, _ float64) error
- type StatsdMetricsClient
- func (mc *StatsdMetricsClient) AddMetricTags(metric string, additionalTags map[string]string) error
- func (mc *StatsdMetricsClient) Gauge(metric string, value float64, rate float64) error
- func (mc *StatsdMetricsClient) GetMetricTags(metric string) []string
- func (mc *StatsdMetricsClient) Histogram(metric string, value float64, rate float64) error
- func (mc *StatsdMetricsClient) HistogramWithTags(metric string, value float64, additionalTags map[string]string, rate float64) error
- func (mc *StatsdMetricsClient) Incr(metric string, rate float64) error
- func (mc *StatsdMetricsClient) IncrWithTags(metric string, additionalTags map[string]string, rate float64) error
- func (mc *StatsdMetricsClient) SetStarted()
- func (mc *StatsdMetricsClient) StatsdClient() statsd.ClientInterface
- func (mc *StatsdMetricsClient) Timing(metric string, d time.Duration, rate float64) error
- func (mc *StatsdMetricsClient) TimingWithTags(metric string, d time.Duration, additionalTags map[string]string, rate float64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportConnError ¶
func ReportConnError(mc MetricsClientInterface, err error)
reportConnError emits a detailed metric about a connection error, with a tag corresponding to the failure type. If err is not a net.Error, does nothing.
Types ¶
type MetricsClientInterface ¶
type MetricsClientInterface interface { AddMetricTags(string, map[string]string) error Incr(string, float64) error IncrWithTags(string, map[string]string, float64) error Gauge(string, float64, float64) error Histogram(string, float64, float64) error HistogramWithTags(string, float64, map[string]string, float64) error Timing(string, time.Duration, float64) error TimingWithTags(string, time.Duration, map[string]string, float64) error SetStarted() }
type MockMetricsClient ¶
type MockMetricsClient struct { MetricsClientInterface // contains filtered or unexported fields }
MockMetricsClient is a MetricsClient that counts metric updates.
func NewMockMetricsClient ¶
func NewMockMetricsClient() *MockMetricsClient
NewMockMetricsClient returns a new MockMetricsClient that wraps a NoOpMetricsClient with counters to track metric updates.
func (*MockMetricsClient) Gauge ¶
func (m *MockMetricsClient) Gauge(metric string, value float64, rate float64) error
func (*MockMetricsClient) GetCount ¶
GetCount returns the number of times metric has been updated since the MockMetricsClient was created. To support GetCount being called with or without tags for a given metric, tagged metrics are counted twice: once for the untagged metric ("foo") and once for the metric with its tags sorted("foo [a b c]").
func (*MockMetricsClient) GetValues ¶
GetValues returns the values stored for a metric metric has been updated since the MockMetricsClient was created. To support GetValues being called with or without tags for a given metric, the values for tagged metrics are recorded twice: once for the untagged metric ("foo") and once for the metric with its tags sorted("foo [a b c]").
func (*MockMetricsClient) Histogram ¶
func (m *MockMetricsClient) Histogram(metric string, value float64, rate float64) error
func (*MockMetricsClient) HistogramWithTags ¶
func (*MockMetricsClient) Incr ¶
func (m *MockMetricsClient) Incr(metric string, rate float64) error
func (*MockMetricsClient) IncrWithTags ¶
func (*MockMetricsClient) TimingWithTags ¶
type PrometheusMetricsClient ¶
type PrometheusMetricsClient struct {
// contains filtered or unexported fields
}
PrometheusMetricsClient attempts to replicate the functionality of the StatsdMetricsClient, but exposing the metrics via a http endpoint
func NewPrometheusMetricsClient ¶
func NewPrometheusMetricsClient(endpoint string, port string) (*PrometheusMetricsClient, error)
func (*PrometheusMetricsClient) AddMetricTags ¶
func (mc *PrometheusMetricsClient) AddMetricTags( metric string, additionalTags map[string]string) error
func (*PrometheusMetricsClient) Gauge ¶
func (mc *PrometheusMetricsClient) Gauge( metric string, value float64, _ float64) error
func (*PrometheusMetricsClient) GetMetricTags ¶
func (mc *PrometheusMetricsClient) GetMetricTags(metric string) map[string]string
func (*PrometheusMetricsClient) Histogram ¶
func (mc *PrometheusMetricsClient) Histogram( metric string, value float64, rate float64) error
func (*PrometheusMetricsClient) HistogramWithTags ¶
func (*PrometheusMetricsClient) Incr ¶
func (mc *PrometheusMetricsClient) Incr( metric string, rate float64) error
func (*PrometheusMetricsClient) IncrWithTags ¶
func (*PrometheusMetricsClient) SetStarted ¶
func (mc *PrometheusMetricsClient) SetStarted()
func (*PrometheusMetricsClient) TimingWithTags ¶
type StatsdMetricsClient ¶
type StatsdMetricsClient struct {
// contains filtered or unexported fields
}
StatsdMetricsClient is a thin wrapper around statsd.ClientInterface. It is used to allow adding arbitrary tags to Smokescreen metrics.
StatsdMetricsClient is not thread safe and should not be used concurrently.
func NewNoOpMetricsClient ¶
func NewNoOpMetricsClient() *StatsdMetricsClient
NewNoOpMetricsClient returns a StatsdMetricsClient with a no-op statsd client. This can be used when there's no statsd service available to smokescreen.
func NewStatsdMetricsClient ¶
func NewStatsdMetricsClient(addr, namespace string) (*StatsdMetricsClient, error)
NewMetricsClient creates a new StatsdMetricsClient with the provided statsd address and namespace.
func (*StatsdMetricsClient) AddMetricTags ¶
func (mc *StatsdMetricsClient) AddMetricTags( metric string, additionalTags map[string]string) error
AddMetricTags associates the provided tags slice with a given metric. The metric must be present in the metrics slice.
Once a metric has tags added via AddMetricTags, those tags will *always* be attached whenever that metric is emitted. For example, calling `AddMetricTags(foo, [bar])` will cause the `bar` tag to be added to *every* metric `foo` that is emitted for the lifetime of the StatsdMetricsClient.
This function is not thread safe, and adding persistent tags should only be done while initializing the configuration and prior to running smokescreen.
func (*StatsdMetricsClient) Gauge ¶
func (mc *StatsdMetricsClient) Gauge( metric string, value float64, rate float64) error
func (*StatsdMetricsClient) GetMetricTags ¶
func (mc *StatsdMetricsClient) GetMetricTags(metric string) []string
GetMetricTags returns the slice of metrics associated with a given metric.
func (*StatsdMetricsClient) Histogram ¶
func (mc *StatsdMetricsClient) Histogram( metric string, value float64, rate float64) error
func (*StatsdMetricsClient) HistogramWithTags ¶
func (*StatsdMetricsClient) Incr ¶
func (mc *StatsdMetricsClient) Incr(metric string, rate float64) error
func (*StatsdMetricsClient) IncrWithTags ¶
func (*StatsdMetricsClient) SetStarted ¶
func (mc *StatsdMetricsClient) SetStarted()
func (*StatsdMetricsClient) StatsdClient ¶
func (mc *StatsdMetricsClient) StatsdClient() statsd.ClientInterface