1212import io .opentelemetry .sdk .trace .export .SpanExporter ;
1313import io .opentelemetry .semconv .HttpAttributes ;
1414import io .opentelemetry .semconv .incubating .ProcessIncubatingAttributes ;
15+ import io .opentelemetry .semconv .incubating .ThreadIncubatingAttributes ;
1516import io .sentry .Baggage ;
1617import io .sentry .DateUtils ;
1718import io .sentry .DefaultSpanFactory ;
@@ -339,6 +340,7 @@ private void transferSpanDetails(
339340 setOtelInstrumentationInfo (span , sentryTransaction );
340341 setOtelSpanKind (span , sentryTransaction );
341342 transferSpanDetails (sentrySpanMaybe , sentryTransaction );
343+ maybeTransferOtelThreadAttributes (span , sentryTransaction );
342344
343345 scopesToUse .configureScope (
344346 ScopeType .CURRENT ,
@@ -347,6 +349,19 @@ private void transferSpanDetails(
347349 return sentryTransaction ;
348350 }
349351
352+ private void maybeTransferOtelThreadAttributes (
353+ final @ NotNull SpanData span , final @ NotNull ITransaction sentryTransaction ) {
354+ final @ NotNull Attributes attributes = span .getAttributes ();
355+ final @ Nullable Long threadId = attributes .get (ThreadIncubatingAttributes .THREAD_ID );
356+ if (threadId != null ) {
357+ sentryTransaction .setData (ThreadIncubatingAttributes .THREAD_ID .getKey (), threadId );
358+ }
359+ final @ Nullable String threadName = attributes .get (ThreadIncubatingAttributes .THREAD_NAME );
360+ if (threadName != null ) {
361+ sentryTransaction .setData (ThreadIncubatingAttributes .THREAD_NAME .getKey (), threadName );
362+ }
363+ }
364+
350365 private List <SpanNode > findCompletedRootNodes (final @ NotNull List <SpanNode > grouped ) {
351366 final @ NotNull Predicate <SpanNode > isRootPredicate =
352367 (node ) -> {
0 commit comments