Skip to content

Export vercel ai sdk span modifier to be used with custom OTEL exporter #106244

@Yuripetusko

Description

@Yuripetusko

Problem Statement

We run most of our ai calls from trigger.dev, and they register global OpenTelemetry which you can't change. The only way to add Sentry traces there is through a custom exporter

const sentryOtelExporter = new OTLPTraceExporter({
  url: process.env.SENTRY_OTLP_TRACES_ENDPOINT,
  headers: {
    'x-sentry-auth': process.env.SENTRY_OTLP_AUTH_HEADER ?? '',
  },
})

However this then ignores any custom integrations like vercelAIIntegration so the spans are sent, but with original ai sdk span names and not the normalized names that Sentry expects to be able to show in AI insights

Solution Brainstorm

Export a function that is used by sentry vercelAIIntegration internally that modifies ai sdk spans to normalize them for ai insights. Or support ai-sdk spans in AI insights

Product Area

Insights

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Support

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions