github.com/mre-fog/trillianxx@v1.1.2-0.20180615153820-ae375a99d36a/monitoring/metrics.go (about) 1 // Copyright 2017 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package monitoring 16 17 // MetricFactory allows the creation of different types of metric. 18 type MetricFactory interface { 19 NewCounter(name, help string, labelNames ...string) Counter 20 NewGauge(name, help string, labelNames ...string) Gauge 21 NewHistogram(name, help string, labelNames ...string) Histogram 22 } 23 24 // Counter is a metric class for numeric values that increase. 25 type Counter interface { 26 Inc(labelVals ...string) 27 Add(val float64, labelVals ...string) 28 Value(labelVals ...string) float64 29 } 30 31 // Gauge is a metric class for numeric values that can go up and down. 32 type Gauge interface { 33 Inc(labelVals ...string) 34 Dec(labelVals ...string) 35 Add(val float64, labelVals ...string) 36 Set(val float64, labelVals ...string) 37 // Value retrieves the value for a particular set of labels. 38 // This is only really useful for testing implementations. 39 Value(labelVals ...string) float64 40 } 41 42 // Histogram is a metric class that tracks the distribution of a collection 43 // of observations. 44 type Histogram interface { 45 Observe(val float64, labelVals ...string) 46 // Info retrieves the count and sum of observations for a particular set of labels. 47 // This is only really useful for testing implementations. 48 Info(labelVals ...string) (uint64, float64) 49 }