Add total Users metric
This commit is contained in:
parent
e801bbf2e2
commit
961a4df270
|
@ -35,7 +35,8 @@ public class MetricsManager {
|
||||||
{"totalTemplates", Gauge.build("total_templates", "Number of total Templates").register()},
|
{"totalTemplates", Gauge.build("total_templates", "Number of total Templates").register()},
|
||||||
{"activeTemplates", Gauge.build("active_templates", "Number of active Templates").register()},
|
{"activeTemplates", Gauge.build("active_templates", "Number of active Templates").register()},
|
||||||
{"usedTemplates", Gauge.build("used_templates", "Number of used Templates").register()},
|
{"usedTemplates", Gauge.build("used_templates", "Number of used Templates").register()},
|
||||||
{"languages", Gauge.build("languages", "Number of Languages").register()}
|
{"languages", Gauge.build("languages", "Number of Languages").register()},
|
||||||
|
{"totalUsers", Gauge.build("total_users", "Total Number of Users").register()}
|
||||||
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
|
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
|
||||||
|
|
||||||
public static void increaseValue(String name, int amount) {
|
public static void increaseValue(String name, int amount) {
|
||||||
|
@ -96,6 +97,7 @@ public class MetricsManager {
|
||||||
calculateValue("activeTemplates", (int) datasetProfileManager.countAllFinalized());
|
calculateValue("activeTemplates", (int) datasetProfileManager.countAllFinalized());
|
||||||
calculateValue("usedTemplates", (int) datasetProfileManager.countAllUsed());
|
calculateValue("usedTemplates", (int) datasetProfileManager.countAllUsed());
|
||||||
calculateValue("usersLoggedIn", userManager.countActiveUsers().intValue());
|
calculateValue("usersLoggedIn", userManager.countActiveUsers().intValue());
|
||||||
|
calculateValue("totalUsers", userManager.countAllUsers().intValue());
|
||||||
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
|
||||||
calculateValue("languages", (int) files);
|
calculateValue("languages", (int) files);
|
||||||
logger.info("Metrics calculation Completed");
|
logger.info("Metrics calculation Completed");
|
||||||
|
|
|
@ -248,5 +248,9 @@ public class UserManager {
|
||||||
public Long countActiveUsers(){
|
public Long countActiveUsers(){
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count();
|
return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long countAllUsers(){
|
||||||
|
return apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().count();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue