Skip to content

Sentry-related spans are appearing in dns/net opentelemetry traces #13466

Closed
@Bruno-DaSilva

Description

@Bruno-DaSilva

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.26.0

Framework Version

Node 20.12.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
    dsn: process.env.SENTRY_DSN,
    skipOpenTelemetrySetup: true
  });
// We want 100% sample rate but without telling sentry to init tracing (rolling our own tracing, using sentry for errors only).
export class CustomSentrySampler implements Sampler {
  shouldSample(
    context: Context,
    _traceId: string,
    _spanName: string,
    _spanKind: SpanKind,
    attributes: SpanAttributes,
    _links: Link[],
  ) {
    const decision = SamplingDecision.RECORD_AND_SAMPLED;

    // wrap the result, necessary for sentry
    return SentryOtel.wrapSamplingDecision({
      decision,
      context,
      spanAttributes: attributes,
    });
  }

  toString() {
    return CustomSentrySampler.name;
  }
}

// can use SentrySampler if you init sentry with sample rate instead
const provider = new NodeTracerProvider({ sampler: new CustomSentrySampler(), }); 
// Only required if you are sending traces up to sentry
// provider.addSpanProcessor(new SentrySpanProcessor());
// an alternative exporter if you don't want to send traces to sentry
provider.addSpanProcessor(new OTLPTraceExporter({
  url: TRACING_EXPORTER_URL,
}));

const propagator = SentryPropagator();
const contextManager = SentryContextManager();

// register additional instrumentations outside of what sentry uses by default.
// For this bug report, just adding net/dns instrumentations.
registerInstrumentations({
  tracerProvider: provider,
  instrumentations: [
    new NetInstrumentation(),
    new DnsInstrumentation(),
  ],
});
provider.register({ propagator, contextManager });

Steps to Reproduce

  1. Setup SDK as above
  2. Run the app, hit an endpoint that triggers a captureException or captureMessage
  3. Check the trace for this request

Expected Result

The trace should NOT have any sentry related spans in it

Actual Result

Despite the @opentelemetry/instrumentation-http ignoring (not creating spans for) the sentry outgoing requests, the dns and net instrumentations still appear in the trace:
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions