-
Notifications
You must be signed in to change notification settings - Fork 567
chore(Pubsub): Add adhoc debug logging #32136
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
base: main
Are you sure you want to change the base?
Conversation
7c8937c to
2ead334
Compare
feywind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine from a logging perspective, just wondering about the histogram class comment.
|
The acceptance tests pass locally. They can be flakey when running on Kokoro. Acceptance test failures are unrelated to my changes. |
f36a306 to
4ebacf2
Compare
039d065 to
bdd5d68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a change to look into this a bit more. I think the approach we want to take it is along the lines of:
- Allow configuration of logger in
lib/google/cloud/pubsub.rb. I was thinking something like here, with 3 options. - Once we have it there, we can pass it to
Serviceto use downstream. - Logs should happen via
Messagefromgoogle-logging-utils:
@logger&.info do
# This block is only executed if INFO level is enabled, making it efficient.
Google::Logging::Message.new(....)
end
This logic should be able to handle instances of a default Ruby logger (e.g. stdin/out) or Google::Logging::StructuredFormatter, which you can use for testing.
HI @aandreassa . Thanks for your feedback.
You can programmatically configure a custom logger: require "google/cloud/pubsub"
require "logger"
# Configure a logger for the pubsub library
Google::Cloud.configure.pubsub.logger = Logger.new "my-app.log"If the custom logger is not configured, it will default to a standard stdout logger.
Talk tomorrow! |
73e205a to
1990c5e
Compare
|
These two pull requests introduce a standardized and dynamically configurable debug logging framework for Google Cloud Ruby clients and implement it in the Pub/Sub library. The primary goal was to enable on-demand debug logging that could be controlled by the developer via configuring a custom logger and controlling an environment variable to turn logs on/off. This required passing a logger from the handwritten client (google-cloud-pubsub) down to the underlying GAPIC client (google-cloud-pubsub-v1). I needed to build a wrapper around the logger (creating a logger duck-type) that will evaluate the environment variable before emitting logs. The Solution:
Once the first 2 PRs are approved, I will create a new PR that passes the GoogleSdkLoggerDelegator down to the GAPIC layer (google-cloud-pubsub-v1). |
1990c5e to
38f281b
Compare
https://docs.google.com/document/d/1R5UNVksMGCsN-KOthICr8-McrLmlN9F0XP99AKp6plY/edit?tab=t.s19hlulorz61
https://buganizer.corp.google.com/issues/427197812