66import io .opentelemetry .semconv .HttpAttributes ;
77import io .opentelemetry .semconv .UrlAttributes ;
88import io .opentelemetry .semconv .incubating .DbIncubatingAttributes ;
9+ import io .opentelemetry .semconv .incubating .GraphqlIncubatingAttributes ;
910import io .opentelemetry .semconv .incubating .HttpIncubatingAttributes ;
1011import io .sentry .protocol .TransactionNameSource ;
1112import org .jetbrains .annotations .ApiStatus ;
@@ -30,6 +31,11 @@ public final class SpanDescriptionExtractor {
3031 return descriptionForDbSystem (otelSpan );
3132 }
3233
34+ final @ Nullable String graphqlOperationType = attributes .get (GraphqlIncubatingAttributes .GRAPHQL_OPERATION_TYPE );
35+ if (graphqlOperationType != null ) {
36+ return descriptionForGraphql (otelSpan );
37+ }
38+
3339 final @ NotNull String name = otelSpan .getName ();
3440 final @ Nullable String maybeDescription =
3541 sentrySpan != null ? sentrySpan .getDescription () : name ;
@@ -105,4 +111,16 @@ private OtelSpanInfo descriptionForDbSystem(final @NotNull SpanData otelSpan) {
105111
106112 return new OtelSpanInfo ("db" , otelSpan .getName (), TransactionNameSource .TASK );
107113 }
114+
115+ private OtelSpanInfo descriptionForGraphql (final @ NotNull SpanData otelSpan ) {
116+ final @ NotNull Attributes attributes = otelSpan .getAttributes ();
117+ @ Nullable String graphqlOperationType = attributes .get (GraphqlIncubatingAttributes .GRAPHQL_OPERATION_TYPE );
118+ @ Nullable String graphqlOperationName = attributes .get (GraphqlIncubatingAttributes .GRAPHQL_OPERATION_NAME );
119+ if (graphqlOperationType != null && graphqlOperationName != null ) {
120+ String description = graphqlOperationType + " " + graphqlOperationName ;
121+ return new OtelSpanInfo (description , description , TransactionNameSource .TASK );
122+ }
123+
124+ return new OtelSpanInfo (otelSpan .getName (), otelSpan .getName (), TransactionNameSource .TASK );
125+ }
108126}
0 commit comments