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

com.github.kristofa.brave.http.HttpClientResponseAdapter Maven / Gradle / Ivy

Go to download

Abstraction that makes it easier to implement brave in http clients and servers.

There is a newer version: 4.13.6
Show newest version
package com.github.kristofa.brave.http;

import com.github.kristofa.brave.ClientResponseAdapter;
import com.github.kristofa.brave.KeyValueAnnotation;
import zipkin.TraceKeys;

import java.util.Collection;
import java.util.Collections;

/**
 * @deprecated Replaced by {@code HttpClientParser} from brave-http
 */
@Deprecated
public class HttpClientResponseAdapter implements ClientResponseAdapter {

    private final HttpResponse response;

    public HttpClientResponseAdapter(HttpResponse response) {
        this.response = response;
    }

    @Override
    public Collection responseAnnotations() {
        int httpStatus = response.getHttpStatusCode();

        if ((httpStatus < 200) || (httpStatus > 299)) {
            return Collections.singleton(KeyValueAnnotation.create(
                    TraceKeys.HTTP_STATUS_CODE, String.valueOf(httpStatus)));
        }
        return Collections.emptyList();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy