sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Option to ignore specific Postgres (`pg`) spans

Open Lms24 opened this issue 7 months ago • 1 comments

Problem Statement

Extracted from https://github.com/getsentry/sentry-javascript/issues/16505#issuecomment-2954260527, we should find a way to ignore certain spans emitted from the OTel pg instrumentation. For example, the pg-pool.connect spans.

Solution Brainstorm

Right now, I don't think there is a way to achieve this, given that the pg instrumentation from OTel used in our postgresIntegration doesn't expose an option for (not) starting connect spans. Which means we'll likely need to contribute this upstream or vendor-in the pg instrumentation (with pg already being Otel v2 compatible, we'd likely need to vendor-in anyway).

Lms24 avatar Jun 10 '25 17:06 Lms24

This was already requested in https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2017 and we might be able to use the workaround: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2017#issuecomment-2167817925

Lms24 avatar Jun 10 '25 17:06 Lms24

@Lms24 I have a clarification question on this. A customer raised the problem that they're attempting to use ignoreSpans in their express app on pg-pool.connect spans, using this syntax:

ignoreSpans: [
      /pg-pool\.connect/,
]

(SDK version: sentry.javascript.node 9.13.0)

I'd expect these spans to be ignored, but the customer is seeing them still:

Image

Is the reason they're still showing up related to the fact that these are auto-instrumented by the OTel pg instrumentation?

cstavitsky avatar Sep 17 '25 18:09 cstavitsky

(SDK version: sentry.javascript.node 9.13.0)

ignoreSpans was introduced in 10.2.0. I recommend upgrading and trying again. I opened https://github.com/getsentry/sentry-docs/pull/14971 to clarify the required version in docs.

Lms24 avatar Sep 18 '25 07:09 Lms24