Skip to content

Sentry slowing down DB queries #18552

@raymondhechen

Description

@raymondhechen

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node - express

SDK Version

10.29.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

@sentry/node >= 10.29.0 when using postgres and drizzle-orm results in DB query latency increases. Increase at ~1pm reflects this. Below charts show duration of spans that wrap drizzle queries.

Image

I've tested with every version >= 10.29.0, none of which resolve this issue. 10.28.0 is fine. Also it seems that the versions with errors seem to break some postgres instrumentation? (below images are directly from db spans)

Image

Any ideas what the issue might be? For some context: we're computing the first image's charts spans like this:

export const withServerTrace = async <T>(
  { name, op = 'service', attributes }: ServerSpanArgs,
  fn: (span: Sentry.Span) => Promise<T> | T
): Promise<T> => {
  return Sentry.startSpan({ name, op, attributes }, async (span) => {
    try {
      return await fn(span)
    } catch (err) {
      span.setStatus({ code: 2, message: 'internal_error' })
      Sentry.captureException(err)
      throw err
    }
  })
}

And here's an example usage with drizzle-orm:

export const getChat = async ({ chatId }: { chatId: string }) => {
  return await withServerTrace(
    { name: 'getChat', op: 'api.query' },
    async () => {
      return await db.query.chats.findFirst({
        where: (chats, { eq }) => eq(chats.id, chatId),
      })
    }
  )
}

Expected Result

No DB query latency increases.

Actual Result

DB query latency increasing.

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions