Skip to content

Commit 343df12

Browse files
committed
Mention "warn threshold" in master service slowlog (#76815)
We tend to include the phrase `warn threshold` in log messages indicating that something took much longer than we expected. The `MasterService` has some log messages that date from before the adoption of this convention. This commit adds the phrase `warn threshold` to those logs. Relates #76625
1 parent 40242a8 commit 343df12

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,13 @@ public TimeValue ackTimeout() {
606606

607607
private void logExecutionTime(TimeValue executionTime, String activity, String summary) {
608608
if (executionTime.getMillis() > slowTaskLoggingThreshold.getMillis()) {
609-
logger.warn("took [{}], which is over [{}], to {} for [{}]", executionTime, slowTaskLoggingThreshold, activity, summary);
609+
logger.warn(
610+
"took [{}/{}ms] to {} for [{}], which exceeds the warn threshold of [{}]",
611+
executionTime,
612+
executionTime.getMillis(),
613+
activity,
614+
summary,
615+
slowTaskLoggingThreshold);
610616
} else {
611617
logger.debug("took [{}] to {} for [{}]", executionTime, activity, summary);
612618
}

server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,19 +686,19 @@ public void testLongClusterStateUpdateLogging() throws Exception {
686686
"test2",
687687
MasterService.class.getCanonicalName(),
688688
Level.WARN,
689-
"*took [*], which is over [10s], to compute cluster state update for [test2]"));
689+
"*took [*] to compute cluster state update for [test2], which exceeds the warn threshold of [10s]"));
690690
mockAppender.addExpectation(
691691
new MockLogAppender.SeenEventExpectation(
692692
"test3",
693693
MasterService.class.getCanonicalName(),
694694
Level.WARN,
695-
"*took [*], which is over [10s], to compute cluster state update for [test3]"));
695+
"*took [*] to compute cluster state update for [test3], which exceeds the warn threshold of [10s]"));
696696
mockAppender.addExpectation(
697697
new MockLogAppender.SeenEventExpectation(
698698
"test4",
699699
MasterService.class.getCanonicalName(),
700700
Level.WARN,
701-
"*took [*], which is over [10s], to compute cluster state update for [test4]"));
701+
"*took [*] to compute cluster state update for [test4], which exceeds the warn threshold of [10s]"));
702702
mockAppender.addExpectation(
703703
new MockLogAppender.UnseenEventExpectation(
704704
"test5 should not log despite publishing slowly",

0 commit comments

Comments
 (0)