export metricRegistry
This commit is contained in:
parent
93bdc425e5
commit
9df516247c
@ -15,7 +15,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
MetricExporterPusher = func() error { return nil }
|
MetricExporterPusher = func() error { return nil }
|
||||||
MetricExporterHandler Handler = nil
|
MetricExporterHandler Handler = nil
|
||||||
metricRegistry *prometheus.Registry = nil
|
MetricRegistry *prometheus.Registry = nil
|
||||||
metricApiCounter *prometheus.CounterVec = nil
|
metricApiCounter *prometheus.CounterVec = nil
|
||||||
metricApiSummary *prometheus.SummaryVec = nil
|
metricApiSummary *prometheus.SummaryVec = nil
|
||||||
instance string = "--unknown--"
|
instance string = "--unknown--"
|
||||||
@ -68,9 +68,9 @@ func InitMetrics(instanceValue string) {
|
|||||||
[]string{"api", "errcode", "appid"},
|
[]string{"api", "errcode", "appid"},
|
||||||
)
|
)
|
||||||
|
|
||||||
metricRegistry = prometheus.NewRegistry()
|
MetricRegistry = prometheus.NewRegistry()
|
||||||
metricRegistry.MustRegister(metricApiCounter)
|
MetricRegistry.MustRegister(metricApiCounter)
|
||||||
metricRegistry.MustRegister(metricApiSummary)
|
MetricRegistry.MustRegister(metricApiSummary)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupMetricsExporterHandler(apiname string) {
|
func SetupMetricsExporterHandler(apiname string) {
|
||||||
@ -78,10 +78,10 @@ func SetupMetricsExporterHandler(apiname string) {
|
|||||||
apiname = "premetheus_metrics_exporter"
|
apiname = "premetheus_metrics_exporter"
|
||||||
}
|
}
|
||||||
|
|
||||||
opt := promhttp.HandlerOpts{Registry: metricRegistry}
|
opt := promhttp.HandlerOpts{Registry: MetricRegistry}
|
||||||
MetricExporterHandler = &metricExporterHandler{
|
MetricExporterHandler = &metricExporterHandler{
|
||||||
name: apiname,
|
name: apiname,
|
||||||
promhttpHandler: promhttp.HandlerFor(metricRegistry, opt),
|
promhttpHandler: promhttp.HandlerFor(MetricRegistry, opt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ func SetupMetricsExporterPusher(pushgateway string, jobname string) {
|
|||||||
var pusher = push.
|
var pusher = push.
|
||||||
New(pushgateway, jobname).
|
New(pushgateway, jobname).
|
||||||
Grouping("instance", instance).
|
Grouping("instance", instance).
|
||||||
Gatherer(metricRegistry)
|
Gatherer(MetricRegistry)
|
||||||
|
|
||||||
MetricExporterPusher = func() error {
|
MetricExporterPusher = func() error {
|
||||||
RecordMetrics("push_metrics_to_prometheus", "0", "selfmonitoring", 1.0)
|
RecordMetrics("push_metrics_to_prometheus", "0", "selfmonitoring", 1.0)
|
||||||
|
Loading…
Reference in New Issue
Block a user