Emits statistics of Porcupine pipelines via MicroProfile metrics.
Add the following dependency to your project build.
It depends on Porcupine 0.0.4
, CDI 1.1
, and MicroProfile Metrics 1.0
.
<dependency>
<groupId>com.sebastian-daschner</groupId>
<artifactId>porcupine-metrics</artifactId>
<version>1.0</version>
</dependency>
Inject the bean PorcupineMetrics
and invoke the updateMetrics
method as often as you want the metrics to be updated.
Due to Porcupine’s statistics internals, the update mechanism currently requires to be triggered explicitly, e.g. via timer:
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class ExecutorStatisticsUpdater {
@Inject
PorcupineMetrics porcupineMetrics;
@Resource
ManagedScheduledExecutorService scheduler;
@PostConstruct
public void init() {
scheduler.scheduleAtFixedRate(porcupineMetrics::updateMetrics,
0, 5, TimeUnit.SECONDS);
}
}
For more information see Instrumenting Porcupine With Prometheus & Grafana.