Skip to content

Commit

Permalink
fix(core): fix stats webserver (#3408)
Browse files Browse the repository at this point in the history
Fix: #3408
  • Loading branch information
fhussonnois authored and loicmathieu committed Mar 28, 2024
1 parent e32a390 commit b6d6e83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions core/src/main/java/io/kestra/core/services/CollectorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,25 @@ protected synchronized Usage defaultUsage() {
}

public Usage metrics() {
Usage.UsageBuilder<?, ?> builder = defaultUsage().toBuilder()
return metrics(true);
}

private Usage metrics(boolean details) {
Usage.UsageBuilder<?, ?> builder = defaultUsage()
.toBuilder()
.uuid(IdUtils.create());

if (serverType == ServerType.EXECUTOR || serverType == ServerType.STANDALONE) {
builder
.flows(FlowUsage.of(flowRepository))
.executions(ExecutionUsage.of(executionRepository));
if (details) {
builder = builder
.flows(FlowUsage.of(flowRepository))
.executions(ExecutionUsage.of(executionRepository));
}

return builder.build();
}

public void report() {
try {
Usage metrics = this.metrics();
Usage metrics = this.metrics(serverType == ServerType.EXECUTOR || serverType == ServerType.STANDALONE);
MutableHttpRequest<Usage> post = this.request(metrics);

if (log.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public void metrics() throws URISyntaxException {
assertThat(metrics.getHost().getOs().getFamily(), notNullValue());
assertThat(metrics.getConfigurations().getRepositoryType(), is("memory"));
assertThat(metrics.getConfigurations().getQueueType(), is("memory"));
assertThat(metrics.getExecutions(), notNullValue());
assertThat(metrics.getExecutions().getDailyExecutionsCount().size(), is(0));
assertThat(metrics.getExecutions().getDailyTaskRunsCount().size(), is(0));
assertThat(metrics.getInstanceUuid(), is(TestSettingRepository.instanceUuid));
}
}
Expand Down

0 comments on commit b6d6e83

Please sign in to comment.