Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebJobs][EventHubsExtension] Fix metrics when azure checkpoint container does not exist #43213

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task<EventHubsTriggerMetrics> GetMetricsAsync()
}

await Task.WhenAll(partitionPropertiesTasks).ConfigureAwait(false);
EventProcessorCheckpoint[] checkpoints;
EventProcessorCheckpoint[] checkpoints = null;

try
{
Expand All @@ -81,7 +81,6 @@ public async Task<EventHubsTriggerMetrics> GetMetricsAsync()
catch
{
// GetCheckpointsAsync would log
return metrics;
}

return CreateTriggerMetrics(partitionPropertiesTasks.Select(t => t.Result).ToList(), checkpoints);
Expand All @@ -103,7 +102,11 @@ private EventHubsTriggerMetrics CreateTriggerMetrics(List<PartitionProperties> p
{
var partitionProperties = partitionRuntimeInfo[i];

var checkpoint = (BlobCheckpointStoreInternal.BlobStorageCheckpoint)checkpoints.SingleOrDefault(c => c?.PartitionId == partitionProperties.Id);
BlobCheckpointStoreInternal.BlobStorageCheckpoint checkpoint = null;
if (checkpoints != null)
{
checkpoint = (BlobCheckpointStoreInternal.BlobStorageCheckpoint)checkpoints.SingleOrDefault(c => c?.PartitionId == partitionProperties.Id);
}

// Check for the unprocessed messages when there are messages on the Event Hub partition
// In that case, LastEnqueuedSequenceNumber will be >= 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public async Task CreateTriggerMetrics_HandlesExceptions()
var metrics = await _metricsProvider.GetMetricsAsync();

Assert.AreEqual(1, metrics.PartitionCount);
Assert.AreEqual(0, metrics.EventCount);
Assert.AreEqual(1, metrics.EventCount);
Assert.AreNotEqual(default(DateTime), metrics.Timestamp);

// Generic Exception
Expand All @@ -222,7 +222,7 @@ public async Task CreateTriggerMetrics_HandlesExceptions()
metrics = await _metricsProvider.GetMetricsAsync();

Assert.AreEqual(1, metrics.PartitionCount);
Assert.AreEqual(0, metrics.EventCount);
Assert.AreEqual(1, metrics.EventCount);
Assert.AreNotEqual(default(DateTime), metrics.Timestamp);

_loggerProvider.ClearAllLogMessages();
Expand Down
Loading