-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
102 lines (77 loc) · 4.26 KB
/
metrics.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Copyright 2016 Ville Koskela
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package gometricsclient
import (
"time"
)
// Interface for logging metrics: timers, counters and gauges. Clients should
// create one instance of an implementing class for each unit of work. At the
// end of the unit of work the client should invoke close() on that instance.
// After the close() method is invoked the Metrics instance cannot be used to
// record further metrics and should be discarded.
type Metrics interface {
// Create and initialize a counter sample. It is valid to create multiple Counter instances with the same name, even
// concurrently, each will record a unique sample for the counter of the specified name.
CreateCounter(string) Counter
// Increment the specified counter by 1. All counters are initialized to zero. Creates a sample if one does not
// exist. To create a new sample invoke resetCounter.
IncrementCounter(string)
// Increment the specified counter by the specified amount. All counters are initialized to zero. Creates a sample
// if one does not exist. To create a new sample invoke resetCounter.
IncrementCounterByValue(string, int64)
// Decrement the specified counter by 1. All counters are initialized to zero. Creates a sample if one does not
// exist. To create a new sample invoke resetCounter.
DecrementCounter(string)
// Decrement the specified counter by the specified amount. All counters are initialized to zero. Creates a sample
// if one does not exist. To create a new sample invoke resetCounter.
DecrementCounterByValue(string, int64)
// Create a new sample for the counter with value zero. This most commonly used to record a zero-count for a
// particular counter. If clients wish to record set count metrics then all counters should be reset before
// conditionally invoking increment and/or decrement.
ResetCounter(string)
// Create and start a timer. It is valid to create multiple Timer instances with the same name, even concurrently,
// each will record a unique sample for the timer of the specified name.
CreateTimer(string) Timer
// Start measurement of a sample for the specified timer. Use createTimer to make multiple concurrent measurements
// for the same timer.
StartTimer(string)
// Stop measurement of the current sample for the specified timer. Use createTimer to make multiple concurrent