A bit of documentation.

master
Rémi Cocula 8 years ago
parent 88e820d8d1
commit aec131a3d1
  1. 18
      documentation/developer/Performance-Metrics.md
  2. BIN
      documentation/developer/metrics-visualvm-screenshot.png
  3. 1
      libresonic-main/src/main/java/org/libresonic/player/filter/MetricsFilter.java

@ -0,0 +1,18 @@
The Libresonic framework contains a convenient class (called MetricsManager) to add inner metrics that constructs in real time some performance indicators.
The use of MetricsManager is illustrated in the org.libresonic.player.filter.MetricsFilter class.
The MetricsFilter adds a metric based on the time spent by each /main.view HTTP request. This is interesting as the main.view request is invoqued when something is displayed in the main Libresonic web frame.
By default, the MetricsManager is deactivated; it does nothing.
It can be activated only by adding the following line inside the livresonic.properties configuration file :
```
Metrics=
```
Once the MetricsManager as been activated this way, each metric can be inspected using a jmx console like VisualVM.
Each metric is registered as a MBean as shown below.
![](metrics-visualvm-screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

@ -25,6 +25,7 @@ public class MetricsFilter implements Filter {
HttpServletRequest httpServletRequest = (HttpServletRequest)request; HttpServletRequest httpServletRequest = (HttpServletRequest)request;
String timerName = httpServletRequest.getRequestURI(); String timerName = httpServletRequest.getRequestURI();
// Add a metric that measures the time spent for each http request for the /main.view url.
try (MetricsManager.Timer t = metricsManager.condition(timerName.contains("main.view")).timer(this,timerName)) { try (MetricsManager.Timer t = metricsManager.condition(timerName.contains("main.view")).timer(this,timerName)) {
chain.doFilter(request, response); chain.doFilter(request, response);
} }

Loading…
Cancel
Save