New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transformers: Support adding the row index using calculate field transformer #65148
Conversation
You have successfully added a new CodeQL configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic - thanks so much for this, it looks great to me 👏 🚢
I saw your comment on #65146 (comment)
In general i am skeptical of trying to magically detect and avoid running the xform multiple times (if it is configured multiple times... should it run multiple times?)
I agree - if configured multiple times it should run multiple times.
Do we need any software-tests for this at all? I think it's ok, but thought it worth asking the question.
packages/grafana-data/src/transformations/transformers/calculateField.ts
Show resolved
Hide resolved
return r.name; | ||
} | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you introduced this break
here?
And why don't we also need one at the end of the BinaryOperation
case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a JS thing. We don't need one in BinaryOperation because if it matches that case there is always a return. In ReduceRow we only hit the return if the reducer exists. In JS cases fall through by default, so you have to break or it will do the Index case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its a js thing 🤣 -- yup switch in go has explicit fallthough and the opposite in js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS inherited a lot from C syntax, so this is actually a C-ism 😜
Yeah this is much better! |
I'll add some tests and update the docs before merge |
Alternative to #64822
What is this feature?
This adds a new mode to the existing "calculate fields transformer" that will let add the row number
Why do we need this feature?
We need to be able to visualise a timeseries quantile for people who don't understand what it is and how it works. Especially when it comes to understanding Grafana Cloud metrics billing (see the "Who is this feature for" section) we need to show them on their own data, within a Grafana Panel & Dashboard, so that they can see how fluctuations in their data are impacting on the quantile. values of interest (specifically the 95th percentile)
Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
Please check that: