Metrics

Metrics are crucial to determine the current status of the proxy server. Various indicators for a developing problem can be observed beforehand and an appropriate action can follow. For this purpose, the App Suite Proxy has its own metric endpoint which delivers all collected metrics in Prometheus format. The endpoint is located under /metrics path. The complete documentation of the text output format can be found here.

Overview

To enable the prometheus output format, a dedicated Prometheus registry had to be provided by default. This Registry provides a method to translate all registered meters into a Prometheus readable format. This way, all metric types that are provided by the spectator API can be translated into Prometheus format without additional work.

Concept & Example

Since the Prometheus registry does not translate any of the Spectator API fields into a decent “HELP” comment and can also not be registered directly, it is capsuled in a MicrometerRegistry. When creating a new meter the developer has to consider this. Therefore all new meters have to be registered in the dedicated AppSuiteProxyRegistry class and got to be a subtype of io.micrometer.core.instrument.Meter. Let´s look at an example:

import com.google.inject.Inject;
import io.micrometer.core.instrument.Counter;
import io.ox.proxy.metric.AppSuiteProxyRegistry;

public class ToMeasure {

    private final AppSuiteProxyRegistry appSuiteProxyRegistry;
    private final Counter counter;

    @Inject
    public ToMeasure(AppSuiteProxyRegistry appSuiteProxyRegistry) {
        this.appSuiteProxyRegistry = appSuiteProxyRegistry;
        this.counter = io.micrometer.core.instrument.Counter.builder("my_counter").description("my help text").register(this.appSuiteProxyRegistry);
    }

    public void doSomething() {
        //some code here
        counter.increment();
        //some code here
    }
}

As you can see the instance of Counter is a micrometer type. The description provides the Prometheus registry (AppSuiteProxyRegistry) with the “HELP” text. To get more information on the available meters and their usage, take a look at the micrometer documentation.