Skip to content

feat(opentelemetry): Widen peer dependencies to support Otel v2 #16246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 12, 2025

Conversation

andreiborza
Copy link
Member

@andreiborza andreiborza commented May 9, 2025

In preparation for supporting OpenTelemetry v2 we widened the peer dependency range of @sentry/opentelemetry to allow v2 dependencies.

Note: @sentry/node still requires the v1 packages of OpenTelemetry, this is just preparatory work to allow us to bump this down the road.

Parts of @sentry/opentelemetry (and @sentry/core) have been reworked to be compatible with both OpenTelemetry v1 and v2.

Unit tests in @sentry/opentelemetry are running with v1 dependencies while a new package was added to dev-packages/ with a copy of all unit tests from @sentry/opentelemetry to run with v2 dependencies, adjusted to breaking changes introduced with OpenTelemetry v2.

@andreiborza andreiborza requested a review from onurtemizkan May 9, 2025 18:44
Copy link
Contributor

github-actions bot commented May 9, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.38 KB +0.08% +17 B 🔺
@sentry/browser - with treeshaking flags 23.21 KB +0.08% +18 B 🔺
@sentry/browser (incl. Tracing) 37.27 KB +0.06% +21 B 🔺
@sentry/browser (incl. Tracing, Replay) 74.5 KB +0.04% +24 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.36 KB +0.03% +17 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 79.15 KB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 90.96 KB +0.02% +18 B 🔺
@sentry/browser (incl. Feedback) 39.77 KB +0.05% +17 B 🔺
@sentry/browser (incl. sendFeedback) 28 KB +0.06% +17 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.77 KB +0.06% +17 B 🔺
@sentry/react 25.19 KB +0.08% +19 B 🔺
@sentry/react (incl. Tracing) 39.26 KB +0.05% +17 B 🔺
@sentry/vue 27.65 KB +0.07% +19 B 🔺
@sentry/vue (incl. Tracing) 39.03 KB +0.05% +18 B 🔺
@sentry/svelte 23.41 KB +0.09% +21 B 🔺
CDN Bundle 24.58 KB +0.09% +21 B 🔺
CDN Bundle (incl. Tracing) 37.32 KB +0.05% +16 B 🔺
CDN Bundle (incl. Tracing, Replay) 72.36 KB +0.02% +13 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 77.66 KB +0.02% +13 B 🔺
CDN Bundle - uncompressed 71.72 KB +0.11% +76 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 110.44 KB +0.07% +76 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 221.73 KB +0.04% +76 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 234.25 KB +0.04% +76 B 🔺
@sentry/nextjs (client) 40.87 KB +0.05% +19 B 🔺
@sentry/sveltekit (client) 37.76 KB +0.05% +18 B 🔺
@sentry/node 155.28 KB +0.66% +1.02 KB 🔺
@sentry/node - without tracing 95.82 KB -0.15% -140 B 🔽
@sentry/aws-serverless 121.34 KB +0.86% +1.02 KB 🔺

View base workflow run

@andreiborza andreiborza linked an issue May 9, 2025 that may be closed by this pull request
@andreiborza andreiborza force-pushed the ab/sentry-otel-widen-deps branch 2 times, most recently from 7bd99e1 to 5cff48b Compare May 9, 2025 21:34
@andreiborza andreiborza marked this pull request as ready for review May 9, 2025 22:04
@andreiborza andreiborza requested review from mydea, Lms24 and chargome and removed request for Lms24 May 9, 2025 22:04
@@ -751,6 +754,42 @@ jobs:
directory: dev-packages/node-integration-tests
token: ${{ secrets.CODECOV_TOKEN }}

job_opentelemetry_v2_tests:
Copy link
Member

Choose a reason for hiding this comment

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

h: do we need this? Can we not just run this normally through the node unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yea maybe that would make it easier to revert the change too. I'll update.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed and instead relying on node unit tests.

// looking up the parent span id according to the new API
// In OTel v1, the parent span id is accessed as `parentSpanId`
// In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`
const parentSpanId =
Copy link
Member

Choose a reason for hiding this comment

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

l: Can we use the getParentSpanId() util here too? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about that but then I'd need to pull it into core which means more api surface? I preferred not to, but can change if you think that's better?

Copy link
Member

Choose a reason for hiding this comment

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

ah right, other package - all good then!

@andreiborza andreiborza force-pushed the ab/sentry-otel-widen-deps branch from 68950bf to 5b8503d Compare May 12, 2025 11:54
await spanProcessor.forceFlush();
}

await provider?.forceFlush();
Copy link
Member

Choose a reason for hiding this comment

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

Has this changed for both api versions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, this was already supported in v1.

Copy link
Member Author

Choose a reason for hiding this comment

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

@andreiborza andreiborza merged commit d273046 into develop May 12, 2025
157 checks passed
@andreiborza andreiborza deleted the ab/sentry-otel-widen-deps branch May 12, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make @sentry/opentelemetry compatible with OTEL v2
4 participants