Closed
Description
Firestore Cloud functions V2 are missing traces in logs, which makes debugging very painful.
[REQUIRED] Version info
node: 18
firebase-functions: 4.4.1
firebase-tools: 12.4.3
firebase-admin: 11.9.0
[REQUIRED] Test case
import { logger } from "firebase-functions/v2";
export const foo = onDocumentWritten(
{
document: "/foo/{fooId}",
},
async (event) => {
logger.info("This log should have trace. But it does not 😭");
}
);
[REQUIRED] Steps to reproduce
Create a v2 firestore function and look at the logs in the Google Cloud Logs
[REQUIRED] Expected behavior
There should be a trace, to make debugging easier. It is a massive pain to do right now.
This is how firebase-function tasks show up in the logs. Lovely, a trace. So easy to debug! 😍

[REQUIRED] Actual behavior
This is how v2 firestore logs show up. No trace, so hard to debug 😭

Were you able to successfully deploy your functions?
Yes
Activity
google-oss-bot commentedon Jul 11, 2023
I found a few problems with this issue:
milo- commentedon Jul 11, 2023
Looking at the source for other v2 triggers, they wrap all the handlers using wrapTraceContext:
https://github.com/firebase/firebase-functions/blob/master/src/v2/providers/database.ts#L471
The v2 Firestore handler isn't using wrapTraceContext:
https://github.com/firebase/firebase-functions/blob/master/src/v2/providers/firestore.ts#L448
ciriousjoker commentedon Oct 29, 2023
It might be worth adding that when importing v1 stuff into a v2 function (e.g. the old
config()
, which no longer works), the error messages produced by the v1 stuff aren't tagged with a trace.I assume this is working as intended.
fgatti675 commentedon Jan 10, 2024
Hi,


I see this ticket marked as closed but I still don't see the traces like in previous v1 functions.
V2 sample:
V1 sample:
The trace id is extremely useful for finding all the logs to specific invocation. Right now it is pretty painful.
Also note that in V2 there is no tag for the function name.
I suspect there might be something wrong with my setup. This is how I initialize my API:
abdulaziz-mohammed commentedon Apr 26, 2024
why is this closed?
blidd-google commentedon Apr 26, 2024
Hi @fgatti675, see my comment here for more details about how to trace logs from the same invocation in 2nd gen. If you are continuing to have issues, please open a new issue with a reproducible sample and we'll investigate as soon as we can.
fgatti675 commentedon Apr 29, 2024
Thank you! We managed to get the traces working again, we were really missing this.
As a comment, they only work using the logger imported from
firebase-functions/logger
, it doesn't work usingconsole.log
, but much appreciatedfgatti675 commentedon Sep 23, 2024
Traces are gone, not sure since when, with no changes in our side.
You don't understand how frustrating this is.
Really, what is going on at Google?
Byrontoo commentedon Sep 29, 2024
adamxi commentedon Oct 3, 2024
@Byrontoo: We were having the same issues. Suddenly our stack traces were shortened after a redeploy, yet no firebase related dependencies had been updated. In fact, through much debugging it seemed that the
logging.googleapis.com/trace
log entry cannot be set manually AT ALL despite the documentation still indicating otherwise. In production this always gets overwritten.So it appears that during function deployment, the
functions-framework
dependency is added to the build, unless already included (which it isn't for our project). In a recent update to thefunctions-framework
library, theLOG_EXECUTION_ID
env variable was introduced. Inspecting this on the deployed 2nd gen cloud function from the variables tab, to seems to default totrue
, despite the documentation stating otherwise. And yes.. after a redeploy withLOG_EXECUTION_ID=false
our log trace values were working as before and no longer shortened.So
LOG_EXECUTION_ID=true
effectively overwriteslogging.googleapis.com/trace
and alsologging.googleapis.com/spanId
it seems. Very frustrating to suddenly have stuff break in production like this.7 remaining items