diff --git a/pkg/cmd/grafana-server/server.go b/pkg/cmd/grafana-server/server.go index b2952df9185..3119574f7da 100644 --- a/pkg/cmd/grafana-server/server.go +++ b/pkg/cmd/grafana-server/server.go @@ -54,8 +54,7 @@ func (g *GrafanaServerImpl) Start() { g.writePIDFile() initSql() - metricsCfg := metrics.ReadSettings(setting.Cfg) - metrics.Init(metricsCfg) + metrics.Init(setting.Cfg) search.Init() login.Init() social.NewOAuthService() diff --git a/pkg/metrics/graphitebridge/graphite.go b/pkg/metrics/graphitebridge/graphite.go index e23b7ebe538..b9c766a03e1 100644 --- a/pkg/metrics/graphitebridge/graphite.go +++ b/pkg/metrics/graphitebridge/graphite.go @@ -360,12 +360,6 @@ func (b *Bridge) replaceCounterWithDelta(mf *dto.MetricFamily, metric model.Metr } return float64(value) - - //println("use delta for", metric[model.MetricNameLabel], mf.GetType().String()) - - //TODO(bergquist): turn _count in summery into delta - //TODO(bergquist): turn _count in histogram into delta - } func (b *Bridge) returnDelta(metric model.Metric, value model.SampleValue) float64 { diff --git a/pkg/metrics/publish.go b/pkg/metrics/init.go similarity index 81% rename from pkg/metrics/publish.go rename to pkg/metrics/init.go index ebbeb2962d6..833b148d319 100644 --- a/pkg/metrics/publish.go +++ b/pkg/metrics/init.go @@ -3,12 +3,13 @@ package metrics import ( "context" + ini "gopkg.in/ini.v1" + "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/metrics/graphitebridge" ) var metricsLogger log.Logger = log.New("metrics") -var metricPublishCounter int64 = 0 type logWrapper struct { logger log.Logger @@ -18,7 +19,12 @@ func (lw *logWrapper) Println(v ...interface{}) { lw.logger.Info("graphite metric bridge", v...) } -func Init(settings *MetricSettings) { +func Init(file *ini.File) { + cfg := ReadSettings(file) + internalInit(cfg) +} + +func internalInit(settings *MetricSettings) { initMetricVars(settings) if settings.GraphiteBridgeConfig != nil {