diff --git a/prometheus.go b/prometheus.go index bb00201..0fd8bcc 100644 --- a/prometheus.go +++ b/prometheus.go @@ -15,7 +15,7 @@ import ( var ( MetricExporterPusher = func() error { return nil } MetricExporterHandler Handler = nil - metricRegistry *prometheus.Registry = nil + MetricRegistry *prometheus.Registry = nil metricApiCounter *prometheus.CounterVec = nil metricApiSummary *prometheus.SummaryVec = nil instance string = "--unknown--" @@ -68,9 +68,9 @@ func InitMetrics(instanceValue string) { []string{"api", "errcode", "appid"}, ) - metricRegistry = prometheus.NewRegistry() - metricRegistry.MustRegister(metricApiCounter) - metricRegistry.MustRegister(metricApiSummary) + MetricRegistry = prometheus.NewRegistry() + MetricRegistry.MustRegister(metricApiCounter) + MetricRegistry.MustRegister(metricApiSummary) } func SetupMetricsExporterHandler(apiname string) { @@ -78,10 +78,10 @@ func SetupMetricsExporterHandler(apiname string) { apiname = "premetheus_metrics_exporter" } - opt := promhttp.HandlerOpts{Registry: metricRegistry} + opt := promhttp.HandlerOpts{Registry: MetricRegistry} MetricExporterHandler = &metricExporterHandler{ 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. New(pushgateway, jobname). Grouping("instance", instance). - Gatherer(metricRegistry) + Gatherer(MetricRegistry) MetricExporterPusher = func() error { RecordMetrics("push_metrics_to_prometheus", "0", "selfmonitoring", 1.0)