Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -100,10 +100,6 @@ public async Task<long> GetMessageCountAsync()
}
throw;
}
catch (Exception e)
{
_logger.LogWarning(e, $"Error querying for Service Bus {entityName} scale");
}

long totalNewMessageCount = 0;
if ((!_isListeningOnDeadLetterQueue && activeMessageCount > 0) || (_isListeningOnDeadLetterQueue && deadLetterCount > 0))
Expand Down Expand Up @@ -173,10 +169,6 @@ public async Task<ServiceBusTriggerMetrics> GetMetricsAsync()
$"derive {entityName} length metrics. Falling back to using first message enqueued time.");
}
}
catch (Exception e)
{
_logger.LogWarning($"Error querying for Service Bus {entityName} scale status: {e.Message}");
}

// Path for connection strings with no manage claim
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment at line 173 is now misleading. After removing the generic exception handler, this fallback return statement is only reached when an UnauthorizedAccessException is caught at line 164, not for other generic exceptions. The comment should be updated to clarify this is specifically the fallback for UnauthorizedAccessException (no manage claim), or when MessagingEntityNotFound is encountered.

Suggested change
// Path for connection strings with no manage claim
// Fallback for UnauthorizedAccessException (no manage claim) or when MessagingEntityNotFound is encountered

Copilot uses AI. Check for mistakes.
return CreateTriggerMetrics(activeMessage, 0, 0, 0, _isListeningOnDeadLetterQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,9 @@ public async Task GetMetrics_HandlesExceptions()
.Throws(new Exception("Uh oh"));
listener = CreateListener();

metrics = await ((ServiceBusScaleMonitor)listener.GetMonitor()).GetMetricsAsync();

Assert.AreEqual(0, metrics.PartitionCount);
Assert.AreEqual(0, metrics.MessageCount);
Assert.AreEqual(TimeSpan.FromSeconds(0), metrics.QueueTime);
Assert.AreNotEqual(default(DateTime), metrics.Timestamp);

warning = _loggerProvider.GetAllLogMessages().Single(p => p.Level == LogLevel.Warning);
Assert.AreEqual($"Error querying for Service Bus {_entityTypeName} scale status: Uh oh", warning.FormattedMessage);
var ex = Assert.ThrowsAsync<Exception>(async () =>
await ((ServiceBusScaleMonitor)listener.GetMonitor()).GetMetricsAsync());
Assert.AreEqual("Uh oh", ex.Message);
}

private ServiceBusListener CreateListener(bool useDeadletterQueue = false)
Expand Down
Loading