Skip to content

Commit

Permalink
[metrics collector] fix timeout + more verbose in case of failure
Browse files Browse the repository at this point in the history
Signed-off-by: see-quick <[email protected]>
  • Loading branch information
see-quick committed Jun 6, 2024
1 parent d6f7fbc commit 6759581
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,13 @@ public final void collectMetricsFromPods(long timeoutDuration) {
if (metricsData.isEmpty()) {
status.setMessage("No pods found or no metrics available from pods.");
status.setType(MetricsCollectionStatus.Type.NO_DATA);
LOGGER.error("Metrics collection failed: {}", status.getMessage());
return false;
}
if (metricsData.values().stream().anyMatch(String::isEmpty)) {
status.setMessage("Incomplete metrics data collected.");
status.setType(MetricsCollectionStatus.Type.INCOMPLETE_DATA);
LOGGER.error("Metrics collection incomplete: Some pods returned empty metrics.");
return false;
}
this.collectedData = metricsData;
Expand All @@ -453,12 +455,14 @@ public final void collectMetricsFromPods(long timeoutDuration) {
status.setMessage(e.getMessage());
status.setType(MetricsCollectionStatus.Type.ERROR);
status.setException(e);
LOGGER.error("Error during metrics collection: {}", status.getMessage(), e);
return false;
}
},
() -> LOGGER.error("Failed to collect metrics: {}", status.getMessage())
() -> LOGGER.error("Failed to collect metrics within the allowed time: {}", status.getMessage())
);
} catch (WaitException we) {
LOGGER.error("Metrics collection terminated due to timeout: {}", we.getMessage());
throw determineExceptionFromStatus(status);
}
}
Expand Down Expand Up @@ -521,7 +525,7 @@ public void setType(Type type) {
* collection logic.
*/
public final void collectMetricsFromPods() throws MetricsCollectionException {
collectMetricsFromPods(Duration.ofSeconds(TestFrameConstants.GLOBAL_TIMEOUT_MEDIUM).toMillis());
collectMetricsFromPods(TestFrameConstants.GLOBAL_TIMEOUT_MEDIUM);
}

/**
Expand Down

0 comments on commit 6759581

Please sign in to comment.