feat(cloudflare): Allow interop with OpenTelemetry emitted spans #16714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 acontext
being passed in for spans, so this will not work for all integrations and cases etc. But it should work for simple cases like theai
package usingtrace.startActiveSpan
.TODO: Test this, verify this makes sense, ...