Fix: correctly close trace span in Prometheus and Loki data sources (#57774)

* rename span for loki
This commit is contained in:
Yuriy Tseretyan
2022-10-28 10:17:56 -04:00
committed by GitHub
parent 6126f56ef0
commit fa043efb2c
2 changed files with 64 additions and 59 deletions
+2 -2
View File
@@ -184,17 +184,17 @@ func queryData(ctx context.Context, req *backend.QueryDataRequest, dsInfo *datas
}
for _, query := range queries {
_, span := tracer.Start(ctx, "alerting.loki")
_, span := tracer.Start(ctx, "datasource.loki")
span.SetAttributes("expr", query.Expr, attribute.Key("expr").String(query.Expr))
span.SetAttributes("start_unixnano", query.Start, attribute.Key("start_unixnano").Int64(query.Start.UnixNano()))
span.SetAttributes("stop_unixnano", query.End, attribute.Key("stop_unixnano").Int64(query.End.UnixNano()))
defer span.End()
logger := logger.FromContext(ctx) // get logger with trace-id and other contextual info
logger.Debug("Sending query", "start", query.Start, "end", query.End, "step", query.Step, "query", query.Expr)
frames, err := runQuery(ctx, api, query)
span.End()
queryRes := backend.DataResponse{}
if err != nil {