getsentry / sentry-go

The official Go SDK for Sentry (sentry.io)

Home Page:https://docs.sentry.io/platforms/go/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[otel] breaks sampling when used together with sentry middleware

costela opened this issue · comments

Summary

This is a follow-up to #678, which was closed before the actual issue got resolved.

When using the otel integration for tracing, but sentry for exceptions, the sentry middleware always starts a transaction, which is then "invisible" to the otel integration (regardless of middleware ordering; more info in #679) and causes sampling decisions to diverge.

Steps To Reproduce

Initialize otel with:

trace.NewTracerProvider(
	trace.WithSampler(trace.AlwaysSample()),
	trace.WithSpanProcessor(sentryotel.NewSentrySpanProcessor()),
)

Initialize sentry with:

sentry.ClientOptions{
	//...
	EnableTracing:    true,
	TracesSampleRate: 0.0,
	//...
}

All traces created with otel.Tracer("").Start() will have span.IsSampled() == true, but none of them will be sent to sentry.

Switching the to NeverSample()/TracesSampleRate: 1.0 causes the opposite problem.

Expected Behavior

Both stacks would agree on sampling.

Environment

SDK

  • sentry-go version: v0.27.0
  • Go version: 1.22
  • Using Go Modules? yes

Sentry

  • Using hosted Sentry in sentry.io? yes