Skip to content

Commit 7cbaf06

Browse files
committed
feat(instrumentation): check if enabled in http api metrics route
1 parent 1059a35 commit 7cbaf06

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/api/metrics.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/grafana/grafana/pkg/api/dtos"
1010
"github.com/grafana/grafana/pkg/metrics"
1111
"github.com/grafana/grafana/pkg/middleware"
12+
"github.com/grafana/grafana/pkg/util"
1213
)
1314

1415
func GetTestMetrics(c *middleware.Context) {
@@ -40,6 +41,10 @@ func GetTestMetrics(c *middleware.Context) {
4041
}
4142

4243
func GetInternalMetrics(c *middleware.Context) Response {
44+
if metrics.UseNilMetrics {
45+
return Json(200, util.DynMap{"message": "Metrics disabled"})
46+
}
47+
4348
snapshots := metrics.MetricStats.GetSnapshots()
4449

4550
resp := make(map[string]interface{})

pkg/metrics/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func readSettings() *MetricSettings {
3838
if graphitePublisher, err := CreateGraphitePublisher(); err != nil {
3939
log.Error(3, "Metrics: Failed to init Graphite metric publisher", err)
4040
} else if graphitePublisher != nil {
41-
log.Info("Metrics: Internal metrics publisher Graphite initialized")
41+
log.Info("Metrics: Graphite publisher initialized")
4242
settings.Publishers = append(settings.Publishers, graphitePublisher)
4343
}
4444

0 commit comments

Comments
 (0)