Skip to content

Commit

Permalink
Avoid negative duration value for metrics calculated from Discord tim…
Browse files Browse the repository at this point in the history
…estamps
  • Loading branch information
schnapster committed Jan 2, 2025
1 parent 7d97fa0 commit b7eaefe
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ private void reply0(MessageCreateData message, @Nullable Consumer<Message> onSuc
sample.stop(metricsService.commandResponseTime());
Instant in = getMessage().getTimeCreated().toInstant();
Instant out = m.getTimeCreated().toInstant();
metricsService.commandTotalTime().record(Duration.between(in, out));
Duration between = Duration.between(in, out);
if (between.isNegative()) {
//it has happened before...wtf
between = Duration.ZERO;
}
metricsService.commandTotalTime().record(between);
if (onSuccess != null) {
onSuccess.accept(m);
}
Expand Down

0 comments on commit b7eaefe

Please sign in to comment.