I have contacted Firebase support and their answer was:
...
As mentioned here, while Performance Monitoring reports most network requests for your app, some might not be reported. Hence, it is recommended to add monitoring for specific requests in your app.
In order for a request to be reported to the Performance Monitoring console, any trace that is start using the trace.start() must also be
stopped by calling the trace.stop() method. Traces that are never
stopped, are never reported.
- Wildcarding is only based on path segment and not query strings. Query strings are ignored for purpose of aggregation in the dashboard.
- For a domain a.b.c, it's path a.b.c/d/ should have been requested from several dozen unique devices in order for the path a.b.c/d/ to
appear separately in the dashboard, in the time frame of your selected
filter.
- Known Issues with Performance Monitoring.
For the 4th point that I mentioned above, there is also one thing to
keep in mind. Let's say N is the definite numerical value representing
the "several dozen" threshold that I mentioned earlier. And, we are
monitoring the following 3 different path segments:
1. www.something.com/a/
2. www.something.com/b/
3. www.something.com/c/
Within a given time-frame, if all 3 of the paths above received N-1
hits. That is, not meeting the threshold requirement. While the number
of hits might appear to be almost 3 times of N when seen against
www.something.com collectively(as that is what the dashboard will
show), the individual hits for each path did not meet the threshold in
the given time frame and hence, only the aggregated number statistics
are shown.
...
The code that I used to intercept the retrofit request and monitor the request time is: (I removed the query params data for security)
val builder = OkHttpClient.Builder()
.addInterceptor(FirebasePerformanceInterceptor(FirebasePerformance.getInstance()))
.build()
// Adapted from: http://qaru.site/questions/15007824/how-can-i-get-the-url-and-method-of-retrofit-request-on-onsubscribe-of-rxjava-2-custom-operator
class FirebasePerformanceInterceptor(private val performanceInstance: FirebasePerformance) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
//Get request values
val url = request.url().url()
val urlPath = getUrlWithoutQuery(url)
val requestPayloadSize = request.body()?.contentLength() ?: 0L
val httpMethod = request.method()
//Initialize http trace
val trace = performanceInstance.newHttpMetric(urlPath, httpMethod)
trace.setRequestPayloadSize(requestPayloadSize)
trace.start()
//Proceed
val response = chain.proceed(chain.request())
//Get response values
val responseCode = response.code()
//Add response values to trace and close it
trace.setHttpResponseCode(responseCode)
trace.stop()
return response
}
}
private fun getUrlWithoutQuery(url: URL): URL {
val uri = URI(url.protocol, url.host, url.path, null)
return uri.toURL()
}
To test if it's logging correctedly: Follow this Debugging tutorial:
You will see something like:
10-24 19:48:21.162 23037 24411 I FirebasePerformance: Logging NetworkRequestMetric - https://your-api-domain.com/cart 0b 147809ms,