I have Spring Boot 2 web app in which I need to identify site visitor by cookie and gather page view stats. So I need to intercept every web request. The code I had to write is
For gathering page view stats I'll suggest to change the strategy and use Actuator and Micrometer instead:
metrics
)/actuator/metrics
and select the metric for server HTTP requests (see the reference documentation).Micrometer offers way more and helps you to get your metrics right, like: taking into account GC pauses when measuring time, providing histograms/percentiles/..., and more.