Skip to content

[SVLS-9189] feat(logs): add config param DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE#1239

Open
lym953 wants to merge 2 commits into
mainfrom
yiming.luo/durable-log-buffer-size
Open

[SVLS-9189] feat(logs): add config param DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE#1239
lym953 wants to merge 2 commits into
mainfrom
yiming.luo/durable-log-buffer-size

Conversation

@lym953
Copy link
Copy Markdown
Contributor

@lym953 lym953 commented May 27, 2026

Background

For durable functions, the extension holds logs and waits to get the invocation context from the tracer so the extension can enrich the logs.

Problem

When tracing is off (which is not recommended for durable functions), logs are flushed when:

  1. the buffer is full (buffer size is all logs for 50 invocations). This increases delay. Or
  2. when extension shuts down. However, this is not guaranteed to happen due to race conditions, causing missing logs.

This PR

  • Adds durable_function_log_buffer_size config field (env var DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE, default: 0) controlling the max number of request ID keys held in held_logs.
  • When set to 0, logs bypass the hold mechanism and are sent immediately without durable execution context enrichment.
  • Setting the default to 0 for now because the tracer changes for durable functions are not released. Later, after tracer changes are released, we can change the default back to 50 and ask customers to install the tracer for durable functions.

Test plan

Steps

  • Build an extension layer
  • install it on a durable function
  • execute the function
  • wait for a few minutes until the environment shuts down

Result

Before:

  • No log appears in Datadog
  • and the invocation doesn't appear either

After:

  • The invocation appears
image - Logs also appear image

Adds `durable_function_log_buffer_size` (env: `DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE`,
default: 50) to control the max number of request ID keys held in `held_logs`
waiting for durable execution context. Setting it to 0 disables holding entirely,
so logs are flushed immediately without durable context enrichment — useful when the
tracer is not installed and the buffer would otherwise delay log delivery until full
or until extension shutdown.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@datadog-datadog-prod-us1

This comment has been minimized.

@lym953 lym953 changed the title feat(logs): add DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE config param [SVLS-9189] feat(logs): add config param DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE May 27, 2026
Default to 0 (disabled) until tracer-side durable execution support is
released. Customers can set DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE=50 to
opt into context enrichment once the tracer is available.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lym953 lym953 marked this pull request as ready for review May 27, 2026 20:39
@lym953 lym953 requested a review from a team as a code owner May 27, 2026 20:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new DD_DURABLE_FUNCTION_LOG_BUFFER_SIZE configuration option that controls the maximum number of request IDs whose logs are held in the durable-function log buffer. The previous hardcoded constant (HELD_LOGS_MAX_KEYS = 50) is replaced by this configurable value, defaulted to 0, which bypasses the hold mechanism entirely so logs are flushed immediately without durable execution context enrichment. This avoids missing-log issues when the tracer is not installed on durable functions.

Changes:

  • New durable_function_log_buffer_size config field (env + yaml + default), defaulting to 0.
  • LambdaProcessor reads this value, replacing the HELD_LOGS_MAX_KEYS constant, and short-circuits the hold path when set to 0.
  • Existing durable-arn tests explicitly set held_logs_max_keys = 50 to preserve prior behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
bottlecap/src/config/mod.rs Adds durable_function_log_buffer_size: usize field with doc and default 0.
bottlecap/src/config/env.rs Adds env var deserialization, merge call, and updates default-config test.
bottlecap/src/config/yaml.rs Updates yaml test expected struct with new field.
bottlecap/src/logs/lambda/processor.rs Replaces constant with configurable cap; adds zero-disables fast path; updates tests.


let processing_rules = &datadog_config.logs_config_processing_rules;
let logs_enabled = datadog_config.serverless_logs_enabled;
let held_logs_max_keys = datadog_config.durable_function_log_buffer_size;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: rename held_logs_max_keys to durable_function_log_buffer_size or sth. similar for better readability.

/// durable execution context enrichment. Useful when the tracer is not installed.
/// Default is `0`.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub durable_function_log_buffer_size: Option<usize>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wondering if this should include the LAMBDA prefix, since we're gonna migrate to the config package from serverless-components eventually,

that way it makes it more descriptive that its for the lambda product

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