Skip to content

fix(grpcio): properly record and re-raise exceptions - #911

Open
CagriYonca wants to merge 1 commit into
mainfrom
fix-grpcio
Open

CagriYonca wants to merge 1 commit into
mainfrom
fix-grpcio

Conversation

@CagriYonca

Copy link
Copy Markdown
Contributor

Problem Description

Fixes #895

src/instana/instrumentation/grpcio.py::create_span caught gRPC exceptions and recorded them on the span, but did not re-raise them. As a result, the wrapper implicitly returned None, causing:

  • TypeError: cannot unpack non-iterable NoneType object when using gRPC interceptors / with_call (e.g. pymilvus).
  • Silently swallowed grpc.RpcError exceptions on standard calls.

Solution

  • Re-raise wrapped exceptions: Added raise in create_span and call_behavior_with_instana after span.record_exception(exc) so caller applications receive the original grpc.RpcError.
  • Isolate telemetry errors: Wrapped Instana internal metadata injection and attribute collection in a dedicated try/except block (logger.debug) to ensure sensor errors never affect customer code.
  • Prevent duplicate error count: Configured record_exception=False on start_as_current_span to avoid duplicate ec increments on raise.
  • Tests: Added test_server_error_with_call in tests/frameworks/test_grpcio.py to cover with_call exception propagation.

Signed-off-by: Cagri Yonca <cagri@ibm.com>
@CagriYonca
CagriYonca marked this pull request as ready for review October 8, 2026 08:57
@CagriYonca
CagriYonca requested a review from a team as a code owner October 8, 2026 08:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gRPC interceptor swallows exceptions and returns None instead of re-raising

1 participant