Skip to content

feat: emit durable execution log to stdout at invocation start [SVLS-8582]#743

Open
lym953 wants to merge 3 commits intomainfrom
yiming.luo/durable-emit-log
Open

feat: emit durable execution log to stdout at invocation start [SVLS-8582]#743
lym953 wants to merge 3 commits intomainfrom
yiming.luo/durable-emit-log

Conversation

@lym953
Copy link
Contributor

@lym953 lym953 commented Mar 10, 2026

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

  1. Passed the added unit tests
  2. Build a layer, install it on a function, and invoke the function. The message was logged as expected:
image

🤖 Generated with Claude Code

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>
@lym953 lym953 changed the title feat: emit durable execution log to stdout at invocation start [SVLS-8582] feat: emit durable execution log to stdout at invocation start Mar 10, 2026
@lym953 lym953 changed the title [SVLS-8582] feat: emit durable execution log to stdout at invocation start feat: emit durable execution log to stdout at invocation start [SVLS-8582] Mar 10, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lym953 lym953 marked this pull request as ready for review March 10, 2026 19:30
@lym953 lym953 requested review from a team as code owners March 10, 2026 19:30
"durable_execution_id": execution_id,
"schema_version": DURABLE_INVOCATION_LOG_SCHEMA_VERSION,
}
print(json.dumps(log), file=sys.stdout, flush=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using the logger?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joeyzhao2018 probably logger injects other things which we don't want

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i see, you don't want this to be controlled by log level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought extension side has the information of the request_id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need a schema version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding more fields shouldn't require a schema. i'm not very convinced that we need it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@joeyzhao2018
Copy link
Contributor

joeyzhao2018 commented Mar 10, 2026

the logs agent can use logs to extract this information and add attribute to other logs

  1. Would there be any race conditions such that this piece of log gets processed too late?
  2. Would there be any performance impact since you need to look for one specific log? (edit: i look up in the current code, it's already parsing all the logs. so not a big concern here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants