[TraceQL Metrics] New baseline comparison function - #3695
Conversation
|
Instead of requiring max cardinality what if we also make it optional and default to a sensible value? I'm thinking it would be better to return the values Tempo got until max and an error instead of returning an error and nil when it reaches max cardinality. This way that attribute would still show some value, instead of none. Think of a graph with no data and an error label vs a graph with some data and an error/warning label, what would you prefer? I agree that the timestamps in the function are ugly, would be more TraceQL-y to have it as |
Yep can do that. I think 10 is a sensible default.
The main rationale was to avoid computing the exact topN values, which requires continuing to count and pass all values up to the query-frontend. There are two alternatives that are lossy but should be workable:
|
|
My proposal was inline with your |
* Initial working version of compare * Clean/rename * Redo meta labels for type and error. Add required parameter for max values * Add selectAll support to vParquet4 * vp2 unsupported * comment out test for now * Rename select all field * lint * compare() return topN and make it optional * Add callback version of AllAttributes to avoid map alloc * Fix lookup table * Hideous but working version with totals per attribute and classification * less hideous, and restore full time series processing * instant-ish query * add selectall attributes * Adding partial finished test for selectAll, blocked for now * lint * Review feedback, reenable using traceid and traceDuration in the filter * changelog * Finish vp4 selectall test, refactor some methods to share with test * Fix comment and remove test hacks
What this PR does:
This adds a new metrics function
comparewhich is used to split the stream of spans into two groups: a selection and a baseline. Then it returns time-series for all attributes found on the spans to highlight the differences between the two groups. This is kind of hard to describe so there are some example outputs below:Function signature:
The function is used like other metrics functions, which it is placed after any search query, and converts it into a metrics query:
...any spanset pipeline... | compare({subset filters}, <topN>, <start timestamp>, <end timestamp>)Example:
{ resource.service.name="a" && span.http.path="/myapi" } | compare({status=error})Parameters:
{status=error}(what is different about errors?) or{duration>1s}(what is different about slow spans?)span:startTimedirectly in the language, so it could be part of the filter.Output:
The outputs are flat time-series for each attribute/value found in the spans. This function has a built-in select(*) so there can be a lot. Each series has a label
__meta_typewhich denotes which group it is in, eitherselectionorbaseline.Example output series:
When an attribute reaches the cardinality limit there will also be present an error indicator. This example means the attribute
resource.clusterhad too many values.Remaining Work
stepequal toend-start, so effectively it is a range query that returns a single datapoint.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]