quarkus-for-spring-developers / examples

Example code for the Quarkus for Spring Developers eBook
https://red.ht/quarkus-spring-devs
Apache License 2.0
46 stars 17 forks source link

Chapter 6: quarkus-rest-monitoring: RegisterMeterRegistry.java #83

Closed edeandrea closed 3 years ago

edeandrea commented 3 years ago

Sub-issue of quarkus-for-spring-developers/project-management#33

I'm not sure the purpose of the RegisterMeterRegistry class. GreetingResource already injects the MeterRegistry. Why does it need to be passed into a subclass with public attributes?

GreetingResource could simply be

@Path("/hello")
public class GreetingResource {
  private final MeterRegistry registry;

  public GreetingResource(MeterRegistry registry) {       
    this.registry = registry;
  }

  @GET
  @Path("/{name}")
  public String sayHello(@PathParam(value = "name") String name) {
    registry.counter("greeting_counter", Tags.of("name", name)).increment();

    return "Hello!";
  }
}

and then MonitoringResource could have private final attributes for the MeterRegistry and the list.

edeandrea commented 3 years ago

@cmoulliard thoughts?