From 5de747d590e5d019365b5b107eb1812933686b7b Mon Sep 17 00:00:00 2001 From: Jesse Squire Date: Thu, 1 Dec 2022 13:31:21 -0500 Subject: [PATCH] [Event Hubs] Event Source Fixes The focus of these changes is to correct a typo for message parameter within the event source and to attempt to improve reliability for tests that mock the event source by removing base class delegation for calls. --- .../Azure.Messaging.EventHubs.Processor/CHANGELOG.md | 2 ++ sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md | 2 ++ .../src/Diagnostics/EventHubsEventSource.cs | 2 +- .../Primitives/EventProcessorTests.StartStop.cs | 12 ++++++------ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md index e23b3ff99161..6b994baf5b23 100755 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Corrected log message issue causing formatting to fail when developer code for processing events leaks an exception. This obscured the warning that was intended to be emitted to the error handler. + ### Other Changes ## 5.7.5 (2022-11-22) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md b/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md index 16d996c7d4ed..5c887e69d98e 100755 --- a/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md +++ b/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Corrected log message issue causing formatting to fail when developer code for processing events leaks an exception. This obscured the warning that was intended to be emitted to the error handler. + ### Other Changes ## 5.7.5 (2022-11-22) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Diagnostics/EventHubsEventSource.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Diagnostics/EventHubsEventSource.cs index 18aa8dd7cdb9..8a8015012edf 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Diagnostics/EventHubsEventSource.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Diagnostics/EventHubsEventSource.cs @@ -2601,7 +2601,7 @@ public virtual void EventProcessorProcessingHandlerError(string partitionId, { if (IsEnabled()) { - WriteEvent(125, partitionId ?? string.Empty, identifier ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? string.Empty, errorMessage ?? string.Empty); + WriteEvent(125, partitionId ?? string.Empty, identifier ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? string.Empty, operationId ?? string.Empty, errorMessage ?? string.Empty); } } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.StartStop.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.StartStop.cs index 82d8a786f418..709c55acca82 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.StartStop.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.StartStop.cs @@ -480,7 +480,7 @@ public async Task StartProcessingLogsNormalStartup(bool async) using var cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockProcessor = new Mock(4, "consumerGroup", "namespace", "eventHub", Mock.Of(), default(EventProcessorOptions)) { CallBase = true }; mockProcessor.Object.Logger = mockEventSource.Object; @@ -533,7 +533,7 @@ public async Task StartProcessingLogsErrorDuringStartup(bool async) using var cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockProcessor = new Mock(4, "consumerGroup", "namespace", "eventHub", Mock.Of(), default(EventProcessorOptions)) { CallBase = true }; mockEventSource @@ -1182,7 +1182,7 @@ public async Task StopProcessingLogsNormalShutdown(bool async) using var cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockProcessor = new Mock(4, "consumerGroup", "namespace", "eventHub", Mock.Of(), default(EventProcessorOptions)) { CallBase = true }; mockProcessor.Object.Logger = mockEventSource.Object; @@ -1235,7 +1235,7 @@ public async Task StopProcessingLogsErrorDuringShutdown(bool async) using var cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockProcessor = new Mock(4, "consumerGroup", "namespace", "eventHub", Mock.Of(), default(EventProcessorOptions)) { CallBase = true }; mockEventSource @@ -1305,7 +1305,7 @@ public async Task StopProcessingLogsFaultedTaskDuringShutdown(bool async) cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); var expectedException = new DivideByZeroException("BOOM!"); - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockProcessor = new Mock(4, "consumerGroup", "namespace", "eventHub", Mock.Of(), default(EventProcessorOptions)) { CallBase = true }; mockProcessor.Object.Logger = mockEventSource.Object; @@ -1375,7 +1375,7 @@ public async Task StopProcessingIsSafeToCallInTheErrorHandler(bool async) var startCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var stopCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var options = new EventProcessorOptions { LoadBalancingUpdateInterval = TimeSpan.FromMilliseconds(1) }; - var mockEventSource = new Mock() { CallBase = true }; + var mockEventSource = new Mock(); var mockConnection = new Mock(); var mockProcessor = new Mock(65, "consumerGroup", "namespace", "eventHub", Mock.Of(), options) { CallBase = true };