Skip to content

fix(id): reset agentless exporter identity state - #10342

Open
litianningdatadog wants to merge 1 commit into
tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancelfrom
tianning.li/microvm-buffer-reset-02-agentless-exporter-identity
Open

litianningdatadog wants to merge 1 commit into
tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancelfrom
tianning.li/microvm-buffer-reset-02-agentless-exporter-identity

Conversation

@litianningdatadog

@litianningdatadog litianningdatadog commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Reset trace exporter state when an AWS Lambda MicroVM refreshes its identity. A snapshot can contain buffered spans or an in-flight delivery; restoring that snapshot must not resend the old payload under the clone's new runtime identity.

This PR is the second step in the stacked breakdown of PR #9814, tracked by SVLS-9768.

Changes

  • Subscribe both the regular agent exporter and the agentless exporter to datadog:identity:refresh.
  • Clear each exporter's pending flush timer on refresh.
  • Reset the pending agent batch and shared request state for the regular agent exporter.
  • Close the private libdatadog pipeline used by the agentless writer before resetting its encoder and shared request state.
  • Add coverage for refresh handling, timer cleanup, and an active agentless pipeline.

Agentless exporter lifecycle

A refresh closes the current private libdatadog exporter; it does not create a replacement during the reset. The writer clears its cached exporter and configuration fields, then clears the encoded batch.

The next post-refresh flush that has data calls AgentlessWriter._sendPayload(). Its configuration check sees that no pipeline exporter exists and creates one with the current runtime ID, environment, API key, and endpoint. An empty flush does not recreate the exporter.

Dependency tree

  • origin/master
    • #10338 01-common-exporter-agent-spanstats-reset-and-cancel
      • #10342 02-agentless-exporter-identity ← current PR
      • #10341 06-datastream-reset-and-cancel
    • #10339 03-dogstatsd-buffer-reset
    • #10340 04-otel-runtime-baseline
      • #10343 05-otel-runtime-metric-resets

This PR is part of the stacked review sequence above.

@dd-octo-sts

dd-octo-sts Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.97 MB
Deduped: 9.7 MB
No deduping: 9.7 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.1 | 127.66 kB | 513.61 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@litianningdatadog litianningdatadog added the aws-microvm AWS MicroVM related features label Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.29%. Comparing base (dda557a) to head (9ce96e0).

❗ There is a different number of reports uploaded between BASE (dda557a) and HEAD (9ce96e0). Click for more details.

HEAD has 14 uploads less than BASE
Flag BASE (dda557a) HEAD (9ce96e0)
master-coverage 12 0
llmobs 1 0
test-optimization 1 0
Additional details and impacted files
@@                                                    Coverage Diff                                                    @@
##           tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancel   #10342       +/-   ##
=========================================================================================================================
- Coverage                                                                                 98.74%   81.29%   -17.46%     
=========================================================================================================================
  Files                                                                                      1029     1006       -23     
  Lines                                                                                    161396   154901     -6495     
  Branches                                                                                     74       74               
=========================================================================================================================
- Hits                                                                                     159374   125927    -33447     
- Misses                                                                                     2022    28974    +26952     
Flag Coverage Δ
ai-guard 65.27% <61.90%> (+0.24%) ⬆️
apm-capabilities 63.75% <100.00%> (+0.22%) ⬆️
apm-integrations 81.54% <61.90%> (-0.26%) ⬇️
appsec 58.95% <61.90%> (+0.28%) ⬆️
debugger 70.18% <61.90%> (-0.08%) ⬇️
instrumentation 54.47% <61.90%> (+0.18%) ⬆️
llmobs ?
master-coverage ?
openfeature 66.50% <61.90%> (+0.08%) ⬆️
platform 69.37% <59.25%> (+0.05%) ⬆️
profiling 66.84% <61.90%> (-0.07%) ⬇️
serverless 66.00% <61.90%> (+0.36%) ⬆️
test-optimization ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T21:08:00.630635Z 9ce96e0 New commits
🔒 Security Review ✅ Completed 2026-09-18T21:09:51.366818Z 9ce96e0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

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.

