-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Lens] Implement counter rate expression #82948
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
Good question, I think going with |
12abf6f
to
e0b4b31
Compare
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.
Relocating series_calculation_helpers
outside of the specs
directory makes sense to me, so I'm good on the app arch changes once we get a green build 👍
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.
Didn't run, but test cases look good to me. Left one small nit
const previousValue = previousValues[bucketIdentifier]; | ||
const currentValue = newRow[inputColumnId]; | ||
if (currentValue != null && previousValue != null) { | ||
if (Number(currentValue) >= previousValue) { |
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.
nit: There are four places where currentValue
is cast to number, we could refactor this to a single currentValueAsNumber
, but no biggie
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.
I didn't run this code, but just looking at the code looks good. Left one comment about clarifying a test case.
}, | ||
{ inputColumnId: 'val', outputColumnId: 'output' } | ||
); | ||
expect(result.rows.map((row) => row.output)).toEqual([undefined, 7 - 5, 3, 2]); |
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.
Most of the other tests are using numbers that are always increasing, this test appears to be the only one that tests the scenario where the number goes down. Are there other scenarios to test around the edge cases of the algorithm? Or maybe you can name the test differently to indicate that this one tests 2 things?
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.
Good idea @wylieconlon! I'll add new test.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
Summary
Fixes #46627
Adds
lens_counter_rate
function.The counter rate function works exactly like derivative expression if value increases or is equal to previous one – it returns the difference between current and previous value.
If value decreased compared to the previous value, the function outputs the current value. Here's the example:
Special cases
For undefined:
Question: NaN case
Should value after NaN be also NaN (eg. counter between NaN and 2 - that's what derivative do) or should it be NaN?
The expression takes inputColumnId, outputColumnId, outputColumnName, by (similar behavior to new expression time series functions)
Checklist