mirror of
https://github.com/grafana/grafana.git
synced 2024-12-30 10:47:30 -06:00
Plugins Instrumentation: add exemplar to the plugin requests metrics (#72071)
* Plugins Instrumentation: add exemplar to the plugin requests metrics
This commit is contained in:
parent
65d8ea9beb
commit
7ec3489cd3
@ -6,6 +6,7 @@
|
||||
- "host.docker.internal:host-gateway"
|
||||
command: >
|
||||
--enable-feature=remote-write-receiver
|
||||
--enable-feature=exemplar-storage
|
||||
--config.file=/etc/prometheus/prometheus.yml
|
||||
--storage.tsdb.path=/prometheus
|
||||
volumes:
|
||||
|
@ -76,10 +76,24 @@ func instrumentPluginRequest(ctx context.Context, cfg Cfg, pluginCtx *backend.Pl
|
||||
}
|
||||
|
||||
elapsed := time.Since(start)
|
||||
pluginRequestDuration.WithLabelValues(pluginCtx.PluginID, endpoint, string(cfg.Target)).Observe(float64(elapsed / time.Millisecond))
|
||||
pluginRequestCounter.WithLabelValues(pluginCtx.PluginID, endpoint, status, string(cfg.Target)).Inc()
|
||||
|
||||
PluginRequestDurationSeconds.WithLabelValues("grafana-backend", pluginCtx.PluginID, endpoint, status, string(cfg.Target)).Observe(elapsed.Seconds())
|
||||
pluginRequestDurationWithLabels := pluginRequestDuration.WithLabelValues(pluginCtx.PluginID, endpoint, string(cfg.Target))
|
||||
pluginRequestCounterWithLabels := pluginRequestCounter.WithLabelValues(pluginCtx.PluginID, endpoint, status, string(cfg.Target))
|
||||
pluginRequestDurationSecondsWithLabels := PluginRequestDurationSeconds.WithLabelValues("grafana-backend", pluginCtx.PluginID, endpoint, status, string(cfg.Target))
|
||||
|
||||
if traceID := tracing.TraceIDFromContext(ctx, true); traceID != "" {
|
||||
pluginRequestDurationWithLabels.(prometheus.ExemplarObserver).ObserveWithExemplar(
|
||||
float64(elapsed/time.Millisecond), prometheus.Labels{"traceID": traceID},
|
||||
)
|
||||
pluginRequestCounterWithLabels.(prometheus.ExemplarAdder).AddWithExemplar(1, prometheus.Labels{"traceID": traceID})
|
||||
pluginRequestDurationSecondsWithLabels.(prometheus.ExemplarObserver).ObserveWithExemplar(
|
||||
elapsed.Seconds(), prometheus.Labels{"traceID": traceID},
|
||||
)
|
||||
} else {
|
||||
pluginRequestDurationWithLabels.Observe(float64(elapsed / time.Millisecond))
|
||||
pluginRequestCounterWithLabels.Inc()
|
||||
pluginRequestDurationSecondsWithLabels.Observe(elapsed.Seconds())
|
||||
}
|
||||
|
||||
if cfg.LogDatasourceRequests {
|
||||
logParams := []interface{}{
|
||||
|
Loading…
Reference in New Issue
Block a user