Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry Profiling Integration doesn't work #102

Open
tillpd opened this issue Dec 13, 2022 · 8 comments
Open

Sentry Profiling Integration doesn't work #102

tillpd opened this issue Dec 13, 2022 · 8 comments

Comments

@tillpd
Copy link

tillpd commented Dec 13, 2022

This is the suggested configuration from the docs:

import * as Sentry from "@sentry/node";
// NOTE: @sentry/tracing should be imported before @sentry/profiling-node
import "@sentry/tracing";
import {ProfilingIntegration} from "@sentry/profiling-node";

Sentry.init({
  // ... SDK config
  integrations: [
    // add profiling integration
    new ProfilingIntegration()
  ]
  profilesSampleRate: 1.0,
});

This is my module configuration:

   SentryModule.forRoot({
      enabled: true,
      dsn: process.env.SENTRY_DSN,
      logLevels: ['debug'],
      debug: true,
      integrations: [new ProfilingIntegration()],
      // @ts-ignore
      profilesSampleRate: 1.0,
    }),

Profiling doesn't work and profilesSampleRate produces a type error.

@svachmic
Copy link

This seems to be a problem with all integrations. I get type error since @nestjs version 9.2.1 and @sentry version 7.26.0.

Versions 9.1.6 and 7.17.2 work fine.

The problem is probably somewhere between NestJS -> ntegral -> Sentry.

@StPaulis
Copy link

StPaulis commented Feb 9, 2023

Any news about that? I can confirm that the problem exists in 7.36.0 also.

@yepMad
Copy link

yepMad commented Mar 25, 2023

@sentry/tracing not working either? Or it's the same package?

@AdamGerthel
Copy link

@sentry/tracing not working either? Or it's the same package?

According to the Sentry docs for NodeJS, tracing is already enabled: https://docs.sentry.io/platforms/node/performance/#enable-tracing

@AdamGerthel
Copy link

Has anyone managed to solve this issue?

@StPaulis
Copy link

StPaulis commented Oct 27, 2023

Has anyone managed to solve this issue?

I end up using the plain @sentry package.

I forked a repository with a generic nestjs implementation and develop this to support tracing.

@ossamaweb
Copy link

It appears that SentryService gets initiated twice. And because of that Sentry.init gets called twice also.

Screen Shot 2024-01-23 at 23 42 49

A workaround:

  1. Add fromFactory guard in sentry.service.ts constructor to initiate Sentry.
constructor(
    @Inject(SENTRY_MODULE_OPTIONS)
    readonly opts?: SentryModuleOptions,
    readonly fromFactory?: boolean
  ) {
    super();
   ...
   if (fromFactory) {  // <-- here
      Sentry.init(opts);
    }
  ...
}
  1. Add it to the Service instantiation in forRootAsync/ forRoot in sentry-core.module.ts
public static forRootAsync(options: SentryModuleAsyncOptions): DynamicModule {
    const provider: Provider = {
      inject: [SENTRY_MODULE_OPTIONS],
      provide: SENTRY_TOKEN,
      useFactory: (options: SentryModuleOptions) =>
        new SentryService(options, true), // <-- here
    };
   ...
}

@ossamaweb
Copy link

Has anyone managed to solve this issue?

@AdamGerthel @StPaulis check my workaround above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants