Skip to content

fix: Disable client-side trace stats computation in Lambda#4471

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
joey/disable-trace-stats
Feb 24, 2026
Merged

fix: Disable client-side trace stats computation in Lambda#4471
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
joey/disable-trace-stats

Conversation

@joeyzhao2018

@joeyzhao2018 joeyzhao2018 commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

https://datadoghq.atlassian.net/browse/APMSVLS-389

What does this PR do?

  • Add ddtracer.WithStatsComputation(false) to the tracer initialization options in the Lambda wrapper's initTracer() method
  • Client-side stats computation is enabled by default (DD_TRACE_STATS_COMPUTATION_ENABLED=true) but is unnecessary in Lambda — the Datadog Extension handles stats server-side, making client-side computation redundant and a source of duplicate data
  • Uses the WithStatsComputation StartOption (with OriginCode priority) rather than setting the env var, avoiding timing concerns with internal/config initialization and global state mutation

Motivation

In Lambda environments:

  • When the extension is running: stats are computed server-side by the extension, so client-side computation produces duplicate data
  • When the extension is not running: WithLambdaMode(true) routes traces to stdout with no agent to receive stats, making client-side stats meaningless

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

@joeyzhao2018
joeyzhao2018 requested review from a team as code owners February 23, 2026 23:48
@github-actions github-actions Bot added the apm:ecosystem contrib/* related feature requests or bugs label Feb 23, 2026
@codecov

codecov Bot commented Feb 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 55.66%. Comparing base (c9ac510) to head (2383571).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...b/aws/datadog-lambda-go/internal/trace/listener.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...b/aws/datadog-lambda-go/internal/trace/listener.go 45.36% <0.00%> (-0.48%) ⬇️

... and 372 files with indirect coverage changes

🚀 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.

Comment thread contrib/aws/datadog-lambda-go/README.md Outdated
@pr-commenter

pr-commenter Bot commented Feb 24, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-02-24 13:24:47

Comparing candidate commit 2383571 in PR branch joey/disable-trace-stats with baseline commit c9ac510 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 152 metrics, 9 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 ----------------------------------'

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 26d636c into main Feb 24, 2026
213 of 218 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the joey/disable-trace-stats branch February 24, 2026 15:21
jchrostek-dd added a commit to DataDog/datadog-lambda-go that referenced this pull request Apr 15, 2026
…head in Lambda

Stats computation was enabled by default in dd-trace-go v2.1.0 (DataDog/dd-trace-go#3548).
When extension v91+ advertises /v0.6/stats support in its /info response, tracer.Flush()
makes a synchronous HTTP POST to http://127.0.0.1:8126/v0.6/stats before returning,
adding 33-59ms per warm invocation.

This fix disables stats computation at the tracer level so it is never posted from Lambda,
mirroring the identical fix already applied to the dd-trace-go contrib Lambda wrapper in
DataDog/dd-trace-go#4471 (APMSVLS-389).

Resolves: SLES-2790
jchrostek-dd added a commit to DataDog/datadog-lambda-go that referenced this pull request Apr 20, 2026
…head in Lambda (#244)

Stats computation was enabled by default in dd-trace-go v2.1.0 (DataDog/dd-trace-go#3548).
When extension v91+ advertises /v0.6/stats support in its /info response, tracer.Flush()
makes a synchronous HTTP POST to http://127.0.0.1:8126/v0.6/stats before returning,
adding 33-59ms per warm invocation.

This fix disables stats computation at the tracer level so it is never posted from Lambda,
mirroring the identical fix already applied to the dd-trace-go contrib Lambda wrapper in
DataDog/dd-trace-go#4471 (APMSVLS-389).

Resolves: SLES-2790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done serverless

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants