This repository has been archived by the owner on May 24, 2022. It is now read-only.
/
interface.go
75 lines (61 loc) · 2.22 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package metrics
import (
"github.com/facebookincubator/contest/pkg/xcontext/fields"
)
type Fields = fields.Fields
// Metrics is a handler of metrics (like Prometheus, ODS)
type Metrics interface {
// Gauge returns the float64 gauge metric with key "key".
Gauge(key string) Gauge
// IntGauge returns the int64 gauge metric with key "key".
IntGauge(key string) IntGauge
// Count returns the counter metric with key "key".
Count(key string) Count
// WithTag returns scoped Metrics with an added tag to be reported with the metrics.
//
// In terms of Prometheus the "tags" are called "labels".
WithTag(key string, value interface{}) Metrics
// WithTags returns scoped Metrics with added tags to be reported with the metrics.
//
// In terms of Prometheus the "tags" are called "labels".
//
// Value "nil" resets tags.
WithTags(fields Fields) Metrics
}
// Gauge is a float64 gauge metric.
//
// See also https://prometheus.io/docs/concepts/metric_types/
type Gauge interface {
// Add adds value "v" to the metric and returns the result.
Add(v float64) float64
// WithOverriddenTags returns scoped Gauge with replaced tags to be reported with the metrics.
//
// In terms of Prometheus the "tags" are called "labels".
WithOverriddenTags(fields.Fields) Gauge
}
// IntGauge is a int64 gauge metric.
//
// See also https://prometheus.io/docs/concepts/metric_types/
type IntGauge interface {
// Add adds value "v" to the metric and returns the result.
Add(v int64) int64
// WithOverriddenTags returns scoped IntGauge with replaced tags to be reported with the metrics.
//
// In terms of Prometheus the "tags" are called "labels".
WithOverriddenTags(Fields) IntGauge
}
// Count is a counter metric.
//
// See also https://prometheus.io/docs/concepts/metric_types/
type Count interface {
// Add adds value "v" to the metric and returns the result.
Add(v uint64) uint64
// WithOverriddenTags returns scoped Count with replaced tags to be reported with the metrics.
//
// In terms of Prometheus the "tags" are called "labels".
WithOverriddenTags(Fields) Count
}