Repository navigation
feat(api_core): implement L2/L3 method error logging and L4 transport attempt logging - #19000
chalmerlowe wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry-correlated Production Error Logging (PEL) for both gRPC and HTTP transports across synchronous and asynchronous clients, including new interceptors, feature gating, and terminal RPC error logging. The review feedback highlights three critical issues in _observability.py that could compromise the library's fail-open design: first, calling response.exception() on a cancelled gRPC future in the synchronous interceptor may raise an unhandled CancelledError and crash the application; second, converting grpc.StatusCode enums directly to strings using str() yields incorrect status names (e.g., 'StatusCode.OK'), breaking failure detection; and third, executing post-dispatch logging inside the exception-capturing context manager in the asynchronous interceptor could allow logging failures to disrupt the main RPC flow.
…spatch inspection
|
|
||
|
|
||
| def _extract_rpc_identity( | ||
| method_name: str, |
There was a problem hiding this comment.
Note
To the reviewer: this has been moved to _observability.py
Summary
Implements OpenTelemetry-correlated Production Error Logging (PEL) across GAPIC method calls (Tier 3 / L3) and underlying gRPC and HTTP transport wire attempts (Tier 4 / L4) in
google-api-core:client_logging.is_error_logging_enabled): Gates Production Error Logging viaGOOGLE_SDK_EXPERIMENTAL_PYTHON_LOGGING_ENABLEDandclient_options.logger_provider, keeping it distinct from Application Payload Debug Logging (GOOGLE_SDK_PYTHON_LOGGING_SCOPE).gapic_v1/method.py): Enriches active Tier 3 spans with structured error attributes and emits a single terminalERRORlog record on RPC failure (or aDEBUGlog record without traceback on cancellation) across sync and async calls._observability.py): EmitsDEBUGlog records for failed/retried gRPC and HTTP wire attempts (log_transport_attempt,_GrpcAttemptLoggingInterceptor,_AsyncGrpcAttemptLoggingInterceptor, and_TraceContext) while remaining a zero-allocation no-op on successful2xx/OKattempts.Stacked on #18893.