-
Notifications
You must be signed in to change notification settings - Fork 37
Custom actuator metric with request counter #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: support/1.18.x
Are you sure you want to change the base?
Conversation
b1a58f1 to
e957051
Compare
|
Initially I implemented this by extending However, a micrometer dev suggested another approach in this comment from 2018. The latest and greatest approach is probably to override either DefaultServerRequestObservationConvention, or micrometer ObservationFilter, as mentioned in the observability docs. |
eca3a0e to
401221b
Compare
|
ran into #839 |
Creates a custom actuator metric that counts requests to custom endpoints
and use Optional to handle nullable query string
conforming to the existing http.server.requests metric name
…ionFilter implementation following the examples from the spring-boot docs https://docs.spring.io/spring-framework/reference/integration/observability.html#observability.config.conventions
401221b to
4c69720
Compare
For #661 we are interested in counting the requests to individual resources.
However, the default Spring MVC actuator metric http.server.requests does not count requests for individual resources. Instead, it only shows counts for the path patterns defined for the controllers, such as
FAIRDataPoint/src/main/java/org/fairdatapoint/api/controller/metadata/GenericController.java
Line 150 in f65cd35
To count requests to individual resource URIs, I added a custom micrometer
ObservationFilterimplementation that replaces the defaulturipath pattern by the full path. Also see spring observability docs.Note
Although it is relatively quick and easy to use Spring actuator metrics for this, I'm not convinced this is the best approach. I think it would make more sense to do this at the deployment level, e.g. based on proxy logs, instead of the app level.
fixes #661
todo
So, figure out why the following lines are ignored by the fdp, whereas they do work in a fresh spring project, and they also work without issue if we apply them to the
developbranch...FAIRDataPoint/src/main/resources/application.yml
Lines 35 to 39 in 4c69720
usage example
{ "name": "http.server.requests", "baseUnit": "seconds", "measurements": [ { "statistic": "COUNT", "value": 3.0 }, { "statistic": "TOTAL_TIME", "value": 0.042224172 }, { "statistic": "MAX", "value": 0.02092224 } ], "availableTags": [ { "tag": "exception", "values": [ "none" ] }, { "tag": "method", "values": [ "GET" ] }, { "tag": "error", "values": [ "none" ] }, { "tag": "outcome", "values": [ "SUCCESS" ] }, { "tag": "status", "values": [ "200" ] } ] }