All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.kristofa.brave.ClientResponseInterceptor Maven / Gradle / Ivy

The newest version!
package com.github.kristofa.brave;

import static com.github.kristofa.brave.internal.Util.checkNotNull;

/**
 * Contains logic for dealing with response from client request.
 * This means it will:
 *
 * - Submit potential annotations
 * - Submit client received annotation
 *
 * You will have to implement ClientResponseAdapter.
 *
 * @see ClientResponseAdapter
 */
public class ClientResponseInterceptor {

    private final ClientTracer clientTracer;

    public ClientResponseInterceptor(ClientTracer clientTracer) {
        this.clientTracer = checkNotNull(clientTracer, "Null clientTracer");
    }

    /**
     * Handle a client response.
     *
     * @param adapter Adapter that hides implementation details.
     */
    public void handle(ClientResponseAdapter adapter) {
        try {
            for (KeyValueAnnotation annotation : adapter.responseAnnotations()) {
                clientTracer.submitBinaryAnnotation(annotation.getKey(), annotation.getValue());
            }
        }
        finally
        {
            clientTracer.setClientReceived();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy