Skip to content

Commit f6f7b7b

Browse files
committed
* action: added ActionLogContext.maxProcessTime(duration)
Signed-off-by: neo <[email protected]>
1 parent e15f6ce commit f6f7b7b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
> migrated to apache httpclient 5
99
> simplify logging
1010
> remove opentelemetry dependency
11+
* action: added ActionLogContext.maxProcessTime(duration)
12+
> for long and non-critical action (such as test jobs), set max process time to avoid SLOW_PROCESS warning
1113
1214
### 9.1.8 (3/7/2025 - 4/24/2025)
1315

core-ng/src/main/java/core/framework/internal/web/sse/ServerSentEventHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void handleRequest(HttpServerExchange exchange) {
6262
if (sink.flush()) {
6363
exchange.dispatch(() -> handle(exchange, sink));
6464
} else {
65-
var listener = ChannelListeners.flushingChannelListener(channel -> exchange.dispatch(() -> handle(exchange, sink)),
66-
(channel, e) -> {
65+
var listener = ChannelListeners.flushingChannelListener(_ -> exchange.dispatch(() -> handle(exchange, sink)),
66+
(_, e) -> {
6767
logger.warn("failed to establish sse connection, error={}", e.getMessage(), e);
6868
IoUtils.safeClose(exchange.getConnection());
6969
});

core-ng/src/main/java/core/framework/log/ActionLogContext.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public static void triggerTrace(boolean cascade) {
6666
}
6767
}
6868

69+
// for non-critical actions, set max process time to avoid slow_process warning
70+
public static void maxProcessTime(Duration duration) {
71+
ActionLog actionLog = LogManager.CURRENT_ACTION_LOG.get();
72+
if (actionLog != null) {
73+
actionLog.warningContext.maxProcessTimeInNano(duration.toNanos());
74+
}
75+
}
76+
6977
// for long process, use this guidance to determine whether continue to do more work
7078
@Nullable
7179
public static Duration remainingProcessTime() {

core-ng/src/test/java/core/framework/log/ActionLogContextTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package core.framework.log;
22

3-
import core.framework.internal.log.ActionLog;
43
import core.framework.internal.log.LogManager;
54
import core.framework.internal.log.Trace;
65
import org.junit.jupiter.api.Test;
@@ -59,9 +58,9 @@ void remainingProcessTime() {
5958
assertThat(ActionLogContext.remainingProcessTime()).isNull();
6059

6160
var logManager = new LogManager();
62-
ActionLog log = logManager.begin("begin", null);
63-
log.warningContext.maxProcessTimeInNano(Duration.ofSeconds(30).toNanos());
64-
assertThat(ActionLogContext.remainingProcessTime()).isGreaterThan(Duration.ZERO);
61+
logManager.begin("begin", null);
62+
ActionLogContext.maxProcessTime(Duration.ofMinutes(30));
63+
assertThat(ActionLogContext.remainingProcessTime()).isGreaterThan(Duration.ofMinutes(20));
6564
logManager.end("end");
6665
}
6766
}

0 commit comments

Comments
 (0)