Dynamic metrics group by multiple attributes#2582
Conversation
zalegrala
left a comment
There was a problem hiding this comment.
This looks like a good start to me. Do you want to plumb through the frontend, or leave that for another PR?
Can you clarify what you mean? It already works end-to-end by reusing the Note I chose comma because it's a common delimiter, and it's already excluded from being part of an attribute name in regular queries by the code here: https://github.com/grafana/tempo/blob/main/pkg/traceql/lexer.go#L253 |
zalegrala
left a comment
There was a problem hiding this comment.
Sorry, I meant to approve yesterday. This looks good to me with one comment about whitespace on the query.
| return results, nil | ||
| } | ||
|
|
||
| func lookup(needles []traceql.Attribute, haystack map[traceql.Attribute]traceql.Static) traceql.Static { |
There was a problem hiding this comment.
Haha, I love this signature.
There was a problem hiding this comment.
Yeah it was feeling clunky but I think those parameter names saved it. :)
| message SpanMetrics { | ||
| repeated RawHistogram latency_histogram = 1; | ||
| TraceQLStatic static = 2; | ||
| repeated KeyValue series = 2; |
There was a problem hiding this comment.
Maybe we also include a status code to indicate control messages like not-found?
There was a problem hiding this comment.
Or possibly on the KeyValue.
There was a problem hiding this comment.
When an attribute is not found it will return a traceql static with Nil type (empty value). This works because real nils are not possible (against spec but also not persisted).
What this PR does:
Updated /api/metrics/summary to support grouping by mulitple attributes. The
groupByparameter can be a comma delimited list of attributes. Response was changed to return a slice of key/value pairs, in the same order that they are specified in groupBy. A nil is returned for any missing value. Originally it was just the values, but I thought it was better to include the key instead of putting the onus on the caller to know what to expect.This is a draft because it should go after #2579 which also has changes in this area.
Which issue(s) this PR fixes:
Fixes n.a
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]