Add a global option to disable failed-request capture for OkHttp interceptors (including plugin-injected ones)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- networking
調査の方向性
Start from shouldCaptureClientError in SentryOkHttpInterceptor.kt (L463-L467), where the per-interceptor flag is checked. The new global option belongs in SentryOptions, read at intercept time, with SentryAndroidOptions parsing the matching io.sentry.* manifest key; SentryOkHttpClientBeanPostProcessor.java and the Gradle plugin visitor both build the interceptor with no arguments. Done means defaults stay unchanged, disabling stops failed-request events while tracing still works, and sentry-okhttp / sentry-android tests cover injected and manual interceptors.
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
Problem Statement
SentryOkHttpInterceptor already has options to control failed-request capture (captureFailedRequests, failedRequestStatusCodes, failedRequestTargets), but they are constructor parameters, not SentryOptions (see the Android SDK options). They only work on an interceptor the app creates itself. The Sentry Android Gradle Plugin's OkHttp auto-installation also adds an interceptor, and that one cannot be configured.
When tracingInstrumentation and the OKHTTP feature are enabled, the plugin adds a SentryOkHttpInterceptor to every OkHttp client that doesn't already have one. It uses the no-arg constructor (ResponseWithInterceptorChainMethodVisitor.kt#L95-L96), so injected interceptors always run with the defaults documented for HTTP client errors: captureFailedRequests = true, failedRequestStatusCodes 500–599, failedRequestTargets .*.
Where the existing options work and where they don't:
- Interceptor the app creates itself (manual installation): works.
SentryOkHttpInterceptor(captureFailedRequests = false)is honored, and the plugin skips clients that already have a Sentry interceptor. - Plugin-injected interceptor: no way to set any of the options. It always uses the defaults. The Gradle plugin docs only offer turning the OkHttp instrumentation off entirely, which also removes the tracing.
- Clients created inside third-party libraries: the app can't add its own interceptor, so these appear to get the injected defaults, since the rewrite happens in OkHttp's own call path.
As a result, every 5xx response from an instrumented OkHttp client becomes a SentryHttpClientException event, and there's no way to keep the OkHttp tracing instrumentation and turn off failed-request capture for those clients. Apps that talk to chatty backends can send a large volume of these events and exhaust their rate limit. Other SDKs expose this as a global option (Apple, Dart); Android only has the per-interceptor parameters.
This request is filed here because the fix belongs in the SDK, but the trigger is the Gradle plugin's injected interceptor. A plugin-only change would not cover manually added or Spring Boot-configured interceptors.
Current workarounds, and why they fall short:
- Add your own
SentryOkHttpInterceptor(captureFailedRequests = false)on clients you build. This can't reach clients built inside third-party libraries. - Drop the events in
beforeSendusing theOKHTTP_REQUEST/OKHTTP_RESPONSEhints. This requires manual initialization, and every app has to write and maintain its own filter. options.addIgnoredExceptionForType(SentryHttpClientException::class.java)(seeignoredExceptionsForTypein the Android options) drops failed-request events from every client, with no per-client or per-status-code scoping.
Solution Brainstorm
Proposal: a global kill switch in SentryOptions (the name could mirror Dart's captureFailedRequests), also settable through io.sentry.* manifest meta-data.
- Read it at intercept time, not in the constructor, because clients can be built before
Sentry.init. - Combine it with the per-instance value in
shouldCaptureClientError(SentryOkHttpInterceptor.kt#L463-L467). - It covers plugin-injected, manually added, and Spring Boot auto-configured interceptors (SentryOkHttpClientBeanPostProcessor.java#L50 also uses the no-arg constructor).
- Global status-code and target lists can follow later if there's demand, as Apple already offers (
failedRequestStatusCodes,failedRequestTargets). A Gradle plugin DSL could later write the manifest key with no bytecode changes.
Alternative considered: a Gradle plugin DSL option that makes the visitor call the interceptor constructor with arguments. Not recommended: the argument constructor doesn't exist before sentry-android-okhttp 6.6.0, takes IHub up to 7.x and IScopes from 8.0.0, so the plugin would have to emit a different descriptor per SDK range. A wrong descriptor would fail with NoSuchMethodError on every OkHttp call.
Prior art: Apple exposes enableCaptureFailedRequests, failedRequestStatusCodes and failedRequestTargets as core SDK options (HTTP client errors), and Dart exposes captureFailedRequests as a global on/off option. Related: #3315, #3244, #2767, getsentry/sentry-android-gradle-plugin#650, getsentry/sentry-android-gradle-plugin#426.
Solution Brainstorm
No response
- 主要言語
- Kotlin
- スター
- 1.4k
- フォーク
- 483
- 平均マージ
- 2日 54分
- マージ済み PR(30日)
- 207
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-java のほかの issue
-
Test the `sentry wizard` Android port対応中かも @antonis が 1 日前に担当しました。 オープンPlatform: Java
getsentry/sentry-java#6797 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Narrow and clean up Android consumer keep rules対応中かも @runningcode が 3 日前に担当しました。 オープンAndroid Platform: Java
getsentry/sentry-java#6771 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Android Bug Platform: Java Waiting for: Product Owner
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
getsentry/sentry-java#6758 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
Android Bug Platform: Java Replays
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
getsentry/sentry-java#6741 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Android Bug Platform: Java Replays
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
getsentry/sentry-java#6740 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-java の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
IacobIonut01/ReFra#1515 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
openwatersio/slackwater-android#162 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 半日 初心者へのやさしさ 72/100
developmentwithyash/yaan#184 ·
メンテナーはふだん 1 日以内に返信
-
analytics
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
🐛 Type:Bug 📏 Size: S 🔧 State:In Progress 🔹 Priority: P2 - Medium
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
yeliqin666/xjtu-toolbox-android#623 · コメント 1 件 ·