Skip to content

Commit 8fadb23

Browse files
adinauerclaude
andcommitted
chore: Merge Data Collection stack updates
Propagate the OpenTelemetry span-description revert from the preceding stack branch. Co-Authored-By: Claude <noreply@anthropic.com>
2 parents f9b7075 + 58f096f commit 8fadb23

2 files changed

Lines changed: 8 additions & 24 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
1111
import io.sentry.SentryOptions;
1212
import io.sentry.protocol.TransactionNameSource;
13-
import io.sentry.util.UrlUtils;
1413
import org.jetbrains.annotations.ApiStatus;
1514
import org.jetbrains.annotations.NotNull;
1615
import org.jetbrains.annotations.Nullable;
@@ -72,14 +71,16 @@ private OtelSpanInfo descriptionForHttpMethod(
7271
final @Nullable String httpTarget = attributes.get(HttpIncubatingAttributes.HTTP_TARGET);
7372
final @Nullable String httpRoute = attributes.get(HttpAttributes.HTTP_ROUTE);
7473
@Nullable String httpPath = httpRoute;
75-
if (httpPath == null && httpTarget != null) {
76-
httpPath = UrlUtils.parse(httpTarget).getUrl();
74+
if (httpPath == null) {
75+
httpPath = httpTarget;
7776
}
7877
final @NotNull String op = opBuilder.toString();
7978

8079
final @Nullable String urlFull = attributes.get(UrlAttributes.URL_FULL);
81-
if (urlFull != null && httpPath == null) {
82-
httpPath = UrlUtils.parse(urlFull).getUrl();
80+
if (urlFull != null) {
81+
if (httpPath == null) {
82+
httpPath = urlFull;
83+
}
8384
}
8485

8586
final @Nullable String urlPath = attributes.get(UrlAttributes.URL_PATH);

‎sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class SpanDescriptionExtractorTest {
113113
val info = whenExtractingSpanInfo()
114114

115115
assertEquals("http.server", info.op)
116-
assertEquals("GET https://sentry.io/some/path", info.description)
116+
assertEquals("GET https://sentry.io/some/path?q=1#top", info.description)
117117
assertEquals(TransactionNameSource.URL, info.transactionNameSource)
118118
}
119119

@@ -132,7 +132,7 @@ class SpanDescriptionExtractorTest {
132132
}
133133

134134
@Test
135-
fun `uses HTTP_ROUTE over HTTP_TARGET for description`() {
135+
fun `uses HTTP_TARGET for description`() {
136136
givenSpanKind(SpanKind.SERVER)
137137
givenAttributes(
138138
mapOf(
@@ -150,23 +150,6 @@ class SpanDescriptionExtractorTest {
150150
assertEquals(TransactionNameSource.ROUTE, info.transactionNameSource)
151151
}
152152

153-
@Test
154-
fun `removes query and fragment from HTTP_TARGET description`() {
155-
givenSpanKind(SpanKind.SERVER)
156-
givenAttributes(
157-
mapOf(
158-
HttpAttributes.HTTP_REQUEST_METHOD to "GET",
159-
HttpIncubatingAttributes.HTTP_TARGET to "/checkout?page=1&token=secret#details",
160-
)
161-
)
162-
163-
val info = whenExtractingSpanInfo()
164-
165-
assertEquals("http.server", info.op)
166-
assertEquals("GET /checkout", info.description)
167-
assertEquals(TransactionNameSource.URL, info.transactionNameSource)
168-
}
169-
170153
@Test
171154
fun `uses span name as description fallback`() {
172155
givenSpanKind(SpanKind.SERVER)

0 commit comments

Comments
 (0)