Networking#
We use Okhttp and Retrofit for networking in Gradle plugins and Android libraries.
How to observe your plugin http request stability#
Add StatsHttpEventListener
from module subprojects:common:http-statsd
to your OkHttpClient.Builder
-
Add module dependency
dependencies { implementation(projects.subprojects.common.httpStatsd) }
-
Add
StatsHttpEventListener
OkHttpClient.Builder() .eventListenerFactory { StatsHttpEventListener( statsDSender = statsdSender, timeProvider = timeProvider, loggerFactory = loggerFactory, requestMetadataProvder = requestMetadataProvder, ) }
-
Add RequestMetadata to your request
tag
corresponding to your requestMetadataProvider typeWarning
Missing tag will lead to missing metrics for this api method / service Warning message could be found in logs
Request.Builder() .url("some url") .tag(RequestMetadata::class.java, RequestMetadata("some-service", "some-method")) .build()
or
interface SomeApi { @POST("/") fun someMethod( @Body someBody: String, @Tag metadata: RequestMetadata = RequestMetadata("some-service", "some-method") ): Call<Unit> }