trpcMiddleware
Capture spans & errors for tRPC handlers.
This integration only works inside server environments (Node.js, Bun, Deno).
Import name: Sentry.trpcMiddleware
The Sentry tRPC middleware creates spans for you and improves error capturing for tRPC handlers.
The trpcMiddleware
is not a traditional SDK integration in the sense that your are not supposed to add it to the integrations
option. Instead, add it as a middleware to your tRPC router.
Copied
import * as Sentry from "@sentry/node";
import { initTRPC } from "@trpc/server";
const t = initTRPC.context().create();
const sentryMiddleware = t.middleware(
Sentry.trpcMiddleware({
attachRpcInput: true,
}),
);
const sentrifiedProcedure = t.procedure.use(sentryMiddleware);
Type: boolean
Defaults to false
. If enabled, the RPC input will be captured in reported events.
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").