Skip to content
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

feat: add client debug logging support for unary-stream gRPC calls #2336

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

parthea
Copy link
Contributor

@parthea parthea commented Feb 14, 2025

Fixes #2289

Also see necessary changes in googleapis/python-api-core#794 to add logging in the response iterator each time a chunk is received in the stream.

Sync Unary->Stream

tests/system/test_streams.py 
{"timestamp": "2025-02-19 14:31:06,113", "severity": "DEBUG", "name": "google.showcase_v1beta1.services.echo.client", "message": "Created client `google.showcase_v1beta1.EchoClient`.", "serviceName": "google.showcase.v1beta1.Echo", "credentialsType": "builtins.NoneType", "universeDomain": ""}
{"timestamp": "2025-02-19 14:31:06,130", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"The\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,131", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"hail\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,132", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"in\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,133", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"Wales\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,134", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"falls\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,135", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"mainly\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,135", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"on\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,136", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"the\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-19 14:31:06,137", "severity": "DEBUG", "name": "google.api_core.grpc_helpers", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"snails.\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
.
============================== 1 passed in 4.24s ===============================

Async Unary->Stream

tests/system/test_streams.py 
{"timestamp": "2025-02-14 22:09:14,950", "severity": "DEBUG", "name": "google.showcase_v1beta1.services.echo.async_client", "message": "Created client `google.showcase_v1beta1.EchoAsyncClient`.", "serviceName": "google.showcase.v1beta1.Echo", "credentialsType": "builtins.NoneType", "universeDomain": ""}
{"timestamp": "2025-02-14 22:09:14,959", "severity": "DEBUG", "name": "google.showcase_v1beta1.services.echo.transports.grpc_asyncio", "message": "Sending request for b'/google.showcase.v1beta1.Echo/Expand'", "rpcName": "b'/google.showcase.v1beta1.Echo/Expand'", "serviceName": "google.showcase.v1beta1.Echo", "request": {"payload": "{\n  \"content\": \"The hail in Wales falls mainly on the snails.\"\n}", "requestMethod": "grpc", "metadata": {"showcase-trailer": "hello world", "x-goog-api-version": "v1_20240408", "x-goog-api-client": "gl-python/3.9.16 grpc/1.67.1 gax/2.24.1 gapic/0.0.0"}}, "metadata": {"showcase-trailer": "hello world", "x-goog-api-version": "v1_20240408", "x-goog-api-client": "gl-python/3.9.16 grpc/1.67.1 gax/2.24.1 gapic/0.0.0"}}
{"timestamp": "2025-02-14 22:09:14,967", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"The\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,969", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"hail\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,970", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"in\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,971", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"Wales\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,972", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"falls\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,973", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"mainly\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,973", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"on\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,974", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"the\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
{"timestamp": "2025-02-14 22:09:14,975", "severity": "DEBUG", "name": "google.api_core.grpc_helpers_async", "message": "Received response of type <class 'google.showcase_v1beta1.types.echo.EchoResponse'> via gRPC stream", "response": {"payload": "{\n  \"content\": \"snails.\",\n  \"severity\": 0,\n  \"requestId\": \"\",\n  \"otherRequestId\": \"\"\n}", "status": "OK"}}
.

@parthea parthea self-assigned this Feb 14, 2025
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Feb 14, 2025
@parthea parthea force-pushed the add-unary-stream-logging branch from d69564c to 27463b2 Compare February 14, 2025 22:26
@parthea parthea marked this pull request as ready for review February 14, 2025 22:36
@parthea parthea requested a review from a team as a code owner February 14, 2025 22:36
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Feb 14, 2025
@parthea parthea added owlbot:run Add this label to trigger the Owlbot post processor. size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Feb 14, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 14, 2025
@parthea parthea assigned vchudnov-g and ohmayr and unassigned parthea Feb 19, 2025
@parthea parthea requested review from ohmayr and vchudnov-g February 19, 2025 14:34
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[logging] add client logging support for gRPC streaming RPCs
3 participants