Skip to content

Commit b32a71a

Browse files
committed
Logging fixes
1 parent 0a7f339 commit b32a71a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/DynamoDBStreamsEventSource/DynamoDBStreamsEventSourceBackgroundService.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private async Task PollStream(string streamArn, CancellationToken stoppingToken)
135135
}
136136

137137
var activeCount = tasks.Count;
138-
_logger.LogInformation("Polling {activeShardCount} active shard(s)", activeCount);
138+
_logger.LogDebug("Polling {activeShardCount} active shard(s)", activeCount);
139139

140140
if (activeCount == 0)
141141
{
@@ -161,7 +161,7 @@ private async Task PollStream(string streamArn, CancellationToken stoppingToken)
161161
if (response.NextShardIterator == null)
162162
{
163163
_logger.LogInformation("Shard {shardId} exhausted (closed), records in final batch: {count}",
164-
shardId, response.Records.Count);
164+
shardId, response.Records?.Count);
165165
shardIterators.Remove(shardId);
166166
shardExhausted = true;
167167
}
@@ -170,7 +170,7 @@ private async Task PollStream(string streamArn, CancellationToken stoppingToken)
170170
shardIterators[shardId] = response.NextShardIterator;
171171
}
172172

173-
if (response.Records.Count == 0)
173+
if (response.Records == null || response.Records.Count == 0)
174174
continue;
175175

176176
hasRecords = true;
@@ -254,6 +254,8 @@ private async Task PollStream(string streamArn, CancellationToken stoppingToken)
254254
_logger.LogInformation("Got LATEST iterator for startup shard {shardId}", shard.ShardId);
255255
iterators[shard.ShardId] = iteratorResponse.ShardIterator;
256256
}
257+
_logger.LogInformation("Initial shard discovery complete: {openCount} open shard(s), {closedCount} closed shard(s) at startup",
258+
iterators.Count, closedAtStartup.Count);
257259

258260
return iterators;
259261
}
@@ -294,7 +296,7 @@ private async Task PollStream(string streamArn, CancellationToken stoppingToken)
294296

295297
private async Task<List<Shard>> GetAllShards(string streamArn, CancellationToken stoppingToken)
296298
{
297-
_logger.LogInformation("Discovering shards for stream {streamArn}", streamArn);
299+
_logger.LogDebug("Discovering shards for stream {streamArn}", streamArn);
298300
var shards = new List<Shard>();
299301
string? lastEvaluatedShardId = null;
300302

@@ -310,7 +312,7 @@ private async Task<List<Shard>> GetAllShards(string streamArn, CancellationToken
310312
lastEvaluatedShardId = describeResponse.StreamDescription.LastEvaluatedShardId;
311313
} while (lastEvaluatedShardId != null);
312314

313-
_logger.LogInformation("Discovered {shardCount} shard(s)", shards.Count);
315+
_logger.LogDebug("There were {shardCount} shard(s) returned from DescribeStream", shards.Count);
314316
return shards;
315317
}
316318

0 commit comments

Comments
 (0)