Expose OpenTelemetry metrics shutdown through MeterProvider - #12317
Expose OpenTelemetry metrics shutdown through MeterProvider#12317bm1549 wants to merge 9 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
Note from Claude (reviewing on behalf of @dougqh): not a blocker, but worth thinking through before this lands. Neither
For the automatic path ( But it cuts against the PR's own motivation: a short-lived job calling Worth considering wrapping the flush/shutdown future with |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
The tracer shutdown path starts the final export on a daemon thread but does not wait for it. The DDTracer wrapper also returns unavailable for both new lifecycle calls instead of forwarding them.
🤖 Datadog Autotest · Commit 1b4200c · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
💡 Codex Review
When CoreTracer.close() runs, especially from dd-tracer-shutdown-hook, this call now only enqueues finishShutdown and discards its future. The exporter uses a daemon AgentThreadFactory, so the JVM may terminate after the hook returns while the final send is still running; manual close likewise returns before sender.shutdown() completes. The previous implementation closed the sender synchronously, so wait for this future with a bounded timeout before returning.
ℹ️ 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".
1b4200c to
7e11776
Compare
|
@dougqh On the deadline question: the future intentionally has no built-in timeout. Callers can bound their wait with get(timeout, unit), which preserves Java 8 support and does not imply that the in-flight transport was cancelled. CoreTracer.close() now applies a 2.5-second bound. |
mabdinur
left a comment
There was a problem hiding this comment.
Reviewed the Datadog lifecycle implementation, addressed feedback, and focused tests. CI is green.
mcculls
left a comment
There was a problem hiding this comment.
We should avoid using CompletableFuture in a public trace/metrics API
I've suggested some alternatives in other comments
There was a problem hiding this comment.
A callback on one shutdown result can block completion of later shutdown results. This behavior breaks the repeated-call result contract.
🤖 Datadog Autotest · Commit cd8ab82 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
More details
The shutdown path returns separate views of one shared result. It exports the last metrics before it stops the sender and executor.
🤖 Datadog Autotest · Commit dc3deb9 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
What Does This Do
Adds a Datadog lifecycle extension to the OpenTelemetry
MeterProviderreturned byGlobalOpenTelemetry:shutdown()performs a final export and stops the Datadog OpenTelemetry metrics pipeline. Java does not expose a publicforceFlush()extension.DatadogMeterProvideris independent of the OpenTelemetry SDKSdkMeterProvider.Repeated calls observe the first shutdown result through isolated result views. A disabled or unavailable pipeline succeeds as a no-op. Existing internal metric flushing remains unchanged.
Motivation
Short-lived Java processes need a supported way to wait for pending custom metrics before exit. Exposing shutdown through the underlying meter provider keeps usage close to the OpenTelemetry API.
Tests
Contributor Checklist
Jira ticket: N/A