Introspect metrics annotations from an implemented interface
given an interface (PetApi) and an implementation (PetResource implements PetApi) for a JAX-RS resource.
In Wildfly 19:
- when I annotate the implementation class, the annotations are not discovered. When I call the method, no metric appears on the /metrics url.
- when I annotate the interface, the annotations are discovered, but not updated by requests. All metrics are displayed on the /metrics url, the values are 0.
- when I annotate the interface and the implementation with the same annotations, the annotations are discovered and return values for requests. In this case I have to mark the annotations as reusable = true. Reading the /metrics url gives all annotated metrics with values.
see also https://github.com/eclipse/microprofile-metrics/issues/451 for a discussion what should be expected behavior in the spec.
- The Microprofile Restclient allows to annotate the interface (there is no implementation class in this case)
- The examples for Microprofile Metrics always use JAX-RS implementation classes without interfaces.
The spec doesn't basically say anything about this at the moment. And while discussing this within the specification repo, we've come across several potential issues and inconsistencies that could arise from this - feel free to chime in there, but I doubt that a feature like this is coming to the spec any time soon. We could try to do some basic slimmed down support for it in SmallRye. I'm not opposed to that, just thinking whether there would be any volunteers to come up with a pull request ;) If we do this in SmallRye first and it proves useful, it can be backported to the spec later.
Hey, let's keep this open, if you don't mind! I think this is a valid suggestion. Perhaps we could find a volunteer to look into it, or I can do that later. Once proved useful in SmallRye, it can be ported to the spec.