class Invocation
A single invocation of a Retrofit service interface method. This class captures both the method that was called and the arguments to the method.
Retrofit automatically adds an invocation to each OkHttp request as a tag. You can retrieve the invocation in an OkHttp interceptor for metrics and monitoring.
class InvocationLogger implements Interceptor {
@Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Invocation invocation = request.tag(Invocation.class);
if (invocation != null) {
System.out.printf("%s.%s %s%n",
invocation.method().getDeclaringClass().getSimpleName(),
invocation.method().getName(), invocation.arguments());
}
return chain.proceed(request);
}
}
Note: use caution when examining an invocation's arguments. Although the arguments list is unmodifiable, the arguments themselves may be mutable. They may also be unsafe for concurrent access. For best results declare Retrofit service interfaces using only immutable types for parameters!
fun arguments(): MutableList<*>! |
|
fun method(): Method! |
|
static fun of(method: Method!, arguments: MutableList<*>!): Invocation! |
|
fun toString(): String |