Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/content/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default withMermaid(defineConfig({
{ text: 'Hey API', link: '/docs/integrations/hey-api' },
{ text: 'OpenTelemetry', link: '/docs/integrations/opentelemetry' },
{ text: 'Pinia Colada', link: '/docs/integrations/pinia-colada' },
{ text: 'Sentry', link: '/docs/integrations/sentry' },
{ text: 'Tanstack Query', link: '/docs/integrations/tanstack-query' },
{
text: 'Tanstack Query (Old)',
Expand Down
83 changes: 83 additions & 0 deletions apps/content/docs/integrations/sentry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Sentry Integration
description: Integrate oRPC with Sentry for error tracking and performance monitoring.
---

# Sentry Integration

[Sentry](https://sentry.io/) is a powerful tool for error tracking and performance monitoring. This guide explains how to integrate oRPC with Sentry to capture errors and performance metrics in your applications.

::: warning
This guide assumes familiarity with [Sentry](https://sentry.io/). Review the official documentation if needed.
:::

::: info
This integration is based on the [OpenTelemetry Integration](/docs/integrations/opentelemetry), so you can refer to that guide for more details on setting up OpenTelemetry with oRPC.
:::

## Installation

::: code-group

```sh [npm]
npm install @orpc/otel@latest
```

```sh [yarn]
yarn add @orpc/otel@latest
```

```sh [pnpm]
pnpm add @orpc/otel@latest
```

```sh [bun]
bun add @orpc/otel@latest
```

```sh [deno]
deno install npm:@orpc/otel@latest
```

:::

## Setup

To set up OpenTelemetry with oRPC, use the `ORPCInstrumentation` class. This class automatically instruments your oRPC client and server for distributed tracing.

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

Sentry.init({
dsn: '...',
sendDefaultPii: true,

tracesSampleRate: 1.0, // enable tracing [!code highlight]

openTelemetryInstrumentations: [
new ORPCInstrumentation(), // [!code highlight]
]
})
```

## Capturing Errors

Since Sentry does not yet support collecting [OpenTelemetry span events](https://opentelemetry.io/docs/concepts/signals/traces/#span-events), you should capture errors that occur in business logic manually. You can use `interceptors`, `middleware`, or other error handling mechanisms.

```ts twoslash
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) // [!code highlight]
throw error
}
})

export const base = os.use(sentryMiddleware)
```
1 change: 1 addition & 0 deletions apps/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@orpc/vue-query": "workspace:*",
"@orpc/zod": "workspace:*",
"@pinia/colada": "^0.17.1",
"@sentry/node": "^10.3.0",
"@shikijs/vitepress-twoslash": "^3.9.0",
"@tanstack/react-query": "^5.83.0",
"@tanstack/solid-query": "^5.83.0",
Expand Down
161 changes: 153 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.