Prometheus: (Chore/Instrumentation) add trace spans for result proces… (#67858)

Prometheus: (Chore/Instrumentation) add trace spans for result processing
This commit is contained in:
Kyle Brandt 2023-05-05 09:07:39 -04:00 committed by GitHub
parent a340d102a6
commit 4abc56c583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ import (
"github.com/grafana/grafana/pkg/tsdb/prometheus/models"
"github.com/grafana/grafana/pkg/tsdb/prometheus/querydata/exemplar"
"github.com/grafana/grafana/pkg/tsdb/prometheus/utils"
"github.com/grafana/grafana/pkg/util/converter"
)
@ -24,6 +25,9 @@ func (s *QueryData) parseResponse(ctx context.Context, q *models.Query, res *htt
}
}()
ctx, endSpan := utils.StartTrace(ctx, s.tracer, "datasource.prometheus.parseResponse", []utils.Attribute{})
defer endSpan()
iter := jsoniter.Parse(jsoniter.ConfigDefault, res.Body, 1024)
r := converter.ReadPrometheusStyleResult(iter, converter.Options{
MatrixWideSeries: s.enableWideSeries,
@ -46,13 +50,15 @@ func (s *QueryData) parseResponse(ctx context.Context, q *models.Query, res *htt
}
if r.Error == nil {
r = s.processExemplars(q, r)
r = s.processExemplars(ctx, q, r)
}
return r
}
func (s *QueryData) processExemplars(q *models.Query, dr backend.DataResponse) backend.DataResponse {
func (s *QueryData) processExemplars(ctx context.Context, q *models.Query, dr backend.DataResponse) backend.DataResponse {
_, endSpan := utils.StartTrace(ctx, s.tracer, "datasource.prometheus.processExemplars", []utils.Attribute{})
defer endSpan()
sampler := s.exemplarSampler()
labelTracker := exemplar.NewLabelTracker()