File tree Expand file tree Collapse file tree
sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ public async Task<EventHubsTriggerMetrics> GetMetricsAsync()
7272 }
7373
7474 await Task . WhenAll ( partitionPropertiesTasks ) . ConfigureAwait ( false ) ;
75- EventProcessorCheckpoint [ ] checkpoints ;
75+ EventProcessorCheckpoint [ ] checkpoints = null ;
7676
7777 try
7878 {
@@ -81,7 +81,6 @@ public async Task<EventHubsTriggerMetrics> GetMetricsAsync()
8181 catch
8282 {
8383 // GetCheckpointsAsync would log
84- return metrics ;
8584 }
8685
8786 return CreateTriggerMetrics ( partitionPropertiesTasks . Select ( t => t . Result ) . ToList ( ) , checkpoints ) ;
@@ -103,7 +102,11 @@ private EventHubsTriggerMetrics CreateTriggerMetrics(List<PartitionProperties> p
103102 {
104103 var partitionProperties = partitionRuntimeInfo [ i ] ;
105104
106- var checkpoint = ( BlobCheckpointStoreInternal . BlobStorageCheckpoint ) checkpoints . SingleOrDefault ( c => c ? . PartitionId == partitionProperties . Id ) ;
105+ BlobCheckpointStoreInternal . BlobStorageCheckpoint checkpoint = null ;
106+ if ( checkpoints != null )
107+ {
108+ checkpoint = ( BlobCheckpointStoreInternal . BlobStorageCheckpoint ) checkpoints . SingleOrDefault ( c => c ? . PartitionId == partitionProperties . Id ) ;
109+ }
107110
108111 // Check for the unprocessed messages when there are messages on the Event Hub partition
109112 // In that case, LastEnqueuedSequenceNumber will be >= 0
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ public async Task CreateTriggerMetrics_HandlesExceptions()
206206 var metrics = await _metricsProvider . GetMetricsAsync ( ) ;
207207
208208 Assert . AreEqual ( 1 , metrics . PartitionCount ) ;
209- Assert . AreEqual ( 0 , metrics . EventCount ) ;
209+ Assert . AreEqual ( 1 , metrics . EventCount ) ;
210210 Assert . AreNotEqual ( default ( DateTime ) , metrics . Timestamp ) ;
211211
212212 // Generic Exception
@@ -222,7 +222,7 @@ public async Task CreateTriggerMetrics_HandlesExceptions()
222222 metrics = await _metricsProvider . GetMetricsAsync ( ) ;
223223
224224 Assert . AreEqual ( 1 , metrics . PartitionCount ) ;
225- Assert . AreEqual ( 0 , metrics . EventCount ) ;
225+ Assert . AreEqual ( 1 , metrics . EventCount ) ;
226226 Assert . AreNotEqual ( default ( DateTime ) , metrics . Timestamp ) ;
227227
228228 _loggerProvider . ClearAllLogMessages ( ) ;
You can’t perform that action at this time.
0 commit comments