Tweaks and CHANGELOG update.
This commit is contained in:
Родитель
d5f7d8bd36
Коммит
42cd7e3a6d
|
@ -2,6 +2,7 @@
|
|||
|
||||
## VNext
|
||||
- [Populate required field Message with "n/a" if it is empty](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1066)
|
||||
- [Fix ITelemetryModule singleton registration to support presence of keyed services](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2908)
|
||||
|
||||
## Version 2.22.0
|
||||
- no changes since beta.
|
||||
|
|
|
@ -312,7 +312,7 @@
|
|||
private static void AddCommonTelemetryModules(IServiceCollection services)
|
||||
{
|
||||
// Previously users were encouraged to manually add the DiagnosticsTelemetryModule.
|
||||
services.TryAddSingleton<ITelemetryModule, DiagnosticsTelemetryModule>();
|
||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITelemetryModule, DiagnosticsTelemetryModule>());
|
||||
|
||||
// These modules add properties to Heartbeat and expect the DiagnosticsTelemetryModule to be configured in DI.
|
||||
services.AddSingleton<ITelemetryModule, AppServicesHeartbeatTelemetryModule>();
|
||||
|
|
|
@ -37,14 +37,22 @@ namespace Microsoft.Extensions.DependencyInjection.Test
|
|||
|
||||
public class AddApplicationInsightsTelemetryTests : BaseTestClass
|
||||
{
|
||||
[Fact]
|
||||
public static void TelemetryModulesResolvableWhenKeyedServiceRegistered()
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public static void TelemetryModulesResolvableWhenKeyedServiceRegistered(bool manuallyRegisterDiagnosticsTelemetryModule)
|
||||
{
|
||||
// Note: This test verifies a regression doesn't get introduced for:
|
||||
// https://github.com/dotnet/extensions/issues/5222
|
||||
// https://github.com/microsoft/ApplicationInsights-dotnet/issues/2879
|
||||
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton<ITelemetryModule, TestTelemetryModule>();
|
||||
if (manuallyRegisterDiagnosticsTelemetryModule)
|
||||
{
|
||||
services.AddSingleton<ITelemetryModule, DiagnosticsTelemetryModule>();
|
||||
}
|
||||
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationType: typeof(TestService));
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationInstance: new TestService());
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationFactory: (sp, key) => new TestService());
|
||||
|
@ -55,7 +63,9 @@ namespace Microsoft.Extensions.DependencyInjection.Test
|
|||
|
||||
var telemetryModules = sp.GetServices<ITelemetryModule>();
|
||||
|
||||
Assert.Equal(7, telemetryModules.Count());
|
||||
Assert.Equal(8, telemetryModules.Count());
|
||||
|
||||
Assert.Single(telemetryModules.Where(m => m.GetType() == typeof(DiagnosticsTelemetryModule)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -123,14 +123,22 @@ namespace Microsoft.ApplicationInsights.WorkerService.Tests
|
|||
return services;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TelemetryModulesResolvableWhenKeyedServiceRegistered()
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public static void TelemetryModulesResolvableWhenKeyedServiceRegistered(bool manuallyRegisterDiagnosticsTelemetryModule)
|
||||
{
|
||||
// Note: This test verifies a regression doesn't get introduced for:
|
||||
// https://github.com/dotnet/extensions/issues/5222
|
||||
// https://github.com/microsoft/ApplicationInsights-dotnet/issues/2879
|
||||
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton<ITelemetryModule, TestTelemetryModule>();
|
||||
if (manuallyRegisterDiagnosticsTelemetryModule)
|
||||
{
|
||||
services.AddSingleton<ITelemetryModule, DiagnosticsTelemetryModule>();
|
||||
}
|
||||
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationType: typeof(TestService));
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationInstance: new TestService());
|
||||
services.AddKeyedSingleton(typeof(ITestService), serviceKey: new(), implementationFactory: (sp, key) => new TestService());
|
||||
|
@ -141,7 +149,9 @@ namespace Microsoft.ApplicationInsights.WorkerService.Tests
|
|||
|
||||
var telemetryModules = sp.GetServices<ITelemetryModule>();
|
||||
|
||||
Assert.Equal(7, telemetryModules.Count());
|
||||
Assert.Equal(8, telemetryModules.Count());
|
||||
|
||||
Assert.Single(telemetryModules.Where(m => m.GetType() == typeof(DiagnosticsTelemetryModule)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -921,6 +931,13 @@ namespace Microsoft.ApplicationInsights.WorkerService.Tests
|
|||
{
|
||||
}
|
||||
|
||||
private sealed class TestTelemetryModule : ITelemetryModule
|
||||
{
|
||||
public void Initialize(TelemetryConfiguration configuration)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private interface ITestService
|
||||
{
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче