Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100}
DefBuckets are histogram buckets for the response time (in seconds) of a network service, including one that is responding very slowly.
var HistogramCollectorBuckets = []string{"operation", "status_code"}
HistogramCollectorBuckets define the buckets when passing the metric
Functions ¶
func CollectedRequest ¶
func CollectedRequest(ctx context.Context, method string, col Collector, toStatusCode func(error) string, f func(context.Context) error) error
CollectedRequest runs a tracked request. It uses the given Collector to monitor requests.
If `f` returns no error we log "200" as status code, otherwise "500". Pass in a function for `toStatusCode` to overwrite this behaviour. It will also emit an OpenTracing span if you have a global tracer configured.
func ObserveWithExemplar ¶
func ObserveWithExemplar(ctx context.Context, histogram prometheus.Observer, seconds float64)
ObserveWithExemplar adds a sample to a histogram, and adds an exemplar if the context has a sampled trace. 'histogram' parameter must be castable to prometheus.ExemplarObserver or function will panic (this will always work for a HistogramVec).
Types ¶
type Collector ¶
type Collector interface { Register() Before(ctx context.Context, method string, start time.Time) After(ctx context.Context, method, statusCode string, start time.Time) }
Collector describes something that collects data before and/or after a task.
type HistogramCollector ¶
type HistogramCollector struct {
// contains filtered or unexported fields
}
HistogramCollector collects the duration of a request
func NewHistogramCollector ¶
func NewHistogramCollector(metric *prometheus.HistogramVec) *HistogramCollector
NewHistogramCollector creates a Collector from a metric.
func NewHistogramCollectorFromOpts ¶
func NewHistogramCollectorFromOpts(opts prometheus.HistogramOpts) *HistogramCollector
NewHistogramCollectorFromOpts creates a Collector from histogram options. It makes sure that the buckets are named properly and should be preferred over NewHistogramCollector().
func (*HistogramCollector) Register ¶
func (c *HistogramCollector) Register()
Register registers metrics.
type JobCollector ¶
type JobCollector struct {
// contains filtered or unexported fields
}
JobCollector collects metrics for jobs. Designed for batch jobs which run on a regular, not-too-frequent, non-overlapping interval. We can afford to measure duration directly with gauges, and compute quantile with quantile_over_time.
func NewJobCollector ¶
func NewJobCollector(namespace string) *JobCollector
NewJobCollector instantiates JobCollector which creates its metrics.