Skip to content

Commit 9294b06

Browse files
authored
Merge 1ab4ec9 into 092eb22
2 parents 092eb22 + 1ab4ec9 commit 9294b06

File tree

4 files changed

+1
-86
lines changed

4 files changed

+1
-86
lines changed

sentry-opentelemetry/sentry-opentelemetry-core/api/sentry-opentelemetry-core.api

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ public final class io/sentry/opentelemetry/OtelSentrySpanProcessor : io/opentele
3232

3333
public final class io/sentry/opentelemetry/OtelSpanInfo {
3434
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/sentry/protocol/TransactionNameSource;)V
35-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/sentry/protocol/TransactionNameSource;Ljava/util/Map;)V
36-
public fun addDataField (Ljava/lang/String;Ljava/lang/Object;)V
37-
public fun getDataFields ()Ljava/util/Map;
3835
public fun getDescription ()Ljava/lang/String;
3936
public fun getOp ()Ljava/lang/String;
4037
public fun getTransactionNameSource ()Lio/sentry/protocol/TransactionNameSource;
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.sentry.opentelemetry;
22

33
import io.sentry.protocol.TransactionNameSource;
4-
import java.util.HashMap;
5-
import java.util.Map;
64
import org.jetbrains.annotations.ApiStatus;
75
import org.jetbrains.annotations.NotNull;
86
import org.jetbrains.annotations.Nullable;
@@ -14,27 +12,13 @@ public final class OtelSpanInfo {
1412
private final @Nullable String description;
1513
private final @NotNull TransactionNameSource transactionNameSource;
1614

17-
private final @NotNull Map<String, Object> dataFields;
18-
19-
public OtelSpanInfo(
20-
final @NotNull String op,
21-
final @Nullable String description,
22-
final @NotNull TransactionNameSource transactionNameSource,
23-
final @NotNull Map<String, Object> dataFields) {
24-
this.op = op;
25-
this.description = description;
26-
this.transactionNameSource = transactionNameSource;
27-
this.dataFields = dataFields;
28-
}
29-
3015
public OtelSpanInfo(
3116
final @NotNull String op,
3217
final @Nullable String description,
3318
final @NotNull TransactionNameSource transactionNameSource) {
3419
this.op = op;
3520
this.description = description;
3621
this.transactionNameSource = transactionNameSource;
37-
this.dataFields = new HashMap<>();
3822
}
3923

4024
public @NotNull String getOp() {
@@ -48,12 +32,4 @@ public OtelSpanInfo(
4832
public @NotNull TransactionNameSource getTransactionNameSource() {
4933
return transactionNameSource;
5034
}
51-
52-
public @NotNull Map<String, Object> getDataFields() {
53-
return dataFields;
54-
}
55-
56-
public void addDataField(final @NotNull String key, final @NotNull Object value) {
57-
dataFields.put(key, value);
58-
}
5935
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ private void createAndFinishSpanForOtelSpan(
225225

226226
final @NotNull ISpan sentryChildSpan = parentSentrySpan.startChild(spanContext, spanOptions);
227227

228-
for (Map.Entry<String, Object> dataField : spanInfo.getDataFields().entrySet()) {
229-
sentryChildSpan.setData(dataField.getKey(), dataField.getValue());
230-
}
231-
232228
for (Map.Entry<String, Object> dataField :
233229
toMapWithStringKeys(spanData.getAttributes()).entrySet()) {
234230
sentryChildSpan.setData(dataField.getKey(), dataField.getValue());
@@ -345,10 +341,6 @@ private void transferSpanDetails(
345341
final @NotNull Map<String, Object> otelContext = toOtelContext(span);
346342
sentryTransaction.setContext("otel", otelContext);
347343

348-
for (Map.Entry<String, Object> dataField : spanInfo.getDataFields().entrySet()) {
349-
sentryTransaction.setData(dataField.getKey(), dataField.getValue());
350-
}
351-
352344
setOtelInstrumentationInfo(span, sentryTransaction);
353345

354346
transferSpanDetails(sentrySpanMaybe, sentryTransaction);

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

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,16 @@
55
import io.opentelemetry.sdk.trace.data.SpanData;
66
import io.opentelemetry.semconv.SemanticAttributes;
77
import io.sentry.protocol.TransactionNameSource;
8-
import java.util.HashMap;
9-
import java.util.Map;
108
import org.jetbrains.annotations.ApiStatus;
119
import org.jetbrains.annotations.NotNull;
1210
import org.jetbrains.annotations.Nullable;
1311

1412
@ApiStatus.Internal
1513
public 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

Comments
 (0)