@@ -46,11 +46,11 @@ func (ssp *sentrySpanProcessor) OnStart(parent context.Context, s otelSdkTrace.R
46
46
47
47
sentrySpanMap .Set (otelSpanID , span )
48
48
} else {
49
- traceParentContext := getTraceParentContext (parent )
49
+ sampled := getSampled (parent , s )
50
50
transaction := sentry .StartTransaction (
51
51
parent ,
52
52
s .Name (),
53
- sentry .WithSpanSampled (traceParentContext . Sampled ),
53
+ sentry .WithSpanSampled (sampled ),
54
54
)
55
55
transaction .SpanID = sentry .SpanID (otelSpanID )
56
56
transaction .TraceID = sentry .TraceID (otelTraceID )
@@ -112,12 +112,17 @@ func flushSpanProcessor(ctx context.Context) error {
112
112
return nil
113
113
}
114
114
115
- func getTraceParentContext (ctx context.Context ) sentry.TraceParentContext {
115
+ func getSampled (ctx context.Context , s otelSdkTrace. ReadWriteSpan ) sentry.Sampled {
116
116
traceParentContext , ok := ctx .Value (sentryTraceParentContextKey {}).(sentry.TraceParentContext )
117
- if ! ok {
118
- traceParentContext .Sampled = sentry . SampledUndefined
117
+ if ok {
118
+ return traceParentContext .Sampled
119
119
}
120
- return traceParentContext
120
+
121
+ if s .SpanContext ().IsSampled () {
122
+ return sentry .SampledTrue
123
+ }
124
+
125
+ return sentry .SampledFalse
121
126
}
122
127
123
128
func updateTransactionWithOtelData (transaction * sentry.Span , s otelSdkTrace.ReadOnlySpan ) {
0 commit comments