diff --git a/sentry-android-okhttp/src/main/java/io/sentry/android/okhttp/SentryOkHttpInterceptor.kt b/sentry-android-okhttp/src/main/java/io/sentry/android/okhttp/SentryOkHttpInterceptor.kt index 78bddc8d7b..989c8f189b 100644 --- a/sentry-android-okhttp/src/main/java/io/sentry/android/okhttp/SentryOkHttpInterceptor.kt +++ b/sentry-android-okhttp/src/main/java/io/sentry/android/okhttp/SentryOkHttpInterceptor.kt @@ -25,9 +25,10 @@ import java.io.IOException class SentryOkHttpInterceptor( private val hub: IHub = HubAdapter.getInstance(), private val beforeSpan: BeforeSpanCallback? = null, - // TODO: should this be under the options or here? also define the names + // should this be under the options or here? also define the names private val captureFailedRequests: Boolean = false, - private val failedRequestStatusCode: List = listOf(HttpStatusCodeRange(500, 599)), + private val failedRequestStatusCode: List = listOf( + HttpStatusCodeRange(HttpStatusCodeRange.DEFAULT_MIN, HttpStatusCodeRange.DEFAULT_MAX)), private val failedRequestsTargets: List = listOf(".*") ) : Interceptor { @@ -141,14 +142,17 @@ class SentryOkHttpInterceptor( requestUrl = requestUrl.replace("#$urlFragment", "") } - if (!captureFailedRequests || !PropagationTargetsUtils.contain(failedRequestsTargets, requestUrl) || !containsStatusCode(response.code)) { + if (!captureFailedRequests || + !PropagationTargetsUtils.contain(failedRequestsTargets, requestUrl) || + !containsStatusCode(response.code)) { return } val mechanism = Mechanism().apply { type = "SentryOkHttpInterceptor" } - val exception = SentryHttpClientException("Event was captured because the request status code was ${response.code}") + val exception = SentryHttpClientException( + "Event was captured because the request status code was ${response.code}") val mechanismException = ExceptionMechanismException(mechanism, exception, Thread.currentThread(), true) val event = SentryEvent(mechanismException) @@ -156,7 +160,7 @@ class SentryOkHttpInterceptor( hint.set("request", request) hint.set("response", response) - // TODO: remove after fields indexed + // remove after fields indexed // val tags = mutableMapOf() // tags["status_code"] = response.code.toString() // tags["url"] = requestUrl @@ -173,7 +177,7 @@ class SentryOkHttpInterceptor( fragment = urlFragment request.body?.contentLength().ifHasValidLength { - // TODO: should be mapped in relay and added to the protocol, right now + // should be mapped in relay and added to the protocol, right now // relay isn't retaining unmapped fields unknownRequestFields["body_size"] = it } diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index e811a1ed7c..964138e0ae 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -261,6 +261,8 @@ public final class io/sentry/Hint { } public final class io/sentry/HttpStatusCodeRange { + public static final field DEFAULT_MAX I + public static final field DEFAULT_MIN I public fun (I)V public fun (II)V public fun isInRange (I)Z diff --git a/sentry/src/main/java/io/sentry/HttpStatusCodeRange.java b/sentry/src/main/java/io/sentry/HttpStatusCodeRange.java index 7505643a1f..56602fcc79 100644 --- a/sentry/src/main/java/io/sentry/HttpStatusCodeRange.java +++ b/sentry/src/main/java/io/sentry/HttpStatusCodeRange.java @@ -6,6 +6,9 @@ *

Example for a single status code 400 500 */ public final class HttpStatusCodeRange { + public static final int DEFAULT_MIN = 500; + public static final int DEFAULT_MAX = 599; + private final int min; private final int max;