Skip to content

feat: ad-hoc, targeted debug logging #2062

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

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

feat: ad-hoc, targeted debug logging #2062

wants to merge 13 commits into from

Conversation

feywind
Copy link
Collaborator

@feywind feywind commented Jul 3, 2025

This feature will add the ability to selectively enable "printf debugging" output for diagnostic introspection. This uses the new standard Google ad-hoc debug logging infrastructure introduced a few months back.

Samples:

GOOGLE_SDK_NODE_LOGGING=pubsub:*

All hand-written logic on top of the auto-generated RPCs.

GOOGLE_SDK_NODE_LOGGING=pubsub*

All logging related to Pub/Sub (including the RPCs).

GOOGLE_SDK_NODE_LOGGING=*

All logging, including things like auth.

A fuller guide will be forthcoming.

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: pubsub Issues related to the googleapis/nodejs-pubsub API. labels Jul 3, 2025
@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@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 Jul 3, 2025
@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@feywind feywind marked this pull request as ready for review July 3, 2025 23:06
@feywind feywind requested review from a team as code owners July 3, 2025 23:06
@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 16, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 16, 2025
Copy link
Contributor

@sofisl sofisl left a comment

Choose a reason for hiding this comment

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

same general comment about private elements

}

/**
* Cancels any pending publishes and calls _publish immediately.
*
* Does _not_ attempt to further drain after one batch is sent.
*/
async publish(): Promise<void> {
await this._publishInternal(false);
async publish(reason: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

since you're adding a param, wouldn't you need to add a default value to make it backwards-compatible or make it optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These two are internal/private methods, so they shouldn't need a default. I'm trying to make sure that everything that calls them gets updated for the logging, but at this point I guess it would be okay to add a default? Users definitely shouldn't be calling these directly, so I am also fine with just leaving it as-is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, re: private methods, this library is pretty old and wasn't built to use them, so it would be pretty painful to add it now, imo. I'll definitely think about that going forward, but e.g. a lot of the unit tests assume that innards are accessible for mocking. I'd like to find a better way to do the unit tests too, but there are over 900 of them now 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went ahead and made those optional parameter changes.

hongalex
hongalex previously approved these changes Jul 21, 2025
@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 21, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants