Skip to content

test(o11y): add GAPIC LRO tracing network RPC error integration tests#5889

Draft
haphungw wants to merge 3 commits into
googleapis:mainfrom
haphungw:fix-lro-tracing-gapic-network-errors
Draft

test(o11y): add GAPIC LRO tracing network RPC error integration tests#5889
haphungw wants to merge 3 commits into
googleapis:mainfrom
haphungw:fix-lro-tracing-gapic-network-errors

Conversation

@haphungw

Copy link
Copy Markdown
Contributor

Stacked on top of #5886.

Introduce integration tests validating telemetry attributes during network RPC errors encountered during polling.

@haphungw haphungw changed the title Fix lro tracing gapic network errors test(o11y): add GAPIC LRO tracing network RPC error integration tests Jun 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/o11y/src/lro_tracing.rs Outdated
Comment on lines +334 to +347
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"))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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];

Comment thread tests/o11y/src/lro_tracing.rs Outdated
Comment on lines +478 to +491
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"))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.90%. Comparing base (d059878) to head (f855545).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haphungw haphungw force-pushed the fix-lro-tracing-gapic-network-errors branch 3 times, most recently from 6b140d8 to 26d5d7e Compare June 16, 2026 17:39
@haphungw haphungw force-pushed the fix-lro-tracing-gapic-network-errors branch from 26d5d7e to 112fcd6 Compare June 16, 2026 18:28
haphungw added 2 commits June 16, 2026 22:23
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.
@haphungw haphungw force-pushed the fix-lro-tracing-gapic-network-errors branch from 112fcd6 to dafcd25 Compare June 16, 2026 22:25
@haphungw haphungw force-pushed the fix-lro-tracing-gapic-network-errors branch from dafcd25 to f855545 Compare June 16, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant