How to get `execution_id` in Cloud Function (Node) environment

1,291 views
Skip to first unread message

Juan Uys

unread,
Jun 18, 2018, 11:18:59 AM6/18/18
to Firebase Google Group
Hello,

In my Firebase trigger (or Cloud Function), when I log with console.log, I see a

labels['execution_id']

on StackDriver:


I do my logging with nodejs-logging-winston, and can't figure out how to get my own handle on the execution_id so I can set it on the logging metadata.


Thanks,
Juan

Robert-Jan Huijsman

unread,
Jun 18, 2018, 5:39:47 PM6/18/18
to Firebase Google Group
Hi Juan!

I'm sorry to say that we don't currently have a way to programmatically access the execution ID. I've noted your feedback in the internal feature request we have open for this.

In the mean time, you may find that the `event_id` you get in the asynchronous (non-HTTP) functions context object can achieve the same goals as the execution ID. They're not the same, but they behave much the same; most notably they'll be identical between retries of the same function execution.

Cheers,
RJ.

Juan Uys

unread,
Jun 19, 2018, 10:25:28 AM6/19/18
to Firebase Google Group
On Monday, 18 June 2018 22:39:47 UTC+1, Robert-Jan Huijsman wrote:

In the mean time, you may find that the `event_id` you get in the asynchronous (non-HTTP) functions context object can achieve the same goals as the execution ID. They're not the same, but they behave much the same; most notably they'll be identical between retries of the same function execution.

Thanks for the reply, Robert-Jan.

I'll look into using event_id in the interim. 

Justin Noel

unread,
Apr 28, 2019, 6:21:36 PM4/28/19
to Firebase Google Group
I'd really love to use the `execution_id` in my logging as well for HTTP, db, and storage triggers.  Right now, I'm generating a GUID at the beginning of each request.  Then, I use that GUID on every log for that request.  This works reasonably well.  However, it makes it hard to then find the log entry that Firebase generates to tell the function start and end times.

So, being able to access that `execution_id` would let me see something like:

2019-04-28 12:36:04.410 CDT receiveMessage 4nzkoeiqi2q8 Function execution started
2019-04-28 12:36:04.410 CDT receiveMessage 4nzkoeiqi2q8 my-custom-log-info-1
2019-04-28 12:36:04.410 CDT receiveMessage 4nzkoeiqi2q8 my-custom-log-info-2
...
2019-04-28 12:36:05.299 CDT receiveMessage 4nzkoeiqi2q8 Function execution took 889 ms, finished with status code: 200

Is something like this possible?

Reply all
Reply to author
Forward
0 new messages