-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Problem Statement
It would make it easier to debug if I can see which trpc route is causing an issue. The current trpc route only add procedure type and input to the context.
Solution Brainstorm
Simply add path to trpc context in this function would likely work?
sentry-javascript/packages/core/src/trpc.ts
Lines 41 to 94 in 984a6bd
export function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) { | |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
// @ts-ignore | |
return async function <T>(opts: SentryTrpcMiddlewareArguments<T>): SentryTrpcMiddleware<T> { | |
const { path, type, next, rawInput, getRawInput } = opts; | |
const client = getClient(); | |
const clientOptions = client && client.getOptions(); | |
const trpcContext: Record<string, unknown> = { | |
procedure_type: type, | |
}; | |
if (options.attachRpcInput !== undefined ? options.attachRpcInput : clientOptions && clientOptions.sendDefaultPii) { | |
if (rawInput !== undefined) { | |
trpcContext.input = normalize(rawInput); | |
} | |
if (getRawInput !== undefined && typeof getRawInput === 'function') { | |
try { | |
const rawRes = await getRawInput(); | |
trpcContext.input = normalize(rawRes); | |
} catch (err) { | |
// noop | |
} | |
} | |
} | |
setContext('trpc', trpcContext); | |
return startSpanManual( | |
{ | |
name: `trpc/${path}`, | |
op: 'rpc.server', | |
attributes: { | |
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | |
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.rpc.trpc', | |
}, | |
}, | |
async span => { | |
try { | |
const nextResult = await next(); | |
captureIfError(nextResult); | |
span.end(); | |
return nextResult; | |
} catch (e) { | |
captureException(e, trpcCaptureContext); | |
span.end(); | |
throw e; | |
} | |
}, | |
) as SentryTrpcMiddleware<T>; | |
}; | |
} |
Metadata
Metadata
Assignees
Projects
Status
No status