Plugins: Record plugin version in request metrics (#110210)
Plugins: record plugin version in request metrics
This commit is contained in:
@@ -35,27 +35,27 @@ func newMetricsMiddleware(promRegisterer prometheus.Registerer, pluginRegistry r
|
||||
Namespace: "grafana",
|
||||
Name: "plugin_request_total",
|
||||
Help: "The total amount of plugin requests",
|
||||
}, append([]string{"plugin_id", "endpoint", "status", "target"}, additionalLabels...))
|
||||
}, append([]string{"plugin_id", "endpoint", "status", "target", "plugin_version"}, additionalLabels...))
|
||||
pluginRequestDuration := prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: "grafana",
|
||||
Name: "plugin_request_duration_milliseconds",
|
||||
Help: "Plugin request duration",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
||||
}, append([]string{"plugin_id", "endpoint", "target"}, additionalLabels...))
|
||||
}, append([]string{"plugin_id", "endpoint", "target", "plugin_version"}, additionalLabels...))
|
||||
pluginRequestSize := prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: "grafana",
|
||||
Name: "plugin_request_size_bytes",
|
||||
Help: "histogram of plugin request sizes returned",
|
||||
Buckets: []float64{128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576},
|
||||
}, []string{"source", "plugin_id", "endpoint", "target"},
|
||||
}, []string{"source", "plugin_id", "endpoint", "target", "plugin_version"},
|
||||
)
|
||||
pluginRequestDurationSeconds := prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: "grafana",
|
||||
Name: "plugin_request_duration_seconds",
|
||||
Help: "Plugin request duration in seconds",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25},
|
||||
}, append([]string{"source", "plugin_id", "endpoint", "status", "target"}, additionalLabels...))
|
||||
}, append([]string{"source", "plugin_id", "endpoint", "status", "target", "plugin_version"}, additionalLabels...))
|
||||
promRegisterer.MustRegister(
|
||||
pluginRequestCounter,
|
||||
pluginRequestDuration,
|
||||
@@ -101,7 +101,7 @@ func (m *MetricsMiddleware) instrumentPluginRequestSize(ctx context.Context, plu
|
||||
return err
|
||||
}
|
||||
endpoint := backend.EndpointFromContext(ctx)
|
||||
m.pluginRequestSize.WithLabelValues("grafana-backend", pluginCtx.PluginID, string(endpoint), target).Observe(requestSize)
|
||||
m.pluginRequestSize.WithLabelValues("grafana-backend", pluginCtx.PluginID, string(endpoint), target, pluginCtx.PluginVersion).Observe(requestSize)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ func (m *MetricsMiddleware) instrumentPluginRequest(ctx context.Context, pluginC
|
||||
statusSource := backend.ErrorSourceFromContext(ctx)
|
||||
endpoint := backend.EndpointFromContext(ctx)
|
||||
|
||||
pluginRequestDurationWithLabels := m.pluginRequestDuration.WithLabelValues(pluginCtx.PluginID, string(endpoint), target, string(statusSource))
|
||||
pluginRequestCounterWithLabels := m.pluginRequestCounter.WithLabelValues(pluginCtx.PluginID, string(endpoint), status.String(), target, string(statusSource))
|
||||
pluginRequestDurationSecondsWithLabels := m.pluginRequestDurationSeconds.WithLabelValues("grafana-backend", pluginCtx.PluginID, string(endpoint), status.String(), target, string(statusSource))
|
||||
pluginRequestDurationWithLabels := m.pluginRequestDuration.WithLabelValues(pluginCtx.PluginID, string(endpoint), target, pluginCtx.PluginVersion, string(statusSource))
|
||||
pluginRequestCounterWithLabels := m.pluginRequestCounter.WithLabelValues(pluginCtx.PluginID, string(endpoint), status.String(), target, pluginCtx.PluginVersion, string(statusSource))
|
||||
pluginRequestDurationSecondsWithLabels := m.pluginRequestDurationSeconds.WithLabelValues("grafana-backend", pluginCtx.PluginID, string(endpoint), status.String(), target, pluginCtx.PluginVersion, string(statusSource))
|
||||
|
||||
if traceID := tracing.TraceIDFromContext(ctx, true); traceID != "" {
|
||||
pluginRequestDurationWithLabels.(prometheus.ExemplarObserver).ObserveWithExemplar(
|
||||
|
||||
Reference in New Issue
Block a user