Search in sources :

Example 1 with PrometheusKieServerExtension

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));
    }
}
Also used : PrometheusKieServerExtension(org.kie.server.services.prometheus.PrometheusKieServerExtension) PrometheusMetricsSolverListener(org.kie.server.services.prometheus.PrometheusMetricsSolverListener) AbstractSolver(org.optaplanner.core.impl.solver.AbstractSolver)

Example 2 with PrometheusKieServerExtension

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);
            }
        });
    }
}
Also used : PrometheusKieServerExtension(org.kie.server.services.prometheus.PrometheusKieServerExtension) PrometheusMetricsDMNListener(org.kie.server.services.prometheus.PrometheusMetricsDMNListener) DMNRuntimeEventListener(org.kie.dmn.api.core.event.DMNRuntimeEventListener)

Example 3 with PrometheusKieServerExtension

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);
            }
        });
    }
}
Also used : PrometheusKieServerExtension(org.kie.server.services.prometheus.PrometheusKieServerExtension) RuleRuntimeEventManager(org.kie.api.event.rule.RuleRuntimeEventManager) PrometheusMetricsDroolsListener(org.kie.server.services.prometheus.PrometheusMetricsDroolsListener) AgendaEventListener(org.kie.api.event.rule.AgendaEventListener)

Aggregations

PrometheusKieServerExtension (org.kie.server.services.prometheus.PrometheusKieServerExtension)3 AgendaEventListener (org.kie.api.event.rule.AgendaEventListener)1 RuleRuntimeEventManager (org.kie.api.event.rule.RuleRuntimeEventManager)1 DMNRuntimeEventListener (org.kie.dmn.api.core.event.DMNRuntimeEventListener)1 PrometheusMetricsDMNListener (org.kie.server.services.prometheus.PrometheusMetricsDMNListener)1 PrometheusMetricsDroolsListener (org.kie.server.services.prometheus.PrometheusMetricsDroolsListener)1 PrometheusMetricsSolverListener (org.kie.server.services.prometheus.PrometheusMetricsSolverListener)1 AbstractSolver (org.optaplanner.core.impl.solver.AbstractSolver)1