Skip to content

fix: flush feature flag telemetry at the end of each invocation - #878

Open
purple4reina wants to merge 2 commits into
mainfrom
rey.abolofia/ffe-flush-invocation-end
Open

purple4reina wants to merge 2 commits into
mainfrom
rey.abolofia/ffe-flush-invocation-end

Conversation

@purple4reina

@purple4reina purple4reina commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Publishes dd-trace's ffe:writers:flush diagnostics channel at the end of each invocation, right after the existing flushMetrics() call. dd-trace's exposure and flag-evaluation writers subscribe to this channel and send their buffers when it publishes.

Motivation

dd-trace sends feature flag telemetry on a 10 second unref()'d timer. Lambda freezes the sandbox as soon as the handler returns, so the timer never fires and feature_flag.evaluations stays at zero. A customer confirmed this with Extension v104 and layer 144.

Jira: https://datadoghq.atlassian.net/browse/APMSVLS-730

Additional Notes

  • The publish starts delivery but does not wait for it, because dd-trace-js has no awaitable flush. It runs before the awaited metric and extension flushes, which gives the sends time to complete before the freeze. A guaranteed, bounded wait needs a dd-trace-js change like dd-trace-py#21135, which the Python version (datadog-lambda-python#872) uses.
  • No try/catch: diagnostics_channel never throws subscriber errors to the publisher. With an older tracer, or with feature flags off, nothing subscribes and the publish does nothing.
  • Not yet verified in a deployed Lambda. Reviewers: please run that check before merging.

Types of Changes

  • Bug fix

Check all that apply

  • This PR's changes are covered by the automated tests

🤖 Generated with Claude Code

purple4reina and others added 2 commits December 4, 2026 14:04
dd-trace sends feature flag evaluations and exposures on a 10 second
unref'd timer, which never fires before Lambda freezes the sandbox.
Publish dd-trace's ffe:writers:flush channel when the invocation
completes, before the awaited metric flushes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@purple4reina
purple4reina marked this pull request as ready for review December 4, 2026 22:27
@purple4reina
purple4reina requested a review from a team as a code owner December 4, 2026 22:27

@datadog-prod-us1-3 datadog-prod-us1-3 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The feature-flag flush starts before the awaited metric and extension flushes. Delivery remains best-effort because dd-trace provides no awaitable flush; deployed Lambda delivery remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 06d0439

This branch has not been deployed

No deployments
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.

1 participant