Add MP metrics annotation support to MP REST clients #9534
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Resolves #6057
This PR allows users to use the MicroProfile metrics
@Counted
and@Timed
annotations on MicroProfile REST client interfaces and interface methods by adding a dependency in their project on a new Helidon component.Note that Helidon registers the metrics for a given REST client only once Helidon becomes aware of it which happens either when CDI produces that REST client or when an instance is created explicitly using the REST client builder approach. The metric registration can therefore occur after the app has started depending on how the app code is written to refer to REST clients.
Details
The PR adds a new Helidon component
helidon-rest-client-metrics
.The CDI extension does these basic tasks:
The annotation scanning is pretty straightforward. It saves information about the metrics that will be needed for each REST client interface.
At runtime, when user code or CDI production creates a new REST client from an interface, the MP REST Client implementation calls back to a listener added in this PR. The listener:
MetricRegistry
,When the filter is invoked, it basically delegates back to the CDI extension to perform the pre- and post-invocation metrics updating work.
Documentation
The PR includes extensive doc updates.
The existing REST client doc page is moved into a new
restclient
directory which is also where the new REST client metrics page now lives. Several pages with cross-references to the existing REST client page needed to be updated as well. Snippets moved as well.The new REST client metrics page also has an extensive example discussion. There is no existing REST client example app and I have not at this point created one for REST client metrics. That would be a separate PR for the examples repo anyway.