2013-04-03 20:33:32 +04:00
// Copyright (c) 2013, Prometheus Team
2013-02-12 05:36:06 +04:00
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
//
2013-01-18 18:47:40 +04:00
2013-04-03 20:33:32 +04:00
package prometheus
2013-01-18 18:47:40 +04:00
import (
"time"
)
2013-02-12 05:36:06 +04:00
// Boilerplate metrics about the metrics reporting subservice. These are only
// exposed if the DefaultRegistry's exporter is hooked into the HTTP request
// handler.
2013-01-18 18:47:40 +04:00
var (
2013-04-03 20:33:32 +04:00
marshalErrorCount = NewCounter ( )
dumpErrorCount = NewCounter ( )
2013-01-19 17:48:30 +04:00
2013-04-03 20:33:32 +04:00
requestCount = NewCounter ( )
requestLatencyBuckets = LogarithmicSizedBucketsFor ( 0 , 1000 )
requestLatency = NewHistogram ( & HistogramSpecification {
2013-01-19 17:48:30 +04:00
Starts : requestLatencyBuckets ,
2013-04-03 20:33:32 +04:00
BucketBuilder : AccumulatingBucketBuilder ( EvictAndReplaceWith ( 50 , AverageReducer ) , 1000 ) ,
2013-01-18 18:47:40 +04:00
ReportablePercentiles : [ ] float64 { 0.01 , 0.05 , 0.5 , 0.9 , 0.99 } ,
} )
2013-04-03 20:33:32 +04:00
startTime = NewGauge ( )
2013-01-18 18:47:40 +04:00
)
func init ( ) {
2013-01-19 17:48:30 +04:00
startTime . Set ( nil , float64 ( time . Now ( ) . Unix ( ) ) )
2013-01-18 18:47:40 +04:00
2013-01-19 17:48:30 +04:00
DefaultRegistry . Register ( "telemetry_requests_metrics_total" , "A counter of the total requests made against the telemetry system." , NilLabels , requestCount )
DefaultRegistry . Register ( "telemetry_requests_metrics_latency_microseconds" , "A histogram of the response latency for requests made against the telemetry system." , NilLabels , requestLatency )
2013-01-18 18:47:40 +04:00
DefaultRegistry . Register ( "instance_start_time_seconds" , "The time at which the current instance started (UTC)." , NilLabels , startTime )
}
2013-02-12 05:36:06 +04:00
// This callback accumulates the microsecond duration of the reporting
// framework's overhead such that it can be reported.
2013-04-03 20:33:32 +04:00
var requestLatencyAccumulator CompletionCallback = func ( duration time . Duration ) {
2013-02-12 05:36:06 +04:00
microseconds := float64 ( duration / time . Microsecond )
requestLatency . Add ( nil , microseconds )
}