Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only keep the most recent 50 failure events #2107

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class SingularityDeployStatisticsBuilder {
private final String requestId;
Expand Down Expand Up @@ -173,6 +175,16 @@ public SingularityDeployStatisticsBuilder addTaskFailureEvent(
return this;
}

public SingularityDeployStatisticsBuilder trimTaskFailureEvents(int countToKeep) {
this.taskFailureEvents =
taskFailureEvents
.stream()
.sorted(Comparator.comparingLong(TaskFailureEvent::getTimestamp).reversed())
.limit(countToKeep)
.collect(Collectors.toList());
return this;
}

@Override
public String toString() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ private void updateDeployStatistics(
bldr.setNumSequentialRetries(0);
}

bldr.trimTaskFailureEvents(50);
final SingularityDeployStatistics newStatistics = bldr.build();

LOG.trace("Saving new deploy statistics {}", newStatistics);
Expand Down