Execution ID in logs generated by Firebase Functions v2
Logs generated by Firebase Functions v1 have the property labels.execution_id
that can be used to correlate logs that pertain to the same execution. However, that property doesn't exist in logs generated by Firebase Functions v2. It's very important for debugging.
-
Thomas Bouldin commented
Some of the "and more" includes
1. Using structured output so you leverage the full granularity of the logger/cloud logging rather than just getting info and error messages
2. Using structured output so things like error messages are guaranteed to be in a single log line rather than split across one log per line. -
Morten Bek Ditlevsen commented
Hi Thomas Bouldin,
Thanks a lot - I am using the firebase-functions/logger, but I had failed to discover that the trace ID was what I was looking for.
Since we are using structured logging, I did add my own ditto, but I can remove that again now then. Thanks so much.
I am curious that you write 'and more'. What might you be hinting at there? :-)
Perhaps my 'idea' could be rephrased to:
Let the logs explorer recognize trace ids and add a context menu showing 'See all from this execution' (similar to the previous functionality). I know it can be done 'manually', but it would be good for discoverability. -
Thomas Bouldin commented
If you use the logger available at `firebase-functions/logger`, it will automatically inject the trace ID for the same effect (and more!). If you don't want to use a separate logger (e.g. you want to upgrade logs from imported modules), you can import `firebase-functions/logger/compat` and it will patch `console.*` with all the upgrades.