You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nestjs supports websocket gateway. It would be nice to have built in tracing interceptor like sentry has for http requests
Solution Brainstorm
This is implementation which we wrote in our project
import{CallHandler,ExecutionContext,NestInterceptor}from'@nestjs/common';import*asSentryfrom'@sentry/core';import{Observable}from'rxjs';import{tap}from'rxjs';exportclassSentryWsTracingInterceptorimplementsNestInterceptor{/** * Intercepts WS requests to set the transaction name for Sentry tracing. */publicintercept(context: ExecutionContext,next: CallHandler,): Observable<unknown>{if(context.getType()==='ws'){constclient=context.switchToWs().getClient();constpattern=context.switchToWs().getPattern();Sentry.getIsolationScope().setTransactionName(`WS ${client.nsp.name}${pattern}`,);returnSentry.startSpanManual({op: 'ws',name: `WS ${client.nsp.name}${pattern}`,},(span)=>{returnnext.handle().pipe(tap({finalize: ()=>span.end(),}),);},);}returnnext.handle();}}
Product Area
Profiling
The text was updated successfully, but these errors were encountered:
Hi @CSenshi, thank you – sounds like a reasonable improvement. But I would suggest we include this functionality in the existing SentryTracingInterceptor. I put this on our list of improvements for nestjs
Problem Statement
Nestjs supports websocket gateway. It would be nice to have built in tracing interceptor like sentry has for http requests
Solution Brainstorm
This is implementation which we wrote in our project
Product Area
Profiling
The text was updated successfully, but these errors were encountered: