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 standardized debug logging #354

Merged
merged 1 commit into from
Jul 24, 2024
Merged

feat: add standardized debug logging #354

merged 1 commit into from
Jul 24, 2024

Conversation

jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Jul 24, 2024

Standardize optional debug logging across AlloyDB Connector packages.

To print debug logs for the Python Connector package add the following to your application:

import logging

logging.basicConfig(format="%(asctime)s [%(levelname)s]: %(message)s")
logger = logging.getLogger(name="google.cloud.alloydb.connector")
logger.setLevel(logging.DEBUG)

Example of the debug logs produced:

2024-07-24 17:52:05,231 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Refresh strategy is set to background refresh
2024-07-24 17:52:05,231 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Connection info added to cache
2024-07-24 17:52:05,231 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Connection info refresh operation started
2024-07-24 17:52:05,881 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Connection info refresh operation complete
2024-07-24 17:52:05,882 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Current certificate expiration = 2024-07-24T18:52:04+00:00
2024-07-24 17:52:05,882 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Connection info refresh operation scheduled for 2024-07-24T18:22:06+00:00 (now + 0:30:01)
2024-07-24 17:52:05,882 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Connecting to 127.0.0.1:5433
2024-07-24 17:52:06,458 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Canceling connection info refresh operation tasks
2024-07-24 17:52:06,458 [DEBUG]: ['projects/my-proj/locations/us-central1/clusters/my-cluster/instances/my-instance']: Scheduled refresh operation cancelled
2024-07-24 17:52:06,458 [DEBUG]: Waiting for connector's http client to close
2024-07-24 17:52:06,459 [DEBUG]: Closed connector's http client

Currently debug logging the following:

  • When a refresh operation starts
  • When a refresh operation finishes
  • When a refresh operation errors
  • When a refresh operation is canceled
  • The ephemeral certificate’s expiration time
  • The next scheduled refresh
  • Adding connection info to the cache
  • The IP address connection is being made to

Fixes #272

@jackwotherspoon jackwotherspoon self-assigned this Jul 24, 2024
@jackwotherspoon jackwotherspoon requested a review from a team as a code owner July 24, 2024 18:55
Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

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

Thank you! ❤️ ❤️

@jackwotherspoon jackwotherspoon merged commit 14d6b1c into main Jul 24, 2024
15 checks passed
@jackwotherspoon jackwotherspoon deleted the debug-logging branch July 24, 2024 20:22
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.

Add standardized debug logging
2 participants