@@ -142,7 +142,7 @@ func Inc(name string, val int64, labels ...metrics.Label) {
142
142
// metriks.IncLabels("publisher.errors", metriks.Labels(metriks.L("status_class", "4xx")), 1)
143
143
//
144
144
func IncLabels (name string , labels []metrics.Label , val int64 ) {
145
- metrics . IncrCounterWithLabels ([] string { name }, float32 ( val ) , labels )
145
+ Inc ( name , val , labels ... )
146
146
}
147
147
148
148
// MeasureSince records the time from start until the invocation of the function
@@ -157,13 +157,17 @@ func IncLabels(name string, labels []metrics.Label, val int64) {
157
157
// return db.Execute(query)
158
158
// }
159
159
//
160
- func MeasureSince (name string , start time.Time ) {
161
- metrics .MeasureSince ([]string {name }, start )
160
+ func MeasureSince (name string , start time.Time , labels ... metrics.Label ) {
161
+ if len (labels ) > 0 {
162
+ metrics .MeasureSinceWithLabels ([]string {name }, start , labels )
163
+ } else {
164
+ metrics .MeasureSince ([]string {name }, start )
165
+ }
162
166
}
163
167
164
168
// MeasureSinceLabels is the same as MeasureSince, but with additional labels
165
169
func MeasureSinceLabels (name string , labels []metrics.Label , start time.Time ) {
166
- metrics . MeasureSinceWithLabels ([] string { name } , start , labels )
170
+ MeasureSince ( name , start , labels ... )
167
171
}
168
172
169
173
// Sample records a float32 sample as part of a histogram. This will get histogram
@@ -173,25 +177,33 @@ func MeasureSinceLabels(name string, labels []metrics.Label, start time.Time) {
173
177
//
174
178
// metriks.Sample("publisher-payload-size", float32(len(payload)))
175
179
//
176
- func Sample (name string , val float32 ) {
177
- metrics .AddSample ([]string {name }, val )
180
+ func Sample (name string , val float32 , labels ... metrics.Label ) {
181
+ if len (labels ) > 0 {
182
+ metrics .AddSampleWithLabels ([]string {name }, val , labels )
183
+ } else {
184
+ metrics .AddSample ([]string {name }, val )
185
+ }
178
186
}
179
187
180
188
// SampleLabels is the same as Sample but with additional labels
181
189
func SampleLabels (name string , labels []metrics.Label , val float32 ) {
182
- metrics . AddSampleWithLabels ([] string { name } , val , labels )
190
+ Sample ( name , val , labels ... )
183
191
}
184
192
185
193
// Gauge is used to report a single float32 value. It is most often used during a
186
194
// periodic update or timer to report the current size of a queue or how many
187
195
// connections are currently connected.
188
- func Gauge (name string , val float32 ) {
189
- metrics .SetGauge ([]string {name }, val )
196
+ func Gauge (name string , val float32 , labels ... metrics.Label ) {
197
+ if len (labels ) > 0 {
198
+ metrics .SetGaugeWithLabels ([]string {name }, val , labels )
199
+ } else {
200
+ metrics .SetGauge ([]string {name }, val )
201
+ }
190
202
}
191
203
192
204
// GaugeLabels is the same as Gauge but with additional labels
193
205
func GaugeLabels (name string , labels []metrics.Label , val float32 ) {
194
- metrics . SetGaugeWithLabels ([] string { name } , val , labels )
206
+ Gauge ( name , val , labels ... )
195
207
}
196
208
197
209
func statsdAddr (conf Config ) string {
0 commit comments