feat: emit durable execution log to stdout at invocation start [SVLS-8582]#743
feat: emit durable execution log to stdout at invocation start [SVLS-8582]#743
Conversation
Emits a structured JSON log to stdout at the start of each durable function invocation, mapping the Lambda request_id to the durable execution name and ID. The Lambda extension layer uses this to correlate request IDs with durable executions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| "durable_execution_id": execution_id, | ||
| "schema_version": DURABLE_INVOCATION_LOG_SCHEMA_VERSION, | ||
| } | ||
| print(json.dumps(log), file=sys.stdout, flush=True) |
There was a problem hiding this comment.
why not using the logger?
There was a problem hiding this comment.
@joeyzhao2018 probably logger injects other things which we don't want
There was a problem hiding this comment.
I think this message should always be logged, and using logger introduces a risk that this message is dropped due to log level. Do you think it's safe to use logger.info()?
There was a problem hiding this comment.
ah, you mean the "parsing" part would be a big unpredictable? can we use regex to solve that part?
using logger can make sure it still follows the existing rules such as extra injections or if customers want to change the level.
There was a problem hiding this comment.
oh, i see, you don't want this to be controlled by log level.
There was a problem hiding this comment.
Although your change says "to use logs instead of traces to enrich logs" still creates a dependency where you need a tracing layer to have complete observability in logs – does that even make sense from a dependency standpoint?
There was a problem hiding this comment.
The dependency refers to the one between trace agent and log agent in lambda extension. Using traces adds coupling between them, making extension code harder to maintain. See discussion here DataDog/datadog-lambda-extension#1053 (comment)
| to correlate request IDs with durable executions. | ||
| """ | ||
| log = { | ||
| "request_id": request_id, |
There was a problem hiding this comment.
I thought extension side has the information of the request_id
There was a problem hiding this comment.
Race conditions often happen (e.g. logs can be delayed), and given a log message, it's hard for the extension to know which request_id it was for, so I think it's safer and easier to add request_id to the log message.
There was a problem hiding this comment.
i see. that makes sense.
| "request_id": request_id, | ||
| "durable_execution_name": execution_name, | ||
| "durable_execution_id": execution_id, | ||
| "schema_version": DURABLE_INVOCATION_LOG_SCHEMA_VERSION, |
There was a problem hiding this comment.
why we need a schema version here?
There was a problem hiding this comment.
I'm worried that we may need to add more fields in the future, though I'm not sure how yet. Adding schema version will make it easier for extension to identify incompatibility (e.g. missing field) and print an error to ask the user to update tracer.
There was a problem hiding this comment.
adding more fields shouldn't require a schema. i'm not very convinced that we need it.
There was a problem hiding this comment.
I would agree that we don't need schema version. If we need to change this in the future, which I think is very unlikely, then we can add schema version at that point.
|
Summary
At the beginning of an invocation of a durable function, emit a log like:
{ "request_id": "123", "durable_execution_name": "abc", "durable_execution_id": "def", "schema_version": "1.0.0" }The Lambda extension layer uses this log to map request ID to durable_execution_name and durable_execution_id.
Passing this information using logs instead of trace tags so the architecture is cleaner on extension side: the logs agent can use logs to extract this information and add attribute to other logs, instead of depending on traces and receiving information from trace agent. Discussion: DataDog/datadog-lambda-extension#1053 (comment)
Test plan
🤖 Generated with Claude Code