55import io .opentelemetry .sdk .trace .data .SpanData ;
66import io .opentelemetry .semconv .SemanticAttributes ;
77import io .sentry .protocol .TransactionNameSource ;
8- import java .util .HashMap ;
9- import java .util .Map ;
108import org .jetbrains .annotations .ApiStatus ;
119import org .jetbrains .annotations .NotNull ;
1210import org .jetbrains .annotations .Nullable ;
1311
1412@ ApiStatus .Internal
1513public final class SpanDescriptionExtractor {
1614
17- // TODO POTEL: should we rely on the OTEL attributes, that are extracted in the exporter for the
18- // datafields?
19- // We are currently extracting some attributes and add it to the span info here
20- // In the `SentrySpanExporter` we extract all attributes and add it to the dataFields
2115 @ SuppressWarnings ("deprecation" )
2216 public @ NotNull OtelSpanInfo extractSpanInfo (
2317 final @ NotNull SpanData otelSpan , final @ Nullable OtelSpanWrapper sentrySpan ) {
24- OtelSpanInfo spanInfo = extractSpanDescription (otelSpan , sentrySpan );
25-
26- final @ Nullable Long threadId = otelSpan .getAttributes ().get (SemanticAttributes .THREAD_ID );
27- if (threadId != null ) {
28- spanInfo .addDataField ("thread.id" , threadId );
29- }
30-
31- final @ Nullable String threadName =
32- otelSpan .getAttributes ().get (SemanticAttributes .THREAD_NAME );
33- if (threadName != null ) {
34- spanInfo .addDataField ("thread.name" , threadName );
35- }
36-
37- final @ Nullable String dbSystem = otelSpan .getAttributes ().get (SemanticAttributes .DB_SYSTEM );
38- if (dbSystem != null ) {
39- spanInfo .addDataField ("db.system" , dbSystem );
40- }
41-
42- final @ Nullable String dbName = otelSpan .getAttributes ().get (SemanticAttributes .DB_NAME );
43- if (dbName != null ) {
44- spanInfo .addDataField ("db.name" , dbName );
45- }
46-
47- return spanInfo ;
48- }
49-
50- @ SuppressWarnings ("deprecation" )
51- private OtelSpanInfo extractSpanDescription (
52- final @ NotNull SpanData otelSpan , final @ Nullable OtelSpanWrapper sentrySpan ) {
5318 final @ NotNull Attributes attributes = otelSpan .getAttributes ();
5419
5520 final @ Nullable String httpMethod = attributes .get (SemanticAttributes .HTTP_METHOD );
@@ -82,9 +47,6 @@ private OtelSpanInfo descriptionForHttpMethod(
8247 final @ NotNull SpanKind kind = otelSpan .getKind ();
8348 final @ NotNull StringBuilder opBuilder = new StringBuilder ("http" );
8449 final @ NotNull Attributes attributes = otelSpan .getAttributes ();
85- final @ NotNull Map <String , Object > dataFields = new HashMap <>();
86-
87- dataFields .put ("http.request.method" , httpMethod );
8850
8951 if (SpanKind .CLIENT .equals (kind )) {
9052 opBuilder .append (".client" );
@@ -99,20 +61,8 @@ private OtelSpanInfo descriptionForHttpMethod(
9961 }
10062 final @ NotNull String op = opBuilder .toString ();
10163
102- final @ Nullable Long httpStatusCode =
103- attributes .get (SemanticAttributes .HTTP_RESPONSE_STATUS_CODE );
104- if (httpStatusCode != null ) {
105- dataFields .put ("http.response.status_code" , httpStatusCode );
106- }
107-
108- final @ Nullable String serverAddress = attributes .get (SemanticAttributes .SERVER_ADDRESS );
109- if (serverAddress != null ) {
110- dataFields .put ("server.address" , serverAddress );
111- }
112-
11364 final @ Nullable String urlFull = attributes .get (SemanticAttributes .URL_FULL );
11465 if (urlFull != null ) {
115- dataFields .put ("url.full" , urlFull );
11666 if (httpPath == null ) {
11767 httpPath = urlFull ;
11868 }
@@ -126,7 +76,7 @@ private OtelSpanInfo descriptionForHttpMethod(
12676 final @ NotNull TransactionNameSource transactionNameSource =
12777 httpRoute != null ? TransactionNameSource .ROUTE : TransactionNameSource .URL ;
12878
129- return new OtelSpanInfo (op , description , transactionNameSource , dataFields );
79+ return new OtelSpanInfo (op , description , transactionNameSource );
13080 }
13181
13282 @ SuppressWarnings ("deprecation" )
0 commit comments