Skip to content

Commit

Permalink
logs query & hashedquery separately to minimize stacktraces (#11901)
Browse files Browse the repository at this point in the history
Rather than call all our values together, this PR precomputes a few in
`metrics.go` so any issues will result in smaller stack traces.
  • Loading branch information
owen-d authored Feb 8, 2024
1 parent fe53eb6 commit 52167c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/logql/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ func RecordRangeAndInstantQueryMetrics(
}

queryTags, _ := ctx.Value(httpreq.QueryTagsHTTPHeader).(string) // it's ok to be empty.
var (
query = p.QueryString()
hashedQuery = util.HashedQuery(query)
)

logValues := make([]interface{}, 0, 50)

logValues = append(logValues, []interface{}{
"latency", latencyType, // this can be used to filter log lines.
"query", p.QueryString(),
"query_hash", util.HashedQuery(p.QueryString()),
"query", query,
"query_hash", hashedQuery,
"query_type", queryType,
"range_type", rt,
"length", p.End().Sub(p.Start()),
Expand Down

0 comments on commit 52167c4

Please sign in to comment.