-
Notifications
You must be signed in to change notification settings - Fork 506
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
Test successful collection by PeriodicReader #1521
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1521 +/- ##
=======================================
+ Coverage 61.9% 62.8% +0.9%
=======================================
Files 144 144
Lines 19862 19891 +29
=======================================
+ Hits 12303 12502 +199
+ Misses 7559 7389 -170 ☔ View full report in Codecov by Sentry. |
use std::sync::mpsc; | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
async fn registration_triggers_collection() { |
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.
not sure I follow the name of the test, as the trigger for collection is the time interval only...
The test is validating that, during collection, triggered by time interval, the observable's callback(s) are invoked.
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.
The aim is to test that creating the SdkMeterProvider
instance triggers the start of the worker that will periodically collect (and export) metrics. This is the line being tested:
let meter_provider = SdkMeterProvider::builder().with_reader(reader).build();
Perhaps a better name would be registration_triggers_worker
?
Using the observable callback is a roundabout way to confirm that the worker thread is running. Maybe better to use meter_provider.force_flush()
and exporter.get_finished_metrics()
instead, as in other tests? I also want to avoid test flakiness here.
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.
calling force_flush() would anyway flush the metric, even without the worker starting?... I need check in detail, but this testing logic sounds good to me.
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.
builder_triggers_periodicreader_worker - as alternative suggestion. Or you can just add a code comment with your comment, as that was good explanation.
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.
Using the observable callback is a roundabout way to confirm that the worker thread is running.
I believe this test looks good to validate the periodic exporter metric collection cycle through the mpsc
channel. We don't need to validate the measurements and their aggregation, as there are other tests for the same.
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. Left a suggestion about rename and/or leaving a code comment to make it clear what are we testing with this particular test, given it may not be very obvious.
Changes
Add a success scenario test for
PeriodicReader
as suggested in #1481 (comment)Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes