Skip to content

chore(deps): bump @opentelemetry deps to v2.x#4933

Closed
JoshElias wants to merge 3 commits into
elastic:mainfrom
uCiC-app:chore/update-opentelemetry-v2
Closed

chore(deps): bump @opentelemetry deps to v2.x#4933
JoshElias wants to merge 3 commits into
elastic:mainfrom
uCiC-app:chore/update-opentelemetry-v2

Conversation

@JoshElias

@JoshElias JoshElias commented Jan 26, 2026

Copy link
Copy Markdown

Description

Update OpenTelemetry dependencies to v2.x and adapt code to the breaking API changes.

Summary

  • Update @opentelemetry/sdk-metrics from v1.x to v2.x
  • Update @opentelemetry/core to v2.x
  • Migrate from class-based aggregations to object-based AggregationOption API
  • Replace MeterProvider.addMetricReader() with constructor-based reader registration
  • Update test fixtures and examples to use v2.x API
  • Update documentation to reflect new API usage

Breaking Changes in OTel v2.x Addressed

  1. MeterProvider.addMetricReader() removed - Now pass readers via constructor options
  2. Aggregation classes removed (SumAggregation, LastValueAggregation, etc.) - Now use object-based { type: AggregationType.SUM } format
  3. Minimum Node.js version raised to ^18.19.0 || >=20.6.0 in OTel SDK

Checklist

  • Implement code
    - [ ] Add tests
    - [ ] Update TypeScript typings
  • Update documentation
    - [ ] Add release notes to docs/release-notes/index.md
  • Commit message follows commit guidelines

@JoshElias JoshElias requested a review from a team as a code owner January 26, 2026 16:43
@cla-checker-service

cla-checker-service Bot commented Jan 26, 2026

Copy link
Copy Markdown

💚 CLA has been signed

@github-actions

Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions

Copy link
Copy Markdown

🔍 Preview links for changed docs

@JoshElias

Copy link
Copy Markdown
Author

❌ Author of the following commits did not sign a Contributor Agreement: 25a8bdf, 129899d, 274e44e

Please, read and sign the above mentioned agreement if you want to contribute to this project

I have since signed this.

@JoshElias

Copy link
Copy Markdown
Author

Happy to make any required changes to fit your standards!

@JoshElias

Copy link
Copy Markdown
Author

I just noticed that my auto formatter was a bit aggressive in the .md and .js files. I'll clean that noise out.

@JoshElias JoshElias changed the title chore(deps): update OpenTelemetry SDK to v2.x chore(deps): update @opentelemetry deps to v2.x Jan 27, 2026
@JoshElias JoshElias changed the title chore(deps): update @opentelemetry deps to v2.x chore(deps): bump @opentelemetry deps to v2.x Jan 27, 2026
@trentm

trentm commented Jul 6, 2026

Copy link
Copy Markdown
Member

@JoshElias Thank you very much for this PR and I'm sorry I haven't responded until now. I'm starting to take a look now.

I'm curious about your use case for the OpenTelemetry Bridge in elastic-apm-node.

The feature is an experimental one in the Node.js APM agent. Since it was initially added, we've focused on OTel-native equivalent agents: e.g. Elastic's distribution of the OTel Node.js SDK (https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/node, @elastic/opentelemetry-node) or the upstream OpenTelemetry Node.js SDK (https://opentelemetry.io/docs/languages/js/, https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-sdk-node/README.md) and, on the server-side, OTLP ingest endpoints and processing.

I would expect for OTel-related observability usage that your experience would be much better using an OTel-native app-side agent/SDK and Elastic's OpenTelemetry ingest path. However, I'd love to hear about your usage and experiences.

@trentm

trentm commented Jul 7, 2026

Copy link
Copy Markdown
Member

This work is covered by #5126 which was just merged (but no release with this yet).

@JoshElias I'm still interested in your use case and experiences, as I asked above.

@trentm trentm closed this Jul 7, 2026
@JoshElias

Copy link
Copy Markdown
Author

@JoshElias I'm still interested in your use case and experiences, as I asked above.

Hey no problem @trentm. You can read about my use case in the issue I raised for this before creating the pr.

TLDR; There was a peer dependency conflict with @langfuse/otel that required @opentelemetry/core v2 to resolve.

We've been using my fork in meantime at my org. Was really hoping this would be my first useful OSS contribution. Been doing this for many years and still don't have any :(.

Would be great to use the official branch though.

Thanks for taking a look! :)

@trentm

trentm commented Jul 8, 2026

Copy link
Copy Markdown
Member

Was really hoping this would be my first useful OSS contribution. Been doing this for many years and still don't have any :(.

I'm sorry for that. I used the other PR as the basis for my additions only because of a few minor differences. I did credit your name and PR in the release notes. I hope that counts, or acts as consolation.

You can read about my use case in the issue I raised for this before creating the pr.

Ah, I missed the connection to that issue... largely because I took so long to get to this PR.
Thanks for getting back.

Have you considered using our @elastic/opentelemetry-node (OTel-native) distro/agent/SDK? (Repo: https://github.com/elastic/elastic-otel-node/tree/main/packages/opentelemetry-node#readme, Docs: https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/node)
There is some effort require to migrate from elastic-apm-node to that, but it does track the latest OpenTelemetry JS closely and so should integrate better with Langfuse instrumentation, IIUC.

@JoshElias

Copy link
Copy Markdown
Author

@trentm Oh that's super cool regarding the other lib. I will raise that with the team. No worries on the credit. I'm glad I got to talk to a maintainer! Thank you.

@trentm

trentm commented Jul 9, 2026

Copy link
Copy Markdown
Member

FYI: elastic-apm-node@4.18.0 is out with the upgrade to OTel SDK 2.x libs (#5137).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants