Skip to content

Commit dd449bf

Browse files
authored
Merge 9ca2c5b into 98f55ae
2 parents 98f55ae + 9ca2c5b commit dd449bf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Session Replay: Do not capture current replay for cached events from the past ([#4474](https://github.com/getsentry/sentry-java/pull/4474))
1111
- Session Replay: Correctly capture Dialogs and non full-sized windows ([#4354](https://github.com/getsentry/sentry-java/pull/4354))
1212
- Session Replay: Fix inconsistent `segment_id` ([#4471](https://github.com/getsentry/sentry-java/pull/4471))
13+
- Set thread information on transaction from OTEL attributes ([#4478](https://github.com/getsentry/sentry-java/pull/4478))
1314

1415
## 8.13.2
1516

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SentrySpanExporter.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.sdk.trace.export.SpanExporter;
1313
import io.opentelemetry.semconv.HttpAttributes;
1414
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
15+
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
1516
import io.sentry.Baggage;
1617
import io.sentry.DateUtils;
1718
import 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

Comments
 (0)