@@ -18,23 +18,16 @@ public final class SpanDescriptionExtractor {
1818 @ SuppressWarnings ("deprecation" )
1919 public @ NotNull OtelSpanInfo extractSpanInfo (
2020 final @ NotNull SpanData otelSpan , final @ Nullable IOtelSpanWrapper sentrySpan ) {
21- if (!isInternalSpanKind (otelSpan )) {
22- final @ NotNull Attributes attributes = otelSpan .getAttributes ();
23-
24- final @ Nullable String httpMethod = attributes .get (HttpAttributes .HTTP_REQUEST_METHOD );
25- if (httpMethod != null ) {
26- return descriptionForHttpMethod (otelSpan , httpMethod );
27- }
21+ final @ NotNull Attributes attributes = otelSpan .getAttributes ();
2822
29- final @ Nullable String httpRequestMethod = attributes .get (HttpAttributes .HTTP_REQUEST_METHOD );
30- if (httpRequestMethod != null ) {
31- return descriptionForHttpMethod (otelSpan , httpRequestMethod );
32- }
23+ final @ Nullable String httpMethod = attributes .get (HttpAttributes .HTTP_REQUEST_METHOD );
24+ if (httpMethod != null ) {
25+ return descriptionForHttpMethod (otelSpan , httpMethod );
26+ }
3327
34- final @ Nullable String dbSystem = attributes .get (DbIncubatingAttributes .DB_SYSTEM );
35- if (dbSystem != null ) {
36- return descriptionForDbSystem (otelSpan );
37- }
28+ final @ Nullable String dbSystem = attributes .get (DbIncubatingAttributes .DB_SYSTEM );
29+ if (dbSystem != null ) {
30+ return descriptionForDbSystem (otelSpan );
3831 }
3932
4033 final @ NotNull String name = otelSpan .getName ();
@@ -44,10 +37,6 @@ public final class SpanDescriptionExtractor {
4437 return new OtelSpanInfo (name , description , TransactionNameSource .CUSTOM );
4538 }
4639
47- private boolean isInternalSpanKind (final @ NotNull SpanData otelSpan ) {
48- return SpanKind .INTERNAL .equals (otelSpan .getKind ());
49- }
50-
5140 @ SuppressWarnings ("deprecation" )
5241 private OtelSpanInfo descriptionForHttpMethod (
5342 final @ NotNull SpanData otelSpan , final @ NotNull String httpMethod ) {
@@ -60,6 +49,12 @@ private OtelSpanInfo descriptionForHttpMethod(
6049 opBuilder .append (".client" );
6150 } else if (SpanKind .SERVER .equals (kind )) {
6251 opBuilder .append (".server" );
52+ } else {
53+ // we cannot be certain that a root span is a server span as it might simply be a client span
54+ // without parent
55+ if (!isRootSpan (otelSpan )) {
56+ opBuilder .append (".client" );
57+ }
6358 }
6459 final @ Nullable String httpTarget = attributes .get (HttpIncubatingAttributes .HTTP_TARGET );
6560 final @ Nullable String httpRoute = attributes .get (HttpAttributes .HTTP_ROUTE );
@@ -92,6 +87,10 @@ private OtelSpanInfo descriptionForHttpMethod(
9287 return new OtelSpanInfo (op , description , transactionNameSource );
9388 }
9489
90+ private static boolean isRootSpan (SpanData otelSpan ) {
91+ return !otelSpan .getParentSpanContext ().isValid () || otelSpan .getParentSpanContext ().isRemote ();
92+ }
93+
9594 @ SuppressWarnings ("deprecation" )
9695 private OtelSpanInfo descriptionForDbSystem (final @ NotNull SpanData otelSpan ) {
9796 final @ NotNull Attributes attributes = otelSpan .getAttributes ();
0 commit comments