Skip to content

Commit 64e0b54

Browse files
committed
Fixing Application Insights host logs tests
1 parent 8eb8c26 commit 64e0b54

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/WebJobs.Script.Tests.Integration/ApplicationInsights/ApplicationInsightsEndToEndTestsBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.ApplicationInsights.Channel;
1212
using Microsoft.ApplicationInsights.DataContracts;
1313
using Microsoft.ApplicationInsights.Extensibility.Implementation;
14+
using Microsoft.Azure.AppService.Proxy.Common.Expressions;
1415
using Microsoft.Azure.WebJobs.Host;
1516
using Microsoft.Azure.WebJobs.Logging;
1617
using Microsoft.Azure.WebJobs.Script.Diagnostics;
@@ -19,6 +20,7 @@
1920
using Microsoft.Extensions.DependencyInjection;
2021
using Microsoft.Extensions.Hosting;
2122
using Microsoft.Extensions.Logging;
23+
using Microsoft.Extensions.Logging.Abstractions.Internal;
2224
using Microsoft.WebJobs.Script.Tests;
2325
using Newtonsoft.Json.Linq;
2426
using Xunit;
@@ -251,12 +253,17 @@ public async Task Validate_HostLogs()
251253
// Validate the host startup traces. Order by message string as the requests may come in
252254
// slightly out-of-order or on different threads
253255
TraceTelemetry[] traces = null;
256+
string routesManagerLogCategory = TypeNameHelper.GetTypeDisplayName(typeof(WebHost.WebScriptHostHttpRoutesManager));
254257

255258
await TestHelpers.Await(() =>
256259
{
257260
traces = _fixture.Channel.Telemetries
258261
.OfType<TraceTelemetry>()
259-
.Where(t => t.Properties[LogConstants.CategoryNameKey].ToString().StartsWith("Host."))
262+
.Where(t =>
263+
{
264+
string category = t.Properties[LogConstants.CategoryNameKey].ToString();
265+
return category.StartsWith("Host.") || category.StartsWith(routesManagerLogCategory);
266+
})
260267
.OrderBy(t => t.Message)
261268
.ToArray();
262269

@@ -287,7 +294,7 @@ await TestHelpers.Await(() =>
287294
ValidateTrace(traces[idx++], "Host lock lease acquired by instance ID", ScriptConstants.LogCategoryHostGeneral);
288295
ValidateTrace(traces[idx++], "Host started (", LogCategories.Startup);
289296
ValidateTrace(traces[idx++], "Initializing function HTTP routes" + Environment.NewLine
290-
+ "Mapped function route 'api/HttpTrigger-Scenarios'", "Host.HttpRoutes");
297+
+ "Mapped function route 'api/HttpTrigger-Scenarios'", routesManagerLogCategory);
291298
ValidateTrace(traces[idx++], "Initializing Host", LogCategories.Startup);
292299
ValidateTrace(traces[idx++], "Initializing Warmup Extension", LogCategories.CreateTriggerCategory("Warmup"));
293300
ValidateTrace(traces[idx++], "Job host started", LogCategories.Startup);

0 commit comments

Comments
 (0)