Support Cronet HTTP instrumentation and network timings
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend-api-design
Línea de trabajo
Start by reading the Cronet API findings and the linked SAGP ResponseWithInterceptorChainMethodVisitor.kt; the issue also identifies RequestFinishedInfo.Metrics as the source of transport timings. The proposed direction is not final and leaves provider support, span correlation, and late or empty metrics unresolved. First validate those assumptions and settle the API and integration scope; done would require agreed behavior for both direct Cronet and Cronet-backed OkHttp.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Direct Cronet usage currently gets no out-of-the-box network metrics from Sentry. In OkHttp-over-Cronet setups where Sentry's interceptor runs, the HTTP request is captured, but DNS/connect/TLS timings are missing. Some OkHttp bridges also prevent the interceptor from running, which means trace propagation and failed-request capture are missing too. Cronet's RequestFinishedInfo.Metrics is the source for transport timings, so OkHttp-side instrumentation alone can't fill that gap.
Raised by an Android SDK user who runs OkHttp over Cronet and currently uses reflection on SentryOkHttpEventListener internals (eventMap, internal attribute keys) to attach Cronet timings to the Sentry span.
Current behavior
- Direct Cronet: there is no out-of-the-box Sentry network instrumentation, so no request-level network metrics are captured.
- OkHttp over Cronet, with Sentry's interceptor reached: the HTTP request is captured, but Cronet-owned DNS/connect/TLS details are not.
- Google's cronet-transport-for-okhttp (and forks of it):
CronetInterceptoris the last application interceptor and never callschain.proceed. SAGP appendsSentryOkHttpInterceptorafter app interceptors (ResponseWithInterceptorChainMethodVisitor.kt), so it never runs: no trace headers, no failed-request capture.SentryOkHttpEventListeneronly seescallStart/callEnd. - Bridges that swap transport at
ConnectInterceptor: our interceptor runs and header/body events may be replayed, butdnsStart,connectStart,secureConnectStartandconnectionAcquirednever fire because Cronet owns the socket. - Other Cronet wrappers: no Sentry Cronet integration exists today.
Why OkHttp-side changes aren't enough
EventListenercallbacks carry no timestamps andSentryOkHttpEventstamps them withnow(), so a bridge replaying DNS/connect/TLS events after the fact would record ~0ms durations.- Moving
SentryOkHttpInterceptorto the front of the chain globally isn't viable: it would record the request before other interceptors modify it (auth headers, URL rewrites) and change span semantics for every OkHttp app.
Cronet findings (source reading only, not validated on device)
UrlRequest.Builder.addRequestAnnotation,UrlRequest.Builder.setRequestFinishedListenerandCronetEngine.addRequestFinishedListenerare in the base API since cronet-api 113; older versions need theExperimental*classes.- These base methods are silent no-ops on providers that don't implement them (e.g. the fallback Java provider), so missing support shows up as a callback that never arrives.
- Embedded Cronet: engine-level and per-request listeners, annotations and metrics all work (
CronetUrlRequest.maybeReportMetrics). - Platform
HttpEngine(Android 14+): listeners and annotations work, butgetMetrics()returnsCronetMetrics.empty()(AndroidRequestFinishedInfoWrapper), so phase timings are unavailable. DefaultCronetProviderselection can pickHttpEnginebefore Play Services. - Play Services Cronet: closed source, unverified.
RequestFinishedInfois delivered asynchronously and can arrive after the OkHttp span has finished (Google's bridge doesn't wait for it).
Proposed direction (from discussion, not final)
- A public API to record transport timings on an
http.clientspan using absolute timestamps (DNS, connect, TLS, send, TTFB) plus protocol,socketReused, QUIC error codes and wire byte counts, with Sentry-owned attribute names. - A
sentry-cronetintegration covering two cases:- Direct Cronet: full HTTP client instrumentation, on par with the other HTTP integrations — create the
http.clientspan, add trace headers, record request/response data (method, URL, status, sizes), breadcrumbs and failed-request capture, plus transport timings via the API above. - Cronet as OkHttp transport: don't create a second span; enrich the existing OkHttp span with transport timings only.
- Correlation via a request annotation carrying the Sentry span, plus an engine-level
RequestFinishedInfo.Listener(so it doesn't replace per-request listeners set by bridges) that reads it.
- Direct Cronet: full HTTP client instrumentation, on par with the other HTTP integrations — create the
- Manual wiring first (bridge mapping hooks, wrapper listener hooks); SAGP call-site instrumentation of
UrlRequest.Builder.build()/CronetEngine.Builder.build()later.
Open questions
- How to correlate a
UrlRequestwith the originating OkHttpCall(e.g. a thread-local set aroundgetResponseWithInterceptorChain), given it relies on the bridge building the request on the call's thread. - Play Services provider support for annotations, listeners and metrics.
- How long to hold a span open for late
RequestFinishedInfo, and what to do when metrics are empty.
via roman.
--
- Lenguaje dominante
- Kotlin
- Estrellas
- 1.4k
- Forks
- 483
- Merge medio
- 2 d 54 min
- PR fusionados (30 d)
- 207
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-java
-
Test the `sentry wizard` Android portPosiblemente ocupada @antonis la tomó hace 1 día. AbiertoPlatform: Java
getsentry/sentry-java#6797 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Narrow and clean up Android consumer keep rulesPosiblemente ocupada @runningcode la tomó hace 3 días. AbiertoAndroid Platform: Java
getsentry/sentry-java#6771 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Android Bug Platform: Java Waiting for: Product Owner
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
getsentry/sentry-java#6758 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Android Bug Platform: Java Replays
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
getsentry/sentry-java#6741 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Android Bug Platform: Java Replays
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
getsentry/sentry-java#6740 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de getsentry/sentry-java
Issues similares
-
[BUG] Issue reported from ReFraAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
IacobIonut01/ReFra#1515 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
openwatersio/slackwater-android#162 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
developmentwithyash/yaan#184 ·
Los mantenedores suelen responder en 1 día
-
analytics
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
🐛 Type:Bug 📏 Size: S 🔧 State:In Progress 🔹 Priority: P2 - Medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
yeliqin666/xjtu-toolbox-android#623 · 1 comentario ·