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 logger compat module for v2 restoring fully v1 behavior when using standard console #1534

Closed

Conversation

JonatanSalas
Copy link

Description

In firebase-functions v1 when using the standard console you'd visualize logs under cloud run with a traceId.

In v2 that behavior has gone, there's a module to patch the console but that method only makes console work again by adjusting the way it logs the user inserted messages.

Screenshot 2024-03-04 at 14 30 04

If we want to have the trace attached to each log emitted by a function we need to use the firebase logger module which is provided by firebase functions.

Since the logger compat module doesn't restore the behavior under v1, I've made an adaptation to ensure it works as expected and keeps the traceId.

The code is a draft, I've added a v2 folder inside the logger folder which I think is wrong but I've done so we can start discussing if this adjustment is possible and where it should go.

@taeold
Copy link
Contributor

taeold commented Sep 3, 2024

@JonatanSalas Hi Jonantan. I don't think this will fix the issue as you reported.

IIUC, compat module must be explicitly imported in order for console patching to work. And even if it is patched, you still won't be receiving traceIds in your 2nd Gen function; this is something that changed in Google Cloud Functions's 2nd Gen execution environment.

I recommend that you use Firebase Function SDK's logger module which automatically injects traceId based on request context.

@taeold taeold closed this Sep 3, 2024
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.

2 participants