use of org.kie.server.services.prometheus.PrometheusKieServerExtension in project droolsjbpm-integration by kiegroup.
the class SolverServiceBase method registerListener.
private void registerListener(Solver solver, String solverId) {
PrometheusKieServerExtension extension = (PrometheusKieServerExtension) context.getServerExtension(PrometheusKieServerExtension.EXTENSION_NAME);
if (extension != null) {
((AbstractSolver) solver).addPhaseLifecycleListener(new PrometheusMetricsSolverListener(solverId));
// custom listeners; no need to check double listener registration as we call registerListener on solver create
extension.getOptaPlannerListeners(solverId).forEach(l -> ((AbstractSolver) solver).addPhaseLifecycleListener(l));
}
}
use of org.kie.server.services.prometheus.PrometheusKieServerExtension in project droolsjbpm-integration by kiegroup.
the class ModelEvaluatorServiceBase method wirePrometheus.
private void wirePrometheus(KieContainerInstanceImpl kContainer, DMNRuntime dmnRuntime) {
PrometheusKieServerExtension extension = (PrometheusKieServerExtension) context.getServerExtension(PrometheusKieServerExtension.EXTENSION_NAME);
if (extension != null) {
// default handler
PrometheusMetricsDMNListener listener = new PrometheusMetricsDMNListener(PrometheusKieServerExtension.getMetrics(), kContainer);
dmnRuntime.addListener(listener);
// custom handler
List<DMNRuntimeEventListener> listeners = extension.getDMNRuntimeListeners(kContainer);
listeners.forEach(l -> {
if (!dmnRuntime.getListeners().contains(l)) {
dmnRuntime.addListener(l);
}
});
}
}
use of org.kie.server.services.prometheus.PrometheusKieServerExtension in project droolsjbpm-integration by kiegroup.
the class DroolsKieSessionLookupHandler method postLookupKieSession.
@Override
public void postLookupKieSession(String kieSessionId, KieContainerInstance containerInstance, CommandExecutor ks, KieServerRegistry registry) {
PrometheusKieServerExtension extension = (PrometheusKieServerExtension) registry.getServerExtension(PrometheusKieServerExtension.EXTENSION_NAME);
if (extension != null && ks instanceof RuleRuntimeEventManager) {
RuleRuntimeEventManager eventManager = (RuleRuntimeEventManager) ks;
if (kieSessionId == null || kieSessionId.isEmpty()) {
kieSessionId = DEFAULT_KIE_SESSION_ID;
}
// default handler
if (eventManager.getAgendaEventListeners().stream().noneMatch(PrometheusMetricsDroolsListener.class::isInstance)) {
PrometheusMetricsDroolsListener listener = new PrometheusMetricsDroolsListener(PrometheusKieServerExtension.getMetrics(), kieSessionId, containerInstance);
eventManager.addEventListener(listener);
}
// custom handlers
List<AgendaEventListener> droolsListeners = extension.getDroolsListeners(kieSessionId, containerInstance);
droolsListeners.forEach(l -> {
if (!eventManager.getAgendaEventListeners().contains(l)) {
eventManager.addEventListener(l);
}
});
}
}
Aggregations