@@ -241,11 +241,21 @@ func (q *query) Exec(ctx context.Context) (logqlmodel.Result, error) {
241
241
242
242
if q .logExecQuery {
243
243
queryHash := util .HashedQuery (q .params .QueryString ())
244
+
245
+ logValues := []interface {}{
246
+ "msg" , "executing query" ,
247
+ "query" , q .params .QueryString (),
248
+ "query_hash" , queryHash ,
249
+ }
250
+ tags := httpreq .ExtractQueryTagsFromContext (ctx )
251
+ tagValues := tagsToKeyValues (tags )
244
252
if GetRangeType (q .params ) == InstantType {
245
- level . Info ( logutil . WithContext ( ctx , q . logger )). Log ( "msg" , "executing query" , " type" , "instant" , "query" , q . params . QueryString (), "query_hash" , queryHash )
253
+ logValues = append ( logValues , "type" , "instant" )
246
254
} else {
247
- level . Info ( logutil . WithContext ( ctx , q . logger )). Log ( "msg" , "executing query" , " type" , "range" , "query" , q . params . QueryString (), " length" , q .params .End ().Sub (q .params .Start ()), "step" , q .params .Step (), "query_hash" , queryHash )
255
+ logValues = append ( logValues , "type" , "range" , "length" , q .params .End ().Sub (q .params .Start ()), "step" , q .params .Step ())
248
256
}
257
+ logValues = append (logValues , tagValues ... )
258
+ level .Info (logutil .WithContext (ctx , q .logger )).Log (logValues ... )
249
259
}
250
260
251
261
rangeType := GetRangeType (q .params )
@@ -265,6 +275,7 @@ func (q *query) Exec(ctx context.Context) (logqlmodel.Result, error) {
265
275
sp .LogKV (statResult .KVList ()... )
266
276
267
277
status , _ := server .ClientHTTPStatusAndError (err )
278
+
268
279
if q .record {
269
280
RecordRangeAndInstantQueryMetrics (ctx , q .logger , q .params , strconv .Itoa (status ), statResult , data )
270
281
}
0 commit comments