-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat(stdlib/contrib): Add stdlib/contrib package events #3266
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3266 +/- ##
==========================================
- Coverage 49.63% 49.59% -0.05%
==========================================
Files 344 346 +2
Lines 35852 35984 +132
==========================================
+ Hits 17794 17845 +51
- Misses 15583 15655 +72
- Partials 2475 2484 +9
Continue to review full report at Codecov.
|
@tomhollingworth Thanks! The new events.duration function behavior looks great and I agree it seems like others will find value in it as well. I'll ask someone on the team to take at the code and get back to you. |
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.
Thanks for doing this work. I have some very minor copy editing things I'd like to see changed, but those issues are surrounded by excellent documentation. Thank you for taking the time to do that.
* fix(stdlib/contrib): copy editing * feat(stdlib/contrib): additional test coverage
Thanks for the feedback and opportunity to contribute! Last commit includes:
|
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.
Thank you so much for this work. It is the kind of contribution I'm not only happy to include, but am excited to do so. It's a good example of what good work looks like. Thank you again.
We release at least once a week, usually on Monday. |
Pull request for a community contributed package.
Done checklist
Why?
My use case is getting the total time in states. The
elapsed
function would drop a value and associate the duration with the subsequent record andstateDuration
would continuously totalize on a function from a starting time. The issue with state duration is that if the same value appears multiple times in a row it's duration in state could be counted multiple times. It also logged the time against the subsequent record. I was previously using a custom flux function, see below, however the performance wasn't great and I'm sure others would benefit from this.How?
This package contains a function
events.duration
which iterates on the timeColumn and compares the current record against the next record and calculates a difference between the two. For the last record it compares against the stopColumn unless a stop time is provided.Basic Example:
Comparison between
elapsed
,stateDuration
andevents.duration
Consider the following dataset of a door opening and closing:
|> elapsed()
yields the following. The first record is dropped and durations are associated with subsequent records. Totalizing on filter on value and summing the elasped column would have the duration swapped between open and closed.|> stateDuration(fn: (r) => true)
yields the following. The duration is continuously totalized. For a particular state we could also include that in our stateDuration function, however time is counted twice on subsequent events. Totalizing this would have that time counted twice.|> events.duration()
yields the following.Notice how time in duration is associated with the correct value. One can easily now group by _value and sum to get the total time in each state.
Custom Flux Function
As mentioned above I was previously doing something similar to
events.duration
in a inline flux function but performance wasn't great.Reviewer Notes