use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project Activiti by Activiti.
the class ProcessEngineEndpoint method invoke.
@ReadOperation
public Map<String, Object> invoke() {
Map<String, Object> metrics = new HashMap<String, Object>();
// Process definitions
metrics.put("processDefinitionCount", processEngine.getRepositoryService().createProcessDefinitionQuery().count());
// List of all process definitions
List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().orderByProcessDefinitionKey().asc().list();
List<String> processDefinitionKeys = new ArrayList<String>();
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionKeys.add(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")");
}
metrics.put("deployedProcessDefinitions", processDefinitionKeys);
// Process instances
Map<String, Object> processInstanceCountMap = new HashMap<String, Object>();
metrics.put("runningProcessInstanceCount", processInstanceCountMap);
for (ProcessDefinition processDefinition : processDefinitions) {
processInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).count());
}
Map<String, Object> completedProcessInstanceCountMap = new HashMap<String, Object>();
metrics.put("completedProcessInstanceCount", completedProcessInstanceCountMap);
for (ProcessDefinition processDefinition : processDefinitions) {
completedProcessInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getHistoryService().createHistoricProcessInstanceQuery().finished().processDefinitionId(processDefinition.getId()).count());
}
// Open tasks
metrics.put("openTaskCount", processEngine.getTaskService().createTaskQuery().count());
metrics.put("completedTaskCount", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().count());
// Tasks completed today
metrics.put("completedTaskCountToday", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().taskCompletedAfter(new Date(System.currentTimeMillis() - secondsForDays(1))).count());
// Process steps
metrics.put("completedActivities", processEngine.getHistoryService().createHistoricActivityInstanceQuery().finished().count());
// Process definition cache
DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getProcessDefinitionCache();
if (deploymentCache instanceof DefaultDeploymentCache) {
metrics.put("cachedProcessDefinitionCount", ((DefaultDeploymentCache) deploymentCache).size());
}
return metrics;
}
use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project spring-cloud-netflix by spring-cloud.
the class FiltersEndpoint method invoke.
@ReadOperation
public Map<String, List<Map<String, Object>>> invoke() {
// Map of filters by type
final Map<String, List<Map<String, Object>>> filterMap = new TreeMap<>();
for (ZuulFilter filter : this.filterRegistry.getAllFilters()) {
// Ensure that we have a list to store filters of each type
if (!filterMap.containsKey(filter.filterType())) {
filterMap.put(filter.filterType(), new ArrayList<>());
}
final Map<String, Object> filterInfo = new LinkedHashMap<>();
filterInfo.put("class", filter.getClass().getName());
filterInfo.put("order", filter.filterOrder());
filterInfo.put("disabled", filter.isFilterDisabled());
filterInfo.put("static", filter.isStaticFilter());
filterMap.get(filter.filterType()).add(filterInfo);
}
return filterMap;
}
Aggregations