FoalTS / foal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
https://foalts.org/
MIT License
1.88k stars 137 forks source link

Unable to integrate sentry performance monitoring and profiling with Foal TS #1248

Open premji012 opened 3 months ago

premji012 commented 3 months ago

Version of FoalTS: 4.2.0

I was recently trying to integrate sentry Performance monitoring and profiling with a Foal TS based application. I used the same logic that we use to integrate sentry APM with an express application. It is working well with express but if i use the same techinique in Foal TS it is not working

  const expressInstance = express();

  const app = await createApp(AppController);

  Sentry.init({
    dsn: ***',
    tracesSampleRate: 1.0,
    profilesSampleRate: 1.0, // Profiling sample rate is relative to tracesSampleRate
    // includeLocalVariables: true,
    integrations: [
      // enable HTTP calls tracing
      new Sentry.Integrations.Http({ tracing: true }),
      new Sentry.Integrations.Express({ app: expressInstance }),
      // // Automatically instrument Node.js libraries and frameworks
      // // (This function is slow because of file I/O, consider manually adding additional integrations instead)
      //...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
      // Add profiling integration to list of integrations
      new ProfilingIntegration(),
      // new Sentry.Integrations.LocalVariables({ captureAllExceptions: true })
    ],
  });

  expressInstance.use(Sentry.Handlers.requestHandler());
  expressInstance.use(Sentry.Handlers.tracingHandler());
  expressInstance.use(Sentry.Handlers.errorHandler())
LoicPoullain commented 3 months ago

Hi @premji012 👋

It looks like you didn't pass the expressInstance to the createApp function, right?

Also, I'm not very familiar with Sentry. Do you know what are the three middlewares used for?