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 Postgres Integration does not detect database events #9431

Closed
RodoVJ opened this issue Nov 1, 2023 · 12 comments
Closed

Sentry Postgres Integration does not detect database events #9431

RodoVJ opened this issue Nov 1, 2023 · 12 comments

Comments

@RodoVJ
Copy link

RodoVJ commented Nov 1, 2023

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

My team wants to use the Sentry Postgres integration to monitor the performance of our database. We are using Postgres as our database and use Typeorm as our ORM to make database operations.

How are you getting stuck?

Sentry does not seem to pick up any activity coming from Postgres and we don't see any metrics related to it. Is the reason Sentry can't pick up activity coming form Postgres because we are using Typeorm to interact with Postgres? If that's the case, is there a way to get around this issue? We introduced other automatic integrations (GraphQL and Express) and those are working fine.

Where in the product are you?

Performance

Link

No response

DSN

No response

Version

No response

@getsantry
Copy link

getsantry bot commented Nov 1, 2023

Assigning to @getsentry/support for routing ⏲️

@getsantry
Copy link

getsantry bot commented Nov 1, 2023

Routing to @getsentry/product-owners-performance for triage ⏲️

@mjq-sentry
Copy link

Hi @RodoVJ, thanks for writing in! We don't have a direct integration with TypeORM, but it looks like it uses the pg library for its Postgres support, so I'd expect that to work. I'm going to transfer this issue to the SDK for that team to take a look.

@mjq-sentry mjq-sentry transferred this issue from getsentry/sentry Nov 1, 2023
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 1, 2023
@AbhiPrasad
Copy link
Member

Hey @RodoVJ thanks for writing in! If you supply the debug: true attribute to your Sentry.init and use the sentry postgres integration, what gets logged out?

@RodoVJ
Copy link
Author

RodoVJ commented Nov 1, 2023

Hi @AbhiPrasad, thank you for your response!

When our app first starts up, I get the following with debug: true:

Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: Undici
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: LocalVariables
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: Express
Sentry Logger [log]: Integration installed: Apollo
Sentry Logger [log]: Integration installed: GraphQL
Sentry Logger [log]: Integration installed: Postgres
Sentry Logger [log]: Integration installed: CaptureConsole

When I perform an action that triggers a GET call to our API that uses Postgres, I get several of the following console logs:
(I couldn't spot any Postgres related events)

Sentry Logger [log]: [Tracing] starting http.server transaction - POST /graphql
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Finishing 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'POST /graphql' ().
Sentry Logger [log]: [Tracing] Adding sentry-trace header <manually removed it for privacy> to outgoing request to <manually removed it for privacy>:
Sentry Logger [log]: [Tracing] Finishing 'http.client' span on transaction 'POST /graphql' (82edce63fe913792).
Sentry Logger [log]: [Tracing] Finishing 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Finishing 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Finishing 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Finishing 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
Sentry Logger [log]: [Tracing] Starting 'middleware.express.use' span on transaction 'POST /graphql' (<manually removed it for privacy>).
--- AFTER 'Team' LOADED: <manually removed it for privacy>
Sentry Logger [log]: [Tracing] Starting 'graphql.execute' span on transaction 'POST /graphql' (<manually removed it for privacy>).

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 1, 2023
@AbhiPrasad
Copy link
Member

I'm looking for logs like so:

__DEBUG_BUILD__ && logger.error('Postgres Integration was unable to require `pg` package.');
return;
}
const Client = this._usePgNative ? pkg.native?.Client : pkg.Client;
if (!Client) {
__DEBUG_BUILD__ && logger.error("Postgres Integration was unable to access 'pg-native' bindings.");

that tell us the pg module is unable to be required.

what version of the SDK are you on? Can you provide a copy of your Sentry.init config?

@RodoVJ
Copy link
Author

RodoVJ commented Nov 1, 2023

I can't seem to find a similar message to "Postgres Integration was unable to access 'pg-native' bindings." in the logs that are printed. The version of our node SDK is 7.77.0

And for sure! This is our Sentry.init:

  Sentry.init({
    dsn: sentryDsn,
    debug: true,
    integrations: [
      new Sentry.Integrations.Http({ tracing: true }),
      new Sentry.Integrations.Express({ app }),
      new Sentry.Integrations.Apollo(),
      new Sentry.Integrations.GraphQL(),
      new Sentry.Integrations.Postgres(),
      new CaptureConsole({ levels: ['error'] }),
    ],

    tracesSampleRate: environment.production ? 0.2 : 1.0,
  });

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 1, 2023
@RodoVJ
Copy link
Author

RodoVJ commented Nov 1, 2023

@AbhiPrasad I set the option usePgNative of the Postgres integration to true and it is now working. I didn't realize our TypeOrm connection is using pg-native. I will close the ticket but I very much appreciate your help!

@mrZedov
Copy link

mrZedov commented Jan 2, 2024

I use MikroORM and I have the same problem. I don't see anything happening in Postgres. I use it like this:

   Sentry.init({
     dsn: process.env.SENTRY_DNS,
     integrations: [
       new ProfilingIntegration(),
       new Sentry.Integrations.Http({tracing: true}),
       new Sentry.Integrations.Postgres({   usePgNative: true  }),
       // ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
     ],
     tracesSampleRate: 1.0,
     profilesSampleRate: 1.0,
   });

Even using autoDiscoverNodePerformanceMonitoringIntegrations doesn't change anything
I would really appreciate any help )

@AbhiPrasad
Copy link
Member

Hey @mrZedov could you open a new GH issue and fill out the template? Would also be super helpful if you can add debug: true to your SDK config and paste the output. This will help us debug further. Thanks!

@souterjk
Copy link

souterjk commented May 28, 2024

@AbhiPrasad any chance there is documentation for what to use instead of usePgNative in sentry v8? Google and Github sent me here for typeorm/sentry problems, and this looks like a great fix, but its no longer available on the postgres integration in v8 as far as I can tell.

@AbhiPrasad
Copy link
Member

For v8 the SDK uses OpenTelemetry, so the mechanisms for instrumentation are completely different. Let's see if we can figure it out in #12265!

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

No branches or pull requests

5 participants