Documentation
¶
Index ¶
- Constants
- Variables
- func GetTags(opts ...TagOption) []string
- func NewMangoStatsCounter(c Client, tags ...string) cache.StatsCounter
- func Register(m prometheus.Collector) prometheus.Collector
- func RegisterClientCtor(clientType string, ctr ClientCtor)
- type Client
- type ClientConfig
- type ClientCtor
- type ClientOption
- type Gauge
- type GaugeFunc
- type Meter
- type TagOption
- type Timer
- type TimerContext
Constants ¶
const DefaultGaugePollingInterval = 1 * time.Second
Variables ¶
var MinuteDistributionBuckets = append( []float64{ 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, }, prometheus.LinearBuckets(5.0, 5.0, 12)..., )
MinuteDistributionBuckets is a set of buckets that provide insight for both subsecond latency requests, as well as exceptionally long ones.
Functions ¶
func NewMangoStatsCounter ¶
func NewMangoStatsCounter(c Client, tags ...string) cache.StatsCounter
NewMangoStatsCounter provides an adapter for github.com/goburrow/cache.StatsCounter over this packages Client.
func Register ¶ added in v0.62.0
func Register(m prometheus.Collector) prometheus.Collector
Register regsiters the provided prometheus collector, or returns the previously registered metric if it exists.
func RegisterClientCtor ¶
func RegisterClientCtor(clientType string, ctr ClientCtor)
RegisterClientCtor registers a ClientCtor for the specified client type.
Types ¶
type Client ¶
type Client interface { // Count measures the count of a metric Count(name string, value int64, tags []string) error // Gauge measures a metric at a point in time Gauge(name string, value float64, tags []string) error // Timing measures the time of a metric. Timing(name string, value time.Duration, tags []string) error // Close closes the client and any underlying resources Close() error }
Client is used for exporting metrics
func CreateClient ¶
func CreateClient(clientType string, config *ClientConfig) (Client, error)
CreateClient creates a Client using the ClientCtor of the requested type, if one has been registered. If no constructor has been registered with the specified type, an error is thrown.
type ClientConfig ¶
type ClientCtor ¶
type ClientCtor func(config *ClientConfig) (Client, error)
A ClientCtor creates a metrics client using the provided config.
type ClientOption ¶
type ClientOption func(o *ClientConfig)
func WithGlobalTags ¶
func WithGlobalTags(tagOptions ...TagOption) ClientOption
WithGlobalTags configures the client to include a set of tags to all submitted metrics.
func WithNamespace ¶
func WithNamespace(namespace string) ClientOption
WithNamespace configures the client to use the provided namespace.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge measures a metric's value at a point in time
type GaugeFunc ¶
type GaugeFunc func() float64
GaugeFunc is used in a polling loop to get the metric's value. Processing here is expected to be fairly light weight since we use a single polling thread to process all gauges.
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Meter tracks a count of a metric
type TagOption ¶
type TagOption func() string
TagOption specifies a tag that should be added to a metric
func WithApp ¶
WithAppTAg adds an "app" tag to a metric. This is typically used to indicate which app a metric pertains to.
func WithServiceTag ¶
WithServiceTag adds a "service" tag to a metric. This is typically used to indicate which service a metric came from.
func WithTypeTag ¶
WithTypeTag adds a "type" tag to a metric. This is typically used to differentiate metrics from different implementations of an interface.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer tracks the time a metric
func (*Timer) Time ¶
func (t *Timer) Time(tags ...TagOption) *TimerContext
Time begins tracking a new datapoint. Use TimerContext.Stop on the returned context to record the time passed since calling Time
type TimerContext ¶
type TimerContext struct {
// contains filtered or unexported fields
}
TimerContext is the context for an in-flight datapoint
func (*TimerContext) Stop ¶
func (tc *TimerContext) Stop()
Stop records the time since the context's creation if it hasn't already been stopped