🔵 Needs a closer look

This is a draft, stacked identity-refresh change requiring final human review.

Pull request overview

Resets agent and agentless exporter state during MicroVM identity refreshes to prevent stale buffered data.

Changes:

  • Adds identity-refresh handling for both exporters.
  • Resets pending writer batches.
  • Adds focused refresh tests.
File summaries
File Summary
packages/dd-trace/test/exporters/agentless/exporter.spec.js Tests agentless exporter refresh handling.
packages/dd-trace/test/exporters/agent/exporter.spec.js Tests agent exporter refresh handling.
packages/dd-trace/src/exporters/agentless/index.js Resets agentless writer state on identity refresh.
packages/dd-trace/src/exporters/agent/index.js Resets agent writer state on identity refresh; separates the dc-polyfill third-party import group.
Review details

Suppressed comments (1)

packages/dd-trace/src/exporters/agent/index.js:4

  • Please keep the new dc-polyfill dependency in its own third-party import group, separated from the Node core and internal imports. The neighboring exporter/common/writer.js:3-9 and this file's agentless counterpart use that grouping, and the current placement makes the import ordering inconsistent with the repository convention.
const { channel } = require('dc-polyfill')
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b44ea439dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/exporters/agentless/index.js Outdated

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Datadog Autotest: FAIL

The agentless exporter keeps an active libdatadog request or retry after identity refresh. A restored MicroVM clone can send the old payload again.

Open Bits AI session

🤖 Datadog Autotest · Commit b44ea43 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Comment thread packages/dd-trace/src/exporters/agentless/index.js Outdated
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 81.27% (-16.96%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9ce96e0 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-18 21:18:17

Comparing candidate commit 9ce96e0 in PR branch tianning.li/microvm-buffer-reset-02-agentless-exporter-identity with baseline commit dda557a in branch tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancel.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2303 metrics, 10 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-9.576MB; +13.558MB] or [-4.338%; +6.142%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-29.628MB; +11.520MB] or [-8.488%; +3.301%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-4.890MB; +12.664MB] or [-6.494%; +16.819%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-9256.262KB; +9193.862KB] or [-12.655%; +12.570%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable execution_time [-281.139ms; +460.619ms] or [-3.940%; +6.455%]

scenario:plugin-graphql-long-with-depth-off-26

  • unstable cpu_user_time [-405.771ms; +385.040ms] or [-5.437%; +5.159%]
  • unstable execution_time [-430.870ms; +401.460ms] or [-5.666%; +5.279%]
  • unstable max_rss_usage [-33.170MB; +26.418MB] or [-15.102%; +12.028%]
  • unstable throughput [-17.699op/s; +19.407op/s] or [-5.230%; +5.735%]

scenario:plugin-memcached-hashring-24

  • unstable execution_time [-73.273ms; +186.622ms] or [-2.877%; +7.328%]

@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancel branch 2 times, most recently from ddfd268 to 6252560 Compare September 16, 2026 19:17
@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-02-agentless-exporter-identity branch 4 times, most recently from 3a669af to 56feaba Compare September 18, 2026 18:18
@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancel branch from 84d4715 to 131286c Compare September 18, 2026 19:12
@litianningdatadog
litianningdatadog requested a review from a team as a code owner September 18, 2026 19:12
@litianningdatadog
litianningdatadog requested review from BridgeAR and removed request for a team September 18, 2026 19:12
@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-02-agentless-exporter-identity branch from 56feaba to 125a469 Compare September 18, 2026 19:14

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Datadog Autotest: PASS

More details

The child finding refers to telemetry retry logic that this PR does not change. It does not meet the changed-line rule.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 56feaba · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-01-common-exporter-agent-spanstats-reset-and-cancel branch 2 times, most recently from 56806c4 to dda557a Compare September 18, 2026 21:02
@litianningdatadog
litianningdatadog force-pushed the tianning.li/microvm-buffer-reset-02-agentless-exporter-identity branch from 125a469 to 9ce96e0 Compare September 18, 2026 21:04

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

aws-microvm AWS MicroVM related features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants