Skip to content

Commit

Permalink
include global labels in x/metrics metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed Aug 24, 2023
1 parent 9368851 commit 23d486f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions x/metrics/types/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ func TelemetryOptionsFromAppOpts(appOpts servertypes.AppOptions) TelemetryOption
GlobalLabelsAndValues: []string{},
}
}

// parse the app.toml global-labels into a slice of alternating label & value strings
// the value is expected to be a list of [label, value] tuples.
rawLabels := cast.ToSlice(appOpts.Get("telemetry.global-labels"))
globalLabelsAndValues := make([]string, 0, len(rawLabels)*2)
for _, gl := range rawLabels {
l := cast.ToStringSlice(gl)
globalLabelsAndValues = append(globalLabelsAndValues, l[0], l[1])
}

return TelemetryOptions{
PrometheusEnabled: true,
CometBFTMetricsNamespace: cast.ToString(appOpts.Get("instrumentation.namespace")),
GlobalLabelsAndValues: []string{
// TODO: can i get the chain id in this context?
},
GlobalLabelsAndValues: globalLabelsAndValues,
}
}

Expand Down

0 comments on commit 23d486f

Please sign in to comment.