-
Notifications
You must be signed in to change notification settings - Fork 453
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
chore: Add metric integration tests #2424
chore: Add metric integration tests #2424
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2424 +/- ##
=====================================
Coverage 79.3% 79.3%
=====================================
Files 122 122
Lines 21569 21565 -4
=====================================
Hits 17114 17114
+ Misses 4455 4451 -4 ☔ View full report in Codecov by Sentry. |
meter_provider | ||
} | ||
|
||
pub async fn metrics() -> Result<(), Box<dyn Error + Send + Sync + 'static>> { |
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 actual meters we're pushing through for the test
@@ -0,0 +1,133 @@ | |||
{ |
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.
same as metrics.json
but with minor changes to validate that our comparison is working.
@@ -6,114 +6,128 @@ | |||
{ |
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.
This file was already here, but was seemingly unused, so i've repurposed it to match the style of the other tests
@cijothomas i've fleshed out the basic pattern to add metrics integration coverage here; it still needs to cover the rest of the meters, and I need to deal with the windows build issues. I don't need a proper review yet, but if you have a second to glance over it let me know if anything seems fundamentally different to what you expect. |
@@ -7,7 +7,7 @@ publish = false | |||
|
|||
[dependencies] | |||
opentelemetry = { path = "../../../opentelemetry", features = ["metrics", "logs"] } | |||
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing"] } | |||
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing", "metrics"] } |
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: we can remove logs,metrics features as they are anyway by default added.
let mut result_scope_metrics = &mut result_resource_metrics.scope_metrics; | ||
let mut expected_scope_metrics = &mut expected_resource_metrics.scope_metrics; | ||
|
||
// Zero out all the timestamps so we can usual the default comparisons |
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.
this is good! Thanks.
let meter_provider = init_metrics(); | ||
|
||
let meter = meter_provider.meter("meter"); | ||
let counter = meter.u64_counter("counter_u64").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.
please add one observable instrument like observable counter .
// wait for file to flush to disks | ||
// ideally we should use volume mount but otel collector file exporter doesn't handle permission too well | ||
// bind mount mitigate the issue by set up the permission correctly on host system | ||
tokio::time::sleep(Duration::from_secs(5)).await; |
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.
while this test is important, we also need to add one where we rely on shutdown to push the metrics, instead of using a ultra-low interval for pushing metrics.
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.
Looks good overall, no concerns with the approach.
After an initial working version, we can add more combinations.
@@ -54,6 +54,7 @@ impl TestSuite { | |||
async fn integration_tests() { | |||
trace_integration_tests().await; | |||
logs_integration_tests().await; | |||
metrics_integration_tests().await; |
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.
Suggestion for future follow-up PR: While this works fine for now, using a shared collector setup across signals could improve efficiency and maintainability. Currently, the collector is started and stopped separately for each signal.
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.
That’s a good point - I’ll change it while I’m here, I don’t think it should be a problem as they are collecting separate signals anyhow.
+1 |
Contributes to #2401
Changes
Please provide a brief description of the changes here.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes