October 2017
Intermediate to advanced
442 pages
12h 33m
English
The following statistics implementation observes the domain event specified earlier and stores the information in the Prometheus counter metric:
import io.prometheus.client.Counter;
@ApplicationScoped
public class ManufacturingStatistics {
private Counter createdCars;
@PostConstruct
private void initMetrics() {
createdCars = Counter.build("cars_manufactured_total", "Total number of manufactured cars")
.labelNames("color", "engine")
.register();
}
public void carCreated(@Observes(during = TransactionPhase.AFTER_SUCCESS) Specification spec) { createdCars.labels(spec.getColor().name(), spec.getEngine().name()).inc();
}
}
The counter metric is created and registered to the Prometheus Client API. Measured values are qualified ...
Read now
Unlock full access