Documentation ¶
Index ¶
- func GetStatusString(status bool) string
- func InitNopMetricsCollector() error
- func InitPrometheusMetricsCollector(gaugeMap map[MetricName]PrometheusGaugeVec, ...) error
- func SetGlobMetricsCollector(c Collector)
- type Collector
- type MetricName
- type NopMetricsCollector
- func (c NopMetricsCollector) Inc(key MetricName, labels map[string]string) error
- func (NopMetricsCollector) MeasureDurationMs(MetricName, map[string]func() string) func()
- func (NopMetricsCollector) MeasureDurationMsSince(MetricName, time.Time, map[string]string) error
- func (NopMetricsCollector) RecordGauge(MetricName, float64, map[string]string) error
- type PrometheusClient
- func (p PrometheusClient) Inc(key MetricName, labels map[string]string) error
- func (p PrometheusClient) MeasureDurationMs(key MetricName, labelValueGetters map[string]func() string) func()
- func (p PrometheusClient) MeasureDurationMsSince(key MetricName, starttime time.Time, labels map[string]string) error
- func (p PrometheusClient) RecordGauge(key MetricName, value float64, labels map[string]string) error
- func (p PrometheusClient) RegisterMetrics(gaugeMap map[MetricName]PrometheusGaugeVec, ...) error
- type PrometheusCounterVec
- type PrometheusGaugeVec
- type PrometheusHistogramVec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStatusString ¶
GetStatusString returns a classification string (success / failure) based on the input boolean
func InitNopMetricsCollector ¶
func InitNopMetricsCollector() error
func InitPrometheusMetricsCollector ¶
func InitPrometheusMetricsCollector( gaugeMap map[MetricName]PrometheusGaugeVec, histogramMap map[MetricName]PrometheusHistogramVec, counterMap map[MetricName]PrometheusCounterVec, ) error
InitPrometheusMetricsCollector initializes the collectors for all metrics defined for the app and registers them with the DefaultRegisterer.
func SetGlobMetricsCollector ¶
func SetGlobMetricsCollector(c Collector)
SetGlobMetricsCollector is used to update the global metrics collector instance with the input
Types ¶
type Collector ¶
type Collector interface { MeasureDurationMsSince(key MetricName, starttime time.Time, labels map[string]string) error // MeasureDurationMs is a deferrable version of MeasureDurationMsSince which evaluates labels // at the time of logging MeasureDurationMs(key MetricName, labels map[string]func() string) func() RecordGauge(key MetricName, value float64, labels map[string]string) error Inc(key MetricName, labels map[string]string) error }
Collector defines the common interface for all metrics collection engines
type MetricName ¶
type MetricName string
MetricName is a type used to define the names of the various metrics collected in the App.
type NopMetricsCollector ¶
type NopMetricsCollector struct { }
NopMetricsCollector implements the Collector interface with a set of Nop methods
func (NopMetricsCollector) Inc ¶
func (c NopMetricsCollector) Inc(key MetricName, labels map[string]string) error
Inc satisfies the Collector interface
func (NopMetricsCollector) MeasureDurationMs ¶
func (NopMetricsCollector) MeasureDurationMs(MetricName, map[string]func() string) func()
MeasureDurationMs satisfies the Collector interface
func (NopMetricsCollector) MeasureDurationMsSince ¶
func (NopMetricsCollector) MeasureDurationMsSince(MetricName, time.Time, map[string]string) error
MeasureDurationMsSince satisfies the Collector interface
func (NopMetricsCollector) RecordGauge ¶
func (NopMetricsCollector) RecordGauge(MetricName, float64, map[string]string) error
RecordGauge satisfies the Collector interface
type PrometheusClient ¶
type PrometheusClient struct {
// contains filtered or unexported fields
}
PrometheusClient satisfies the Collector interface
func (PrometheusClient) Inc ¶
func (p PrometheusClient) Inc(key MetricName, labels map[string]string) error
func (PrometheusClient) MeasureDurationMs ¶
func (p PrometheusClient) MeasureDurationMs( key MetricName, labelValueGetters map[string]func() string, ) func()
MeasureDurationMs takes in the Metric name and a map of labels and functions to obtain the label values - this allows for MeasureDurationMs to be deferred and do a delayed evaluation of the labels. It returns a function which, when executed, will log the duration in ms since MeasureDurationMs was called. If errors occur in accessing the metric or associating the labels, they will simply be logged.
func (PrometheusClient) MeasureDurationMsSince ¶
func (p PrometheusClient) MeasureDurationMsSince( key MetricName, starttime time.Time, labels map[string]string, ) error
MeasureDurationMsSince takes in the Metric name, the start time and a map of labels and values to be associated to the metric. Error will be thrown if errors occur in accessing the metric or associating the labels.
func (PrometheusClient) RecordGauge ¶
func (p PrometheusClient) RecordGauge( key MetricName, value float64, labels map[string]string, ) error
RecordGauge takes in the Metric name, the count and a map of labels and values to be associated to the metric. Error will be thrown if errors occur in accessing the metric or associating the labels.
func (PrometheusClient) RegisterMetrics ¶
func (p PrometheusClient) RegisterMetrics( gaugeMap map[MetricName]PrometheusGaugeVec, histogramMap map[MetricName]PrometheusHistogramVec, counterMap map[MetricName]PrometheusCounterVec, ) error
type PrometheusCounterVec ¶
type PrometheusCounterVec interface { GetMetricWith(prometheus.Labels) (prometheus.Counter, error) prometheus.Collector }
PrometheusCounterVec is an interface that captures the methods from the Prometheus CounterVec type that are used in the app. This is added for unit testing.
type PrometheusGaugeVec ¶
type PrometheusGaugeVec interface { GetMetricWith(prometheus.Labels) (prometheus.Gauge, error) prometheus.Collector }
PrometheusGaugeVec is an interface that captures the methods from the Prometheus GaugeVec type that are used in the app. This is added for unit testing.
type PrometheusHistogramVec ¶
type PrometheusHistogramVec interface { GetMetricWith(prometheus.Labels) (prometheus.Observer, error) prometheus.Collector }
PrometheusHistogramVec is an interface that captures the methods from the the Prometheus HistogramVec type that are used in the app. This is added for unit testing.