From 1083ea8d5fbc7d8d41e928c81a981d22c02fa8ca Mon Sep 17 00:00:00 2001 From: Alexey Rodionov Date: Wed, 18 Mar 2026 22:31:54 -0700 Subject: [PATCH] [EventHubs] Replace scaling logs with WebJobs extension methods --- .../CHANGELOG.md | 2 ++ .../src/Listeners/EventHubMetricsProvider.cs | 5 +++-- .../src/Listeners/EventHubsTargetScaler.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/CHANGELOG.md b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/CHANGELOG.md index 00e98c3348b4..e6b2fbe8cfd4 100644 --- a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/CHANGELOG.md +++ b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/CHANGELOG.md @@ -10,6 +10,8 @@ ### Other Changes +- Replaced scaling warning/error log calls with standardized `LogFunctionScaleWarning` extension method to enable Scale Controller App Insights diagnostics. + ## 6.5.3 (2025-10-20) ### Bugs Fixed diff --git a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs index 7146ec136183..b9460982d486 100644 --- a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs +++ b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs @@ -9,6 +9,7 @@ using Azure.Messaging.EventHubs; using Azure.Messaging.EventHubs.Primitives; using Microsoft.Azure.WebJobs.EventHubs.Listeners; +using Microsoft.Azure.WebJobs.Host.Scale; using Microsoft.Extensions.Logging; namespace Microsoft.Azure.WebJobs.Extensions.EventHubs.Listeners @@ -102,7 +103,7 @@ public async Task GetMetricsAsync() } catch (Exception e) { - _logger.LogWarning($"Encountered an exception while getting partition information for Event Hub '{_client.EventHubName}' used for scaling. Error: {e.Message}"); + _logger.LogFunctionScaleWarning($"Encountered an exception while getting partition information for Event Hub '{_client.EventHubName}' used for scaling.", _functionId, e); } // Get checkpoints @@ -149,7 +150,7 @@ public async Task GetMetricsAsync() } catch (Exception e) { - _logger.LogWarning($"Encountered an exception while getting checkpoints for Event Hub '{_client.EventHubName}' used for scaling. Error: {e.Message}"); + _logger.LogFunctionScaleWarning($"Encountered an exception while getting checkpoints for Event Hub '{_client.EventHubName}' used for scaling.", _functionId, e); } return CreateTriggerMetrics(partitionPropertiesTasks.Select(t => t.Result).ToList(), checkpoints); diff --git a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubsTargetScaler.cs b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubsTargetScaler.cs index e44a86b23e73..72f0988e606c 100644 --- a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubsTargetScaler.cs +++ b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubsTargetScaler.cs @@ -108,7 +108,7 @@ internal TargetScalerResult GetScaleResultInternal(TargetScalerContext context, _logger.LogInformation($"Desired target worker count of '{desiredWorkerCount}' is not in list of valid sorted workers: '{string.Join(",", sortedValidWorkerCounts)}'. Using next largest valid worker as target worker count."); } - _logger.LogInformation($"Target worker count for function '{_functionId}' is '{validatedTargetWorkerCount}' (EventHubName='{_client.EventHubName}', EventCount ='{eventCount}', Concurrency='{desiredConcurrency}', PartitionCount='{partitionCount}')."); + _logger.LogInformation($"Target worker count for function '{_functionId}' is '{validatedTargetWorkerCount}' (EventHubName='{_client.EventHubName}', EventCount='{eventCount}', Concurrency='{desiredConcurrency}', PartitionCount='{partitionCount}')."); return new TargetScalerResult {