1

I am wondering if there exists an execution id into Cloud Run as the one into Google Cloud Functions?

An ID that identifies each invocation separately, it's very useful to use the "Show matching entries" in Cloud Logging to get all logs related to an execution.

I understand the execution process is different, Cloud Run allows concurrency, but is there a workaround to assign each log to a certain execution?

My final need is to group at the same line the request and the response. Because, as for now, I am printing them separately and if a few requests arrive at the same time, I can't see what response corresponds to what request...

Thank you for your attention!

Béranger
  • 90
  • 7
  • 1
    No there isn't execution ID, only the instanceID. To have that, you can use instrumentation tools, like Open Telemetry. You can also customize the app logs with a custom/random execution ID (similar of what OT does) – guillaume blaquiere Sep 26 '22 at 12:25
  • Hey Guillaume, merci, ok I am having a look to OT! – Béranger Sep 28 '22 at 08:56
  • Does above comment helped you to sort out issue? if so, can you share the solution, so that it will help others too? – Roopa M Oct 27 '22 at 11:38

1 Answers1

0

Open Telemetry looks like a great solution, but the learning and manipulation time isn't negligible,

I'm going with a custom id created in before_request, stored in Flask g and called at every print().

@app.before_request
def before_request_func():
    
    execution_id = uuid.uuid4()

    g.execution_id = execution_id
Béranger
  • 90
  • 7