Skip to content

Commit 83dec69

Browse files
committed
Merge branch 'feat/data-collection-session-replay-network-options' into fix/data-collection-android-installation-id
2 parents 0571ff4 + faa7366 commit 83dec69

2 files changed

Lines changed: 1 addition & 47 deletions

File tree

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,14 @@ private void addRequestAttributesToScope(
7979
private static Map<String, String> collectHeaders(
8080
final @NotNull Attributes attributes, final @NotNull SentryOptions options) {
8181
Map<String, String> headers = new HashMap<>();
82-
final boolean isDataCollectionConfigured =
83-
options.getDataCollectionResolver().isDataCollectionConfigured();
8482

8583
attributes.forEach(
8684
(key, value) -> {
8785
final @NotNull String attributeKeyAsString = key.getKey();
8886
if (attributeKeyAsString.startsWith(HTTP_REQUEST_HEADER_PREFIX)) {
8987
final @NotNull String headerName =
9088
StringUtils.removePrefix(attributeKeyAsString, HTTP_REQUEST_HEADER_PREFIX);
91-
if (isDataCollectionConfigured
92-
|| options.isSendDefaultPii()
93-
|| !HttpUtils.containsSensitiveHeader(headerName)) {
89+
if (options.isSendDefaultPii() || !HttpUtils.containsSensitiveHeader(headerName)) {
9490
if (value instanceof List) {
9591
try {
9692
final @NotNull List<String> headerValues = (List<String>) value;
@@ -108,10 +104,6 @@ private static Map<String, String> collectHeaders(
108104
}
109105
}
110106
});
111-
if (isDataCollectionConfigured) {
112-
return HttpUtils.filterHeaders(
113-
headers, options.getDataCollectionResolver().getHttpRequestHeaders());
114-
}
115107
return headers;
116108
}
117109

sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OpenTelemetryAttributesExtractorTest.kt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import io.opentelemetry.sdk.trace.data.SpanData
66
import io.opentelemetry.semconv.HttpAttributes
77
import io.opentelemetry.semconv.ServerAttributes
88
import io.opentelemetry.semconv.UrlAttributes
9-
import io.sentry.KeyValueCollectionBehavior
109
import io.sentry.Scope
1110
import io.sentry.SentryOptions
1211
import io.sentry.protocol.Request
@@ -354,43 +353,6 @@ class OpenTelemetryAttributesExtractorTest {
354353
thenHeaderIsNotPresentOnRequest("some-header")
355354
}
356355

357-
@Test
358-
fun `data collection filters request header attributes`() {
359-
fixture.options.dataCollection.httpHeaders.request =
360-
KeyValueCollectionBehavior.denyList("customer")
361-
givenAttributes(
362-
mapOf(
363-
HttpAttributes.HTTP_REQUEST_METHOD to "GET",
364-
AttributeKey.stringArrayKey("http.request.header.content-type") to
365-
listOf("application/json"),
366-
AttributeKey.stringArrayKey("http.request.header.authorization") to listOf("Bearer token"),
367-
AttributeKey.stringArrayKey("http.request.header.x-customer") to listOf("customer value"),
368-
)
369-
)
370-
371-
whenExtractingAttributes()
372-
373-
thenHeaderIsPresentOnRequest("content-type", "application/json")
374-
thenHeaderIsPresentOnRequest("authorization", "[Filtered]")
375-
thenHeaderIsPresentOnRequest("x-customer", "[Filtered]")
376-
}
377-
378-
@Test
379-
fun `data collection can disable request header attributes`() {
380-
fixture.options.dataCollection.httpHeaders.request = KeyValueCollectionBehavior.off()
381-
givenAttributes(
382-
mapOf(
383-
HttpAttributes.HTTP_REQUEST_METHOD to "GET",
384-
AttributeKey.stringArrayKey("http.request.header.content-type") to
385-
listOf("application/json"),
386-
)
387-
)
388-
389-
whenExtractingAttributes()
390-
391-
assertNull(fixture.scope.request!!.headers)
392-
}
393-
394356
@Test
395357
fun `if there are no header attributes does not set headers on request`() {
396358
givenAttributes(mapOf(HttpAttributes.HTTP_REQUEST_METHOD to "GET"))

0 commit comments

Comments
 (0)