test(o11y): add GAPIC LRO tracing network RPC error integration tests#5889
test(o11y): add GAPIC LRO tracing network RPC error integration tests#5889haphungw wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces integration tests for Long-Running Operation (LRO) tracing within the observability tests crate (tests/o11y). It adds a new module lro_tracing containing tests for successful LRO polling, logical LRO errors, transient RPC errors, and permanent RPC errors. The review feedback suggests refactoring the test assertions in tests/o11y/src/lro_tracing.rs to reuse the find_get_operation_spans helper function instead of manually filtering spans, which will improve code reuse and readability.
| let get_op_span = spans | ||
| .iter() | ||
| .find(|s| { | ||
| s.name == "client_request" | ||
| && s.attributes | ||
| .get("rpc.method") | ||
| .map(|v| { | ||
| v.as_string() | ||
| == Some("google.longrunning.Operations/GetOperation".to_string()) | ||
| }) | ||
| .unwrap_or(false) | ||
| }) | ||
| .ok_or_else(|| anyhow::anyhow!("missing GetOperation span"))?; | ||
|
|
There was a problem hiding this comment.
Instead of manually filtering the spans list and duplicating the logic to find GetOperation spans, you can reuse the find_get_operation_spans helper function. This simplifies the code and adds an explicit assertion on the number of expected spans.
// 2. T3 span "client_request" (get_operation) should have error details
let get_op_spans = find_get_operation_spans(&spans);
assert_eq!(get_op_spans.len(), 1, "expected exactly 1 GetOperation span");
let get_op_span = get_op_spans[0];| let get_op_span = spans | ||
| .iter() | ||
| .find(|s| { | ||
| s.name == "client_request" | ||
| && s.attributes | ||
| .get("rpc.method") | ||
| .map(|v| { | ||
| v.as_string() | ||
| == Some("google.longrunning.Operations/GetOperation".to_string()) | ||
| }) | ||
| .unwrap_or(false) | ||
| }) | ||
| .ok_or_else(|| anyhow::anyhow!("missing GetOperation span"))?; | ||
|
|
There was a problem hiding this comment.
Instead of manually filtering the spans list and duplicating the logic to find GetOperation spans, you can reuse the find_get_operation_spans helper function. This simplifies the code and adds an explicit assertion on the number of expected spans.
// 2. T3 span "client_request" (get_operation) should be ERROR
let get_op_spans = find_get_operation_spans(&spans);
assert_eq!(get_op_spans.len(), 1, "expected exactly 1 GetOperation span");
let get_op_span = get_op_spans[0];
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5889 +/- ##
=======================================
Coverage 97.89% 97.90%
=======================================
Files 233 233
Lines 59202 59202
=======================================
+ Hits 57958 57961 +3
+ Misses 1244 1241 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6b140d8 to
26d5d7e
Compare
26d5d7e to
112fcd6
Compare
Add error.type attribute to the LRO Wait span and populate it from the status code if the long-running operation fails with a status code. This allows observability tools to track error rates by error type for long-running operations.
112fcd6 to
dafcd25
Compare
dafcd25 to
f855545
Compare
Stacked on top of #5886.
Introduce integration tests validating telemetry attributes during network RPC errors encountered during polling.