Skip to content
Open
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
1 change: 1 addition & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<clear />
<!-- Do not add any additional feeds if new packages are needed they need to come from our azure-sdk-for-net DevOps feed which has an upstream set to nuget.org -->
<add key="azure-sdk-for-net" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
<add key="local" value="Q:\nuget" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
4 changes: 2 additions & 2 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@
<PackageReference Update="Microsoft.Azure.SignalR.Management" Version="1.29.0" />
<PackageReference Update="Microsoft.Azure.SignalR.Protocols" Version="1.29.0" />
<PackageReference Update="Microsoft.Azure.SignalR.Serverless.Protocols" Version="1.10.0" />
<PackageReference Update="Microsoft.Azure.WebJobs" Version="3.0.41" />
<PackageReference Update="Microsoft.Azure.WebJobs.Sources" Version="3.0.41" PrivateAssets="All"/>
<PackageReference Update="Microsoft.Azure.WebJobs" Version="3.0.42-dev" />
<PackageReference Update="Microsoft.Azure.WebJobs.Sources" Version="3.0.42-dev" PrivateAssets="All"/>
<PackageReference Update="Microsoft.Azure.WebJobs.Extensions.Rpc" Version="3.0.41" />
<PackageReference Update="Microsoft.Azure.WebJobs.Host.Storage" Version="5.0.1" />
<PackageReference Update="Microsoft.Spatial" Version="7.5.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.WebJobs.ServiceBus.Listeners;
using Microsoft.Azure.WebJobs.ServiceBus;
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Azure.Messaging.ServiceBus;
using Azure.Messaging.ServiceBus.Administration;
using Microsoft.Azure.WebJobs.Extensions.ServiceBus.Config;
using Microsoft.Azure.WebJobs.Host.Scale;
using Microsoft.Azure.WebJobs.ServiceBus;
using Microsoft.Azure.WebJobs.ServiceBus.Listeners;
using Microsoft.Extensions.Logging;

namespace Microsoft.Azure.WebJobs.Extensions.ServiceBus.Listeners
{
Expand All @@ -17,6 +17,7 @@ internal class ServiceBusMetricsProvider
internal const string DeadLetterQueuePath = @"/$DeadLetterQueue";

private readonly ILogger _logger;
private readonly string _functionId;
private readonly string _entityPath;
private readonly ServiceBusEntityType _serviceBusEntityType;
private readonly Lazy<ServiceBusReceiver> _receiver;
Expand All @@ -30,12 +31,14 @@ internal class ServiceBusMetricsProvider
private DateTime _nextWarningTime;

public ServiceBusMetricsProvider(
string functionId,
string entityPath,
ServiceBusEntityType serviceBusEntityType,
Lazy<ServiceBusReceiver> receiver,
Lazy<ServiceBusAdministrationClient> administrationClient,
ILoggerFactory loggerFactory)
{
_functionId = functionId;
_serviceBusEntityType = serviceBusEntityType;
_receiver = receiver;
_entityPath = entityPath;
Expand Down Expand Up @@ -90,19 +93,20 @@ public async Task<long> GetMessageCountAsync()
catch (ServiceBusException ex)
when (ex.Reason == ServiceBusFailureReason.MessagingEntityNotFound)
{
_logger.LogWarning($"ServiceBus {entityName} '{_entityPath}' was not found.");
_logger.LogFunctionScaleWarning($"ServiceBus {entityName} '{_entityPath}' was not found.", _functionId, ex);
}
catch (UnauthorizedAccessException ex)
{
if (TimeToLogWarning())
{
_logger.LogWarning(ex, $"Connection string does not have 'Manage Claim' for {entityName} '{_entityPath}'. Unable to determine active message count.");
_logger.LogFunctionScaleWarning($"Connection string does not have 'Manage Claim' for {entityName} '{_entityPath}'. Unable to determine active message count.",
_functionId, ex);
}
throw;
}
catch (Exception e)
catch (Exception ex)
{
_logger.LogWarning(e, $"Error querying for Service Bus {entityName} scale");
_logger.LogFunctionScaleWarning($"Error querying for Service Bus {entityName} scale", _functionId, ex);
}

long totalNewMessageCount = 0;
Expand Down Expand Up @@ -163,19 +167,20 @@ public async Task<ServiceBusTriggerMetrics> GetMetricsAsync()
catch (ServiceBusException ex)
when (ex.Reason == ServiceBusFailureReason.MessagingEntityNotFound)
{
_logger.LogWarning($"ServiceBus {entityName} '{_entityPath}' was not found.");
_logger.LogFunctionScaleWarning($"ServiceBus {entityName} '{_entityPath}' was not found.", _functionId, ex);
}
catch (UnauthorizedAccessException) // When manage claim is not used on Service Bus connection string
catch (UnauthorizedAccessException ex) // When manage claim is not used on Service Bus connection string
{
if (TimeToLogWarning())
{
_logger.LogWarning($"Connection string does not have Manage claim for {entityName} '{_entityPath}'. Failed to get {entityName} description to " +
$"derive {entityName} length metrics. Falling back to using first message enqueued time.");
_logger.LogFunctionScaleWarning($"Connection string does not have Manage claim for {entityName} '{_entityPath}'. Failed to get {entityName} description to " +
$"derive {entityName} length metrics. Falling back to using first message enqueued time.",
_functionId, ex);
}
}
catch (Exception e)
catch (Exception ex)
{
_logger.LogWarning($"Error querying for Service Bus {entityName} scale status: {e.Message}");
_logger.LogFunctionScaleWarning($"Error querying for Service Bus {entityName} scale status", _functionId, ex);
}

// Path for connection strings with no manage claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ILoggerFactory loggerFactory
{
_functionId = functionId;
_entityPath = entityPath;
_serviceBusMetricsProvider = new ServiceBusMetricsProvider(entityPath, entityType, receiver, administrationClient, loggerFactory);
_serviceBusMetricsProvider = new ServiceBusMetricsProvider(_functionId, entityPath, entityType, receiver, administrationClient, loggerFactory);
_scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{_functionId}-ServiceBusTrigger-{_entityPath}".ToLower(CultureInfo.InvariantCulture), functionId);
_logger = loggerFactory.CreateLogger<ServiceBusScaleMonitor>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.ServiceBus.Listeners
{
internal class ServiceBusTargetScaler : ITargetScaler
{
private readonly string _functionId;
private readonly string _functionName;
private readonly ServiceBusMetricsProvider _serviceBusMetricsProvider;
private readonly ServiceBusOptions _options;
private readonly bool _isSessionsEnabled;
Expand All @@ -26,7 +26,7 @@ internal class ServiceBusTargetScaler : ITargetScaler
private readonly ILogger _logger;

public ServiceBusTargetScaler(
string functionId,
string functionName,
string entityPath,
ServiceBusEntityType entityType,
Lazy<ServiceBusReceiver> receiver,
Expand All @@ -37,10 +37,10 @@ public ServiceBusTargetScaler(
ILoggerFactory loggerFactory
)
{
_functionId = functionId;
_serviceBusMetricsProvider = new ServiceBusMetricsProvider(entityPath, entityType, receiver, administrationClient, loggerFactory);
_functionName = functionName;
_serviceBusMetricsProvider = new ServiceBusMetricsProvider(_functionName, entityPath, entityType, receiver, administrationClient, loggerFactory);
_entityPath = entityPath;
_targetScalerDescriptor = new TargetScalerDescriptor(functionId);
_targetScalerDescriptor = new TargetScalerDescriptor(functionName);
_logger = loggerFactory.CreateLogger<ServiceBusTargetScaler>();
_options = options;
_singleDispatch = singleDispatch;
Expand Down Expand Up @@ -108,7 +108,8 @@ internal TargetScalerResult GetScaleResultInternal(TargetScalerContext context,
targetWorkerCount = int.MaxValue;
}

_logger.LogInformation($"Target worker count for function '{_functionId}' is '{targetWorkerCount}' (EntityPath='{_entityPath}', MessageCount ='{messageCount}', Concurrency='{concurrency}').");
_logger.LogFunctionScaleVote(_functionName, targetWorkerCount, (int)messageCount, concurrency,
$"Target worker count for function '{_functionName}' is '{targetWorkerCount}' (EntityPath='{_entityPath}', MessageCount ='{messageCount}', Concurrency='{concurrency}').");

return new TargetScalerResult
{
Expand Down
Loading