-
Notifications
You must be signed in to change notification settings - Fork 204
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
Functions v2 missing labels with Firebase structured logs #1331
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Ah yes, I ran into this as well, and created a ticket here firebase/firebase-js-sdk#6925 Basically, V2. functions are grouped under the "Cloud Run Revision" resource type. If you look in my linked ticket, you'll see that they had this same bug in the cloud function logging packages for Go + Java. |
Hey @dan-wu-open, thanks for your reply. I don't understand why your ticket was closed, though, as the issue seems to be unsolved. I don't see how the reply to your problem - linking to https://github.com/firebase/firebase-functions - addresses the issue. Am I missing something? |
I think it's because the root cause is with firebase-functions, so we need to make a change in that package, rather than in firebase-js-sdk |
Oh got it, thanks for the clarification @dan-wu-open. Guess this issue is in the right place then. |
As a work-around using |
I just migrated my first project from gen1 to gen2 callable functions and the logging is just terrible. |
I also just upgraded to gen 2. When looking at the logs I was surprised that it is no longer possible to filter logs which belong to one invocation, as 'execution_id' is missing. This is a crucial mechanism to inspect the logs in order to trace what happened during this particular invocation. How to do that without the labels? No mention of this topic in the migration guide either. |
Is there any track of this issue? |
Need this as well |
Has anyone figured out a workaround to filter by one execution? |
Is anyone at Google actually listening to these issues? The V2 functions seem broken in so many ways. |
We created a custom wrapper for the logging. First for every invocation, a random value is created and used as execution ID. We pass this object as last argument to the log methods. export function createExtendedLogContext(): ExtendedLogContext {
// create a random execution id with 10 digits and chars
const execution_id = Math.random().toString(36).substring(2, 12)
return {
'logging.googleapis.com/labels': {
execution_id,
function_name: process.env.FUNCTION_NAME || ''
}
}
} |
Just ran into this issue when migrating from v1 function to v2. With v1 functions I made no changes to my codebase, and all logging through The v1 docs say that you need to include a compatibility patch to get this behaviour, but I did not. Seems this was the default behaviour. Moving to v2 I noticed:
My workaround:
If you want to do something like @glumb I would suggest looking at the "x-cloud-trace-context" header that cloud functions receive. You can extract the trace id from this header. This would allow you to join your log requests with the standard log lines. Really surprised to see no mention of this change on the version comparison chart. |
How does one get at the headers outside of onRequest / onCall @HonahleeWill? |
Not gonna be possible as far as I know. The trace is generated per-request, so you will need access to the request headers to read it. You will need to generate a new logging context for each request (also ensure that context isn't shared by other requests). |
Looks like the code in firebase-functions/src/logger/index.ts Line 158 in 3e7a4b7
|
I ended up just writing my own patch for console logging. This might help you @lox:
|
@HonahleeWill nope, will still not help due to #1440 not being released. |
Hello @lox @metadiego. With the release of #1440, is the logging working as expected? |
|
That is a bummer :( |
Hey @metadiego. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
What information is needed? I don't believe this is fixed yet. |
Any estimates on when this will be fixed? |
One year, still an issue :( |
any updates ? i have migrates from v1 to v2 and every trace indicator is missing from onDocumentCreated or onDocumentUpdated. Also is really hard to follow traces for new v2 cloud functions. Have to edit Summary fields all the times and its not integrated with Log Explorer as v1 was. I m considering moving back to v1 because every issue is a tragedy to analyze |
We retracted from v2 to v1 mostly due to this issue. Fortunately it was just a fraction of functions that we've experimented with v2. |
Yes honestly, this is incredibly frustrating. And time continues to pass and we have 0 news. |
In terms of performance to develop, it did not improve performance. That is my conclusion. |
What if we open a ticket at https://issuetracker.google.com/ telling them the issue. And then we discuss it in there, I have seen bigger problems being reported there and the guys from Google took some time, but after some pressure the problem was fixed. |
@AndreRLima are you referring specifically to missing labels other than trace contexts? This issue is a bit all over the place. Most of the function types seem to have had trace contexts added now. |
@lox Yes, I am referring to missing labels |
@AndreRLima so just the function name and the revision id? |
@lox Yeah, I would say so, but the tracing is still strange, v1 tracing is way better than v2 This how my log looks like. I am using |
@lox cool, thanks. Yeah, I did not know that you could add like that. Just in case someone does not know as well. You need to do the following:
|
In v1, there is execution_id. Using this execution id, it is very easy to check the logs. |
@deepak-agendaboa I believe that is because in v1 cloudfunctions were used, v2 is cloudrun. Most function types include a |
Hi @lox, is it possible to save the Summary field resource.labels.service_name to always show up? Every time that I open a new tab I need to do steps that put here, so that I can see it. |
@AndreRLima Yup, summary fields can be saved in a saved search. |
Hi! I'm still a bit confused with how the logs are organized with v2, so maybe you could clarify what to expect in the future? I've just deployed sample v2 function using nodejs and it seems that its logs are not present in the |
V2 functions have moved from Cloud Functions to Cloud Run, that sounds like very expected behaviour @orestesgaolin? |
it's still missing trace id. I would like to debug a hit to an edpoint isolated from any other requests like it used to be with functions v1. now it's all mixed please help |
Hi @abdulaziz-mohammed, which trigger type do you have deployed that when invoked is missing the trace ID? Could you open a new issue with a reproducible example? It would really help us get to the bottom of the issue you are dealing with. |
I really miss the fields "execution id" and "function name" from entries by default... |
@blidd-google |
@jobweegink You can file a new issue with reproducible examples and we can take a closer look at it |
Hi @blidd-google, We do not see the trace for the
|
Firebase logger structured logs for v2 Cloud functions are missing labels.
This causes a secondary issue, which is that, when trying to access function logs from Firebase console, the logs are empty. Reason being that the URL generated when you click 'View Logs' (see screenshot below) assumes that the function has appropriate labels, but it does not:
Related issues
Maybe this: #703
[REQUIRED] Version info
**node:**16
**firebase-functions:**3.24.1
**firebase-tools:**11.19.0
**firebase-admin:**11.3.0
[REQUIRED] Test case
Create a log from a v2 Cloud Function. Invoke the function. Go to Firebase console > Functions. Click on 'View logs' for previously created function. Logs will be empty because labels are missing.
[REQUIRED] Steps to reproduce
Create a v2 Cloud Function and, using logger, create a structured log, for example:
Inspect the output in your logs.
[REQUIRED] Expected behavior
v2 function logs are similar to v1 function logs, which include labels: function name and version, like this example v1 log label:
[REQUIRED] Actual behavior
v2 function does not include any labels.
Were you able to successfully deploy your functions?
Yes.
No
The text was updated successfully, but these errors were encountered: