javajava-8spring-cloud-feign

spring cloud feign - how to find out what http client its using?


We use spring boot open feign with our java 8 spring boot 2.0.3 apps. Open feign is used to make REST calls to other services. We are trying to get New Relic java agent to "see" the feign calls as part of traces, but it doesnt instrument them at all.

  1. Is open feign a web client, or is it a library which uses a web client?
  2. How do we find out what web client its using?
  3. how would we change it?

We have been told that new relic only supports the following http clients, we can only guess that feign is not using one of them:

Akka HTTP 2.4.5 to latest
Akka Http Core from 0.4 to latest
AsyncHttpClient 2.0.0-RC1 to latest
HttpAsyncClient 4.1 to latest
Apache Httpclient from 3.1 to 5.x
java.net.HttpURLConnection
OkHttp 3.6.0 to latest
Ning AsyncHttpClient 1.x
Spring webclient from 5.0.0.release to latest
STTP v2

This is how we include feign:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>

Solution

    1. Is open feign a web client, or is it a library which uses a web client?

    Feign is a REST Client and it use a httpClient.

    1. How do we find out what web client its using?
    2. how would we change it?

    Look at you application.yaml

    Search for something like: feign.*client.enable=true

    A second way to define the client is with Annotation:

    @ConditionalOnProperty(value = "feign.httpclient.enabled", matchIfMissing = true) // enables Apache httpClient
    

    But most likely you didn't define it. Than it's the default:

    java.net.HttpURLConnection