Skip to content

Commit 352df85

Browse files
Upgrade ApplicationInsights logging package containing ability to enable live metrics filters (#9410)
* Updated AppInsights logging package and added tests
1 parent 280ba77 commit 352df85

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/WebJobs.Script/WebJobs.Script.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<PackageId>Microsoft.Azure.WebJobs.Script</PackageId>
@@ -66,7 +66,7 @@
6666
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
6767
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Timers.Storage" Version="1.0.0-beta.1" />
6868
<PackageReference Include="Microsoft.Azure.WebJobs.Script.Abstractions" Version="1.0.4-preview" />
69-
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.36" />
69+
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.37" />
7070
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.3.1" />
7171
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
7272
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />

test/WebJobs.Script.Tests/Configuration/ApplicationInsightsLoggerOptionsSetupTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,48 @@ public void Configure_QuickPulse_NullByDefault()
244244
Assert.Null(options.QuickPulseAuthenticationApiKey);
245245
}
246246

247+
[Theory]
248+
[InlineData(null, true)] // default value
249+
[InlineData("true", true)]
250+
[InlineData("false", false)]
251+
public void Configure_EnableLiveMetrics(string value, bool expectedValue)
252+
{
253+
IConfiguration config = new ConfigurationBuilder()
254+
.AddInMemoryCollection(new Dictionary<string, string>
255+
{
256+
{ "EnableLiveMetrics", value },
257+
})
258+
.Build();
259+
260+
ApplicationInsightsLoggerOptionsSetup setup = new ApplicationInsightsLoggerOptionsSetup(new MockLoggerConfiguration(config), _environment);
261+
262+
ApplicationInsightsLoggerOptions options = new ApplicationInsightsLoggerOptions();
263+
setup.Configure(options);
264+
265+
Assert.Equal(expectedValue, options.EnableLiveMetrics);
266+
}
267+
268+
[Theory]
269+
[InlineData(null, false)] // default value
270+
[InlineData("true", true)]
271+
[InlineData("false", false)]
272+
public void Configure_EnableLiveMetricsFilters(string value, bool expectedValue)
273+
{
274+
IConfiguration config = new ConfigurationBuilder()
275+
.AddInMemoryCollection(new Dictionary<string, string>
276+
{
277+
{ "EnableLiveMetricsFilters", value },
278+
})
279+
.Build();
280+
281+
ApplicationInsightsLoggerOptionsSetup setup = new ApplicationInsightsLoggerOptionsSetup(new MockLoggerConfiguration(config), _environment);
282+
283+
ApplicationInsightsLoggerOptions options = new ApplicationInsightsLoggerOptions();
284+
setup.Configure(options);
285+
286+
Assert.Equal(expectedValue, options.EnableLiveMetricsFilters);
287+
}
288+
247289
private class MockLoggerConfiguration : ILoggerProviderConfiguration<ApplicationInsightsLoggerProvider>
248290
{
249291
public MockLoggerConfiguration(IConfiguration configuration)

0 commit comments

Comments
 (0)