getsentry/sentry-java

Ok Http Retry Tracking using the EventListner API?

ddas09 opened this issue · 2 comments

Description

Hello Team, I have a question about how we are tracking the network metrics using the OkHttp EventListenerAPI here - https://github.com/getsentry/sentry-java/blob/main/sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpEventListener.kt

From my understanding, with the current implementation, if a request is retried, the event listener only captures metrics for the latest attempt and does not track metrics for each retry separately. So, if there are three requests (one original and two retries), we only see metrics for the last one. I understand that some metrics, like CONNECT, SSL, and DNS, would only be recorded for the initial request since OkHttp reuses the connection. However, other metrics could still be relevant for retries.

Was there a specific reason for implementing it this way?

Looking forward to your insights!

Hi @ddas09!
we just did it this way for simplicity, and because there isn't a lot of value in capturing such metrics for original requests that are then retried.
If you'd like retries to be captured, we can think to add it.
Would a retry counter be enough, or would you prefer to have full insights in all the steps of the calls?

@stefanosiano, thank you for the clarification! For our particular use case, we are trying to get full insights into the requests including retry. I was just wondering if this is something we can achieve through the EventListenerAPI and I found this repo.

To give an example, the desired format for the request metrics that we are looking for might look something like below. This example is for a network call with 3 requests (2 retry request) and assuming the final one succeeds -

[
  { "dns": 50, "connect": 120, "status": 400, "attempt": 1 },
  { "response": 40, "status": 400, "attempt": 2 },
  {  "response": 100, "status": 200 "attempt": 3 }
]