Skip to content

feat(opentelemetry): add meter provider shutdown - #10023

Merged
BridgeAR merged 8 commits into
masterfrom
brian.marks/otel-metrics-lifecycle
Sep 8, 2026
Merged

feat(opentelemetry): add meter provider shutdown#10023
BridgeAR merged 8 commits into
masterfrom
brian.marks/otel-metrics-lifecycle

Conversation

@bm1549

@bm1549 bm1549 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds callback-based shutdown(callback) to the Datadog meter provider returned by metrics.getMeterProvider().

Shutdown performs a final export, stops collection, drains pending delivery, and shuts down the exporter. The callback receives null on success or an error on failure. forceFlush() remains internal and is intentionally not exposed on the provider.

The Datadog provider extension is exported in both supported TypeScript declaration surfaces.

Motivation

Short-lived Node.js processes can exit before the periodic OTel metrics interval. They need a supported completion callback for their final custom metrics.

Additional Notes

@bm1549 bm1549 added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Aug 27, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 27, 2026

Copy link
Copy Markdown

Tests

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 98.16% (+0.02%)

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

@dd-octo-sts

dd-octo-sts Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.85 MB
Deduped: 9.52 MB
No deduping: 9.52 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 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

@pr-commenter

pr-commenter Bot commented Aug 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-08 20:26:50

Comparing candidate commit 32effdc in PR branch brian.marks/otel-metrics-lifecycle with baseline commit 4efd30d in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2308 metrics, 5 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-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-24.931MB; +15.272MB] or [-7.042%; +4.314%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-9.587MB; +6.724MB] or [-12.736%; +8.932%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-13.965MB; +4.331MB] or [-17.889%; +5.549%]

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

  • unstable max_rss_usage [-13.278MB; +21.006MB] or [-7.046%; +11.146%]

scenario:plugin-graphql-long-with-depth-on-max-26

  • unstable max_rss_usage [-14.301MB; +21.029MB] or [-7.766%; +11.420%]

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.68%. Comparing base (4efd30d) to head (32effdc).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10023   +/-   ##
=======================================
  Coverage   98.67%   98.68%           
=======================================
  Files        1006     1006           
  Lines      158039   158127   +88     
  Branches       74       74           
=======================================
+ Hits       155952   156041   +89     
+ Misses       2087     2086    -1     
Flag Coverage Δ
ai-guard 65.00% <ø> (-0.02%) ⬇️
apm-capabilities 63.78% <100.00%> (+0.02%) ⬆️
apm-integrations 81.47% <ø> (-0.02%) ⬇️
appsec 58.85% <ø> (-0.01%) ⬇️
debugger 69.82% <ø> (-0.06%) ⬇️
instrumentation 53.70% <ø> (-0.02%) ⬇️
llmobs 79.01% <ø> (-0.02%) ⬇️
master-coverage 98.68% <100.00%> (?)
openfeature 66.39% <ø> (-0.03%) ⬇️
platform 69.31% <57.14%> (-0.01%) ⬇️
profiling 66.76% <ø> (-0.03%) ⬇️
serverless 65.73% <ø> (-0.02%) ⬇️
test-optimization 82.82% <ø> (+0.02%) ⬆️

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.

@mabdinur
mabdinur requested a review from BridgeAR September 1, 2026 20:45
bengl
bengl previously requested changes Sep 1, 2026

@bengl bengl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is a promise API required, somehow? If not, you should use a callback API.

Comment thread docs/API.md Outdated
Comment thread packages/dd-trace/src/opentelemetry/metrics/meter_provider.js Outdated
@mabdinur
mabdinur force-pushed the brian.marks/otel-metrics-lifecycle branch 2 times, most recently from f57ccd3 to 89e7b75 Compare September 1, 2026 22:08
@mabdinur
mabdinur requested a review from bengl September 1, 2026 22:11
# Conflicts:
#	packages/dd-trace/src/opentelemetry/metrics/index.js
#	packages/dd-trace/test/opentelemetry/metrics.spec.js
@mabdinur
mabdinur force-pushed the brian.marks/otel-metrics-lifecycle branch from 89e7b75 to ca9fede Compare September 1, 2026 23:16

@mabdinur mabdinur 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.

Reviewed the callback lifecycle contract, implementation, and focused tests. CI is green.

@mabdinur
mabdinur marked this pull request as ready for review September 2, 2026 20:55
@mabdinur
mabdinur requested review from a team as code owners September 2, 2026 20:55
@mabdinur
mabdinur requested a review from wconti27 September 2, 2026 20:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-08T20:26:10.189439Z 32effdc 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.

@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: ca9fede157

ℹ️ 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/opentelemetry/metrics/periodic_metric_reader.js Outdated
Comment thread packages/dd-trace/src/opentelemetry/metrics/meter_provider.js
@mabdinur

mabdinur commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 8f0d90262c

ℹ️ 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 docs/test.ts Outdated
@mabdinur
mabdinur force-pushed the brian.marks/otel-metrics-lifecycle branch from 8f0d902 to 71566e8 Compare September 3, 2026 03:52
@mabdinur

mabdinur commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 71566e8122

ℹ️ 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 index.d.ts Outdated
@mabdinur
mabdinur force-pushed the brian.marks/otel-metrics-lifecycle branch from 71566e8 to 817849b Compare September 3, 2026 04:05
@mabdinur

mabdinur commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 817849b311

ℹ️ 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".

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should return null in case of no error. Otherwise LGTM

Comment thread index.d.ts Outdated

@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: 8298acd7b1

ℹ️ 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/opentelemetry/otlp/otlp_http_exporter_base.js
@mabdinur mabdinur changed the title feat(opentelemetry): add metrics lifecycle methods feat(opentelemetry): add meter provider shutdown Sep 8, 2026

@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: 43f091725c

ℹ️ 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".

@mabdinur
mabdinur requested a review from BridgeAR September 8, 2026 20:39
@BridgeAR
BridgeAR enabled auto-merge (squash) September 8, 2026 22:49
@BridgeAR
BridgeAR dismissed bengl’s stale review September 8, 2026 22:51

Request addressed

@BridgeAR
BridgeAR merged commit 6143de9 into master Sep 8, 2026
768 checks passed
@BridgeAR
BridgeAR deleted the brian.marks/otel-metrics-lifecycle branch September 8, 2026 22:52
This was referenced Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants