6

The OpenApi documentation says that it supports micrometer. How does the integration works? I could not find anything except this little documentation.

I have a FeignClient in a spring boot application

@FeignClient(name = "SomeService", url = "xxx", configuration = FeignConfiguration.class)
public interface SomeService {

    @GET
    @Path("/something")
    Something getSomething();
}

with the configuration

public class FeignConfiguration {
    @Bean
    public Capability capability() {
        return new MicrometerCapability();
    }
}

and the micrometer integration as a dependency

<dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-micrometer</artifactId>
    <version>10.12</version>
</dependency>

The code makes a call but I could not find any new metrics via the actuator overview, expecting some general information about my HTTP requests. What part is missing?

DV82XL
  • 5,350
  • 5
  • 30
  • 59
Marius
  • 365
  • 4
  • 18
  • I had almost the same problem. For me when I change Capability method to use provided bean registry (registry that is managed by spring) then It helped fix the problem............................................... public Capability capability(MeterRegistry meterRegistry) { return new MicrometerCapability(meterRegistry); } – Wojciech Aug 31 '23 at 15:51

1 Answers1

6

Update

I added the support for this to spring-cloud-openfeign. After the next release (2020.0.2), if micrometer is set-up, the only thing you need to do is putting feign-micrometer onto your classpath.

Old answer

I'm not sure if you do but I recommend to use spring-cloud-openfeign which autoconfigures Feign components for you. Unfortunately, it seems it does not autoconfigure Capability (that's one reason why your solution does not work) so you need to do it manually, please see the docs how to do it.

I was able to make this work combining the examples in the OpenFeign and Spring Cloud OpenFeign docs:

@Import(FeignClientsConfiguration.class)
class FooController {
    private final FooClient fooClient;

    public FooController(Decoder decoder, Encoder encoder, Contract contract, MeterRegistry meterRegistry) {
        this.fooClient = Feign.builder()
                .encoder(encoder)
                .decoder(decoder)
                .contract(contract)
                .addCapability(new MicrometerCapability(meterRegistry))
                .target(FooClient.class, "https://PROD-SVC");
    }
}

What I did:

  • Used spring-cloud-openfeign
  • Added feign-micrometer (see feign-bom)
  • Created the client in the way you can see above Importing FeignClientsConfiguration and passing MeterRegistry to MicrometerCapability are vital

After these, and calling the client, I had new metrics:

  • feign.Client
  • feign.Feign
  • feign.codec.Decoder
  • feign.codec.Decoder.response_size
Jonatan Ivanov
  • 4,895
  • 2
  • 15
  • 30
  • Thank you for your feedback! Indeed it is possible to add the capability using the builder directly. I would like to do it with the `@FeignClient`/Configuration-approach. This seems not possible yet, but I created an issue https://github.com/spring-cloud/spring-cloud-openfeign/issues/457 and a PR is already in progress https://github.com/spring-cloud/spring-cloud-openfeign/pull/462 – Marius Jan 18 '21 at 08:17
  • 2
    @user1451252 yepp, I opened the PR. :) – Jonatan Ivanov Jan 19 '21 at 17:00