diff --git a/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLogger.cs b/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLogger.cs index b52582b53..97fdcb8ba 100644 --- a/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLogger.cs +++ b/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLogger.cs @@ -375,7 +375,7 @@ private static void ApplyFunctionResultActivityTags(IEnumerable requests = _channel.Telemetries.OfType().ToList(); + List dependencies = _channel.Telemetries.OfType().ToList(); + + Assert.Single(requests); + Assert.Empty(dependencies); + + Assert.NotNull(requests.Single().Context.Operation.Id); + + ValidateServiceBusRequest(requests.Single(), _endpoint, _queueName, nameof(ServiceBusTrigger), null, null); + } + [NoAutomaticTrigger] public static void ServiceBusOut( string input, @@ -163,11 +191,10 @@ public void Dispose() private async Task CleanUpEntity() { var messageReceiver = new MessageReceiver(_connectionString, _queueName, ReceiveMode.ReceiveAndDelete); - Message message; int count = 0; do { - message = await messageReceiver.ReceiveAsync(TimeSpan.FromSeconds(3)).ConfigureAwait(false); + var message = await messageReceiver.ReceiveAsync(TimeSpan.FromSeconds(3)).ConfigureAwait(false); if (message != null) { count++; diff --git a/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/ApplicationInsights/TelemetryValidationHelpers.cs b/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/ApplicationInsights/TelemetryValidationHelpers.cs index 172b234df..8c11fe91d 100644 --- a/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/ApplicationInsights/TelemetryValidationHelpers.cs +++ b/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/ApplicationInsights/TelemetryValidationHelpers.cs @@ -52,9 +52,17 @@ public static void ValidateRequest( Assert.Equal(LogLevel.Information.ToString(), request.Properties[LogConstants.LogLevelKey]); Assert.NotNull(request.Name); Assert.NotNull(request.Id); - Assert.Equal(operationId, request.Context.Operation.Id); + + if (operationId != null) + { + Assert.Equal(operationId, request.Context.Operation.Id); + } + + if (parentId != null) + { + Assert.Equal(parentId, request.Context.Operation.ParentId); + } Assert.Equal(operationName, request.Context.Operation.Name); - Assert.Equal(parentId, request.Context.Operation.ParentId); Assert.True(request.Properties.ContainsKey(LogConstants.InvocationIdKey)); Assert.True(request.Properties.ContainsKey(LogConstants.TriggerReasonKey)); }