Content-Length: 319740 | pFad | http://github.com/getsentry/sentry-javascript/pull/16714

7D feat(cloudflare): Allow interop with OpenTelemetry emitted spans by mydea · Pull Request #16714 · getsentry/sentry-javascript · GitHub
Skip to content

feat(cloudflare): Allow interop with OpenTelemetry emitted spans #16714

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 3 commits into from
Jun 25, 2025

Conversation

mydea
Copy link
Member

@mydea mydea commented Jun 24, 2025

While we eventually want to move the cloudflare SDK over to use OTEL fully under the hood, this PR is an attempt for an intermediate solution to allow us to still get access to e.g. the vercelAi integration, which emits spans via @opentelemetry/core.

For this, we register a custom trace provider in the cloudflare SDK which then just calls our own startSpan APIs. This should translate spans to Sentry spans. The only downside is that it does not handle a context being passed in for spans, so this will not work for all integrations and cases etc. But it should work for simple cases like the ai package using trace.startActiveSpan.

TODO: Test this, verify this makes sense, ...

@mydea mydea requested review from AbhiPrasad and andreiborza June 24, 2025 08:49
@mydea mydea self-assigned this Jun 24, 2025
@mydea mydea force-pushed the fn/cloudflare-trace-api branch from 3551025 to 79795e9 Compare June 24, 2025 08:56
@andreiborza andreiborza force-pushed the fn/cloudflare-trace-api branch from 79795e9 to a70e1fd Compare June 24, 2025 14:51
@andreiborza
Copy link
Member

I copied over the Vercel AI integration from our node SDK and modified it to remove the dep on @opentelemetry/instrumentation. Thus we don't have automatic forcing of experiment_telemetry: { isEnabled: true } with this integration, compared to the one in the node SDK but this is necessary, as @opentelemetry/instrumentation does not work on cloudflare workers.

Here's a sample trace with for vercel ai:
Screenshot 2025-06-24 at 16 19 34@2x

@andreiborza andreiborza force-pushed the fn/cloudflare-trace-api branch from a70e1fd to 4a84f6d Compare June 24, 2025 14:55
@mydea mydea force-pushed the fn/cloudflare-trace-api branch from 4a84f6d to 29f9e8e Compare June 25, 2025 10:06
@mydea
Copy link
Member Author

mydea commented Jun 25, 2025

@andreiborza I extracted the vercel AI change into a new PR, to keep this a bit easier to review/follow! :)

@mydea mydea marked this pull request as ready for review June 25, 2025 10:07
@mydea mydea merged commit 327594c into develop Jun 25, 2025
40 checks passed
@mydea mydea deleted the fn/cloudflare-trace-api branch June 25, 2025 11:03
mydea added a commit that referenced this pull request Jun 26, 2025
…16732)

This is on top of
#16714.

This adds the `vercelAiIntegration` to the cloudflare SDK, as well as to
the vercel-edge SDK.

I moved the critical code from node to core package, so we can reuse
this (the code to process spans).

The integration is not added by default, but needs to be added manually.
then it will "force" add the event processors etc. We cannot auto-detect
the `ai` package, sadly, because this does not work in workers 😢 so for
now it needs to be added manually to avoid overhead for users that don't
need this.

@andreiborza let's verify that this works when deployed to cloudflare,
esp. also the auto-enablement via the modules integration etc 🤔

---------

Co-authored-by: Andrei Borza <andrei.borza@sentry.io>
Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com>
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.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/getsentry/sentry-javascript/pull/16714

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy