Skip to content

Commit f96b765

Browse files
committed
add latencies to logs
1 parent e4f9cd9 commit f96b765

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

examples/src/main/resources/log4j2.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
</Appenders>
88

99
<Loggers>
10+
<Logger name="com.amazonaws.lambda.durable" level="INFO"/>
11+
1012
<!-- AWS SDK logs at WARN -->
1113
<Logger name="software.amazon.awssdk" level="WARN" />
1214

sdk/src/main/java/com/amazonaws/lambda/durable/client/LambdaDurableFunctionsClient.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import java.util.List;
66
import java.util.Objects;
7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
97
import software.amazon.awssdk.services.lambda.LambdaClient;
108
import software.amazon.awssdk.services.lambda.model.CheckpointDurableExecutionRequest;
119
import software.amazon.awssdk.services.lambda.model.CheckpointDurableExecutionResponse;
@@ -15,7 +13,6 @@
1513

1614
public class LambdaDurableFunctionsClient implements DurableExecutionClient {
1715

18-
private static final Logger logger = LoggerFactory.getLogger(LambdaDurableFunctionsClient.class);
1916
private final LambdaClient lambdaClient;
2017

2118
/**
@@ -35,7 +32,6 @@ public CheckpointDurableExecutionResponse checkpoint(String arn, String token, L
3532
.checkpointToken(token)
3633
.updates(updates)
3734
.build();
38-
logger.debug("Calling durable backend with {} updates: {}", updates.size(), request);
3935

4036
return lambdaClient.checkpointDurableExecution(request);
4137
}

sdk/src/main/java/com/amazonaws/lambda/durable/execution/CheckpointBatcher.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@ public List<Operation> fetchAllPages(CheckpointUpdatedExecutionState checkpointU
110110
}
111111
var nextMarker = checkpointUpdatedExecutionState.nextMarker();
112112
while (nextMarker != null && !nextMarker.isEmpty()) {
113+
var startTime = System.nanoTime();
113114
var response = config.getDurableExecutionClient()
114115
.getExecutionState(durableExecutionArn, checkpointToken, nextMarker);
115-
logger.debug("Durable API getExecutionState called: {}.", response);
116+
logger.debug(
117+
"Durable getExecutionState API called (latency={}ns): {}.",
118+
System.nanoTime() - startTime,
119+
response);
116120
operations.addAll(response.operations());
117121
nextMarker = response.nextMarker();
118122
}
@@ -130,9 +134,10 @@ private void doBatchAction(List<OperationUpdate> updates) {
130134
return;
131135
}
132136

133-
logger.debug("Calling durable API checkpointDurableExecution with {} updates", request.size());
137+
var startTime = System.nanoTime();
138+
logger.debug("Calling durable checkpoint API with {} updates: {}", updates.size(), request);
134139
var response = config.getDurableExecutionClient().checkpoint(durableExecutionArn, checkpointToken, request);
135-
logger.debug("Durable API checkpointDurableExecution called: {}.", response);
140+
logger.debug("Durable checkpoint API called (latency={}ns): {}.", System.nanoTime() - startTime, response);
136141

137142
// Notify callback of completion
138143
// TODO: sam local backend returns no new execution state when called with zero
@@ -144,16 +149,26 @@ private void doBatchAction(List<OperationUpdate> updates) {
144149
// fetch all pages of operations
145150
var operations = fetchAllPages(response.newExecutionState());
146151

152+
var processStartTime = System.nanoTime();
153+
int completedFutures = 0;
154+
logger.debug(
155+
"Processing {} operations. ({} pending pollers)", operations.size(), pollingFutures.size());
147156
// call the callback
148157
callback.accept(operations);
149158

150159
// complete the registered pollingFutures
151160
for (var operation : operations) {
152161
var pollers = pollingFutures.remove(operation.id());
153162
if (pollers != null) {
163+
completedFutures += pollers.size();
154164
pollers.forEach(poller -> poller.complete(operation));
155165
}
156166
}
167+
logger.debug(
168+
"{} operations processed and {} pollers completed (latency={}ns). ",
169+
operations.size(),
170+
completedFutures,
171+
System.nanoTime() - processStartTime);
157172
}
158173
}
159174
}

0 commit comments

Comments
 (0)