Skip to content

Commit

Permalink
Do not run capture if metrics are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed May 8, 2024
1 parent 8fd0bca commit c535e9c
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ public TelemetrySubmissionPeriodical(TelemetryClient telemetryClient,

@Override
public void doRun() {
if (telemetryClient.isEnabled()) {
final var telemetryMetrics = metricsProviders.entrySet()
.stream()
.map(entry -> entry(entry.getKey(), entry.getValue().get()))
.flatMap(entry -> entry.getValue().map(metrics -> entry(entry.getKey(), metrics)).stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
try {
final var telemetryMetrics = metricsProviders.entrySet()
.stream()
.map(entry -> entry(entry.getKey(), entry.getValue().get()))
.flatMap(entry -> entry.getValue().map(metrics -> entry(entry.getKey(), metrics)).stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
try {
if (!telemetryMetrics.isEmpty()) {
telemetryClient.capture(telemetryMetrics);
} catch (Exception e) {
LOG.warn("Error while submitting telemetry: ", e);
}
} catch (Exception e) {
LOG.warn("Error while submitting telemetry: ", e);
}
}

Expand Down

0 comments on commit c535e9c

Please sign in to comment.