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 debug log when sending requests via REST #2270

Merged
merged 11 commits into from
Dec 6, 2024

Conversation

parthea
Copy link
Contributor

@parthea parthea commented Dec 3, 2024

Fixes b/381100800

The work in #2266 (comment) is still outstanding.

When running tests for async REST, I see the following stack trace. If this is expected, we should file a follow up issue in case one doesn't already exist.

Traceback (most recent call last):
  File "/usr/local/google/home/partheniou/git/gapic-generator-python/check.py", line 24, in <module>
    asyncio.run(list_instances())
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.9.16/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.9.16/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/usr/local/google/home/partheniou/git/gapic-generator-python/check.py", line 17, in list_instances
    redis = CloudRedisAsyncClient(transport="rest_asyncio")
  File "/usr/local/google/home/partheniou/git/gapic-generator-python/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/async_client.py", line 258, in __init__
    self._client = CloudRedisClient(
  File "/usr/local/google/home/partheniou/git/gapic-generator-python/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py", line 595, in __init__
    self._transport = transport_init(
  File "/usr/local/google/home/partheniou/git/gapic-generator-python/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py", line 597, in __init__
    self._session = AsyncAuthorizedSession(self._credentials)  # type: ignore
  File "/usr/local/google/home/partheniou/git/google-auth-library-python/google/auth/aio/transport/sessions.py", line 120, in __init__
    raise exceptions.InvalidType(
google.auth.exceptions.InvalidType: The configured credentials of type <class 'google.oauth2.credentials.Credentials'> are invalid and must be of type `google.auth.aio.credentials.Credentials`

using this code

from google.cloud.redis_v1 import CloudRedisAsyncClient
import asyncio
async def list_instances():
    redis = CloudRedisAsyncClient(transport="rest_asyncio")
    response = await redis.list_instances(parent="projects/partheniou-303520/locations/us-central1", metadata=[('some-key-bin', b'some_value')])
    print(response)

asyncio.run(list_instances())

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Dec 3, 2024
@parthea parthea force-pushed the add-debug-log-rest-transport branch from afb6631 to fb771fa Compare December 3, 2024 12:38
@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 3, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 3, 2024
@parthea parthea marked this pull request as ready for review December 3, 2024 12:43
@parthea parthea requested a review from a team as a code owner December 3, 2024 12:43
Copy link
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

(These comments didn't get posted yesterday)

if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
http_response = {
"payload": {% if method.output.ident.is_proto_plus_type %}{{ method.output.ident }}.to_json(resp){% else %}json_format.MessageToJson(resp){% endif %},
"status": "OK", # need to obtain this properly
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to figure out how to obtain this.

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! This is the correct REST status code? (i.e. we don't translate it to gRPC?)

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't translate it to gRPC?

What does that mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can confirm the status code from the logs that I've shared in our chat.

@ohmayr ohmayr merged commit 4cb1fa2 into main Dec 6, 2024
85 checks passed
@ohmayr ohmayr deleted the add-debug-log-rest-transport branch December 6, 2024 19:24
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.

3 participants