oRPC Sentry Integration

Integrate oRPC with Sentry for error tracking and performance monitoring.

SKILL.md

GitHub

Sentry Integration

Based on the OpenTelemetry Integration.

Installation

npm install @orpc/otel@latest

Setup

import * as Sentry from '@sentry/node'
import { ORPCInstrumentation } from '@orpc/otel'

Sentry.init({
  dsn: '...',
  sendDefaultPii: true,
  tracesSampleRate: 1.0,
  openTelemetryInstrumentations: [
    new ORPCInstrumentation(),
  ]
})

Capturing Errors

Since Sentry does not yet collect OpenTelemetry span events, capture errors from business logic manually:

import * as Sentry from '@sentry/node'
import { os } from '@orpc/server'

export const sentryMiddleware = os.middleware(async ({ next }) => {
  try {
    return await next()
  } catch (error) {
    Sentry.captureException(error)
    throw error
  }
})

export const base = os.use(sentryMiddleware)