Skip to content

feat: added min_over_time TraceQL metric - #3975

Merged
mdisibio merged 22 commits into
grafana:mainfrom
javiermolinar:min_over_time
Aug 30, 2024
Merged

feat: added min_over_time TraceQL metric#3975
mdisibio merged 22 commits into
grafana:mainfrom
javiermolinar:min_over_time

Conversation

@javiermolinar

@javiermolinar javiermolinar commented Aug 19, 2024

Copy link
Copy Markdown
Contributor

What this PR does:
It adds a new TraceQL metric min_over_time used to compute the minimum value of a span series over a specified date range.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
Comment thread pkg/traceql/ast.go
@javiermolinar
javiermolinar marked this pull request as draft August 19, 2024 10:44
Comment thread pkg/traceql/engine_metrics.go Outdated
@javiermolinar
javiermolinar marked this pull request as ready for review August 19, 2024 14:27
Comment thread pkg/traceql/ast.go
Comment thread pkg/traceql/ast.go Outdated
Comment thread pkg/traceql/ast_stringer.go Outdated
Comment thread pkg/traceql/engine_metrics.go Outdated
Comment thread pkg/traceql/engine_metrics.go Outdated
Comment thread pkg/traceql/engine_metrics.go
Comment thread pkg/traceql/engine_metrics.go Outdated

@mdisibio mdisibio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline - we need to add a new aggregator for mode Sum/Final, which computes the min across time-series (i.e. the min of all mins), and use it in MetricsAggregate.initSum and initFinal. Right now it is still falling back to SimpleAdditionAggregator.

Comment thread pkg/traceql/ast.go
Comment thread pkg/traceql/engine_metrics.go Outdated
@javiermolinar
javiermolinar requested a review from mdisibio August 23, 2024 14:43
@javiermolinar

Copy link
Copy Markdown
Contributor Author

Back to draft, we need to come out with a solution for missing/uninitialized time-series values

@javiermolinar
javiermolinar marked this pull request as draft August 26, 2024 12:59
@knylander-grafana

Copy link
Copy Markdown
Contributor

Is this something we'll want to document?

@javiermolinar
javiermolinar marked this pull request as ready for review August 28, 2024 15:41
@javiermolinar

Copy link
Copy Markdown
Contributor Author

Is this something we'll want to document?

Yes, once we agreed on a solution we should document this new function

Comment thread pkg/traceql/engine_metrics.go
@knylander-grafana

Copy link
Copy Markdown
Contributor

Is this something we'll want to document?

Yes, once we agreed on a solution we should document this new function

This may be a good spot for your content. The compare function content went on the traceql/metrics-queries.md file in the Functions section.

Comment thread pkg/traceql/engine_metrics.go

@mdisibio mdisibio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great. I'm really happy with this PR because we are straightening up some ast and value handling quirks that needed it. There is 1 more required change to drop series with no values, and then 1 small nit that I would prefer but not blocking.

Comment thread pkg/traceql/engine_metrics.go Outdated
@javiermolinar

javiermolinar commented Aug 30, 2024

Copy link
Copy Markdown
Contributor Author

Is this something we'll want to document?

Yes, once we agreed on a solution we should document this new function

This may be a good spot for your content. The compare function content went on the traceql/metrics-queries.md file in the Functions section.

@knylander-grafana I've added some documentation. Maybe is a good idea to have a section for all the aggregation functions over_time. Like prometheus does

@javiermolinar
javiermolinar requested a review from mdisibio August 30, 2024 11:07

@mdisibio mdisibio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

Comment thread docs/sources/tempo/traceql/metrics-queries.md Outdated
Comment thread docs/sources/tempo/traceql/metrics-queries.md Outdated
@knylander-grafana knylander-grafana added the type/docs Improvements or additions to documentation label Aug 30, 2024
@knylander-grafana

Copy link
Copy Markdown
Contributor

If you have a PR with doc updates, add the type/docs label to it please.

@mdisibio
mdisibio merged commit 8c6519f into grafana:main Aug 30, 2024
@knylander-grafana

knylander-grafana commented Aug 30, 2024

Copy link
Copy Markdown
Contributor

@knylander-grafana I've added some documentation. Maybe is a good idea to have a section for all the aggregation functions over_time. Like prometheus does

@javiermolinar Thank you for adding the doc! We have a doc issue to update the metrics query docs (they need some love).

Before we restructure sections in the page, we should look at the content on the metrics query pages to consider who our target audience is, what are the topics that audience needs to know, what are they interested in doing (determine any tasks -- which helps us create meaningful examples), etc.

The Prometheus example is a good way of just listing an item and defining what it does. It could be a good way to do an introduction to a section, and then provide either an example for every function (in which case you use the subheadings like we have) or your subheadings are focused on examples and use cases for the functions. Does that difference make sense? I'd love to see the latter (function list like Prom docs and then real-world examples and explanations), but it takes more time than providing the function heading, with a brief explanation, and then a simple example.

I've captured this conversation in the metrics query doc issue.

mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
* added min_over_time traceql metric

* fix parsing

* add metricsAggregateMinOverTime to the extract conditions to fetch the attribute

* fix tests

* refactor code

* refactor FloatizeAttribute

* unused parameter warning

* added a recombiner aggregator

* ammend traceql lex

* handle NaN values

* fix tests

* test that combination of valid values remove default NaNs

* do not show empty time series

* refactor aggregator function

* changelog and documentation

* doc changes

* typo

* bring back quantile doc header

* fix typos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/docs Improvements or additions to documentation

3 participants