Skip to content

Commit

Permalink
Support keyed service collection (#360)
Browse files Browse the repository at this point in the history
* Bump up dependency injection package

* Support keyed services in the service container
  • Loading branch information
xiaomi7732 authored Jan 30, 2024
1 parent b010b76 commit beb14d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.1.27" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void StartApplicationInsightsKubernetesEnricher(this IServiceProvi
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
private static bool KubernetesTelemetryInitializerExists(IServiceCollection serviceCollection)
=> serviceCollection.Any<ServiceDescriptor>(t => t.ImplementationType == typeof(KubernetesTelemetryInitializer));
=> serviceCollection.Any(t => !t.IsKeyedService && t.ImplementationType == typeof(KubernetesTelemetryInitializer));

/// <summary>
/// Configure the KubernetesTelemetryInitializer and its dependencies.
Expand Down
2 changes: 1 addition & 1 deletion src/ApplicationInsights.Kubernetes/K8sInfoBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class K8sInfoBootstrap : IK8sInfoBootstrap

private readonly AppInsightsForKubernetesOptions _options;

private readonly object _locker = new object();
private readonly object _locker = new();
private readonly IServiceScopeFactory _serviceScopeFactory;
private bool _hasExecuted = false;
private readonly ExponentialDelaySource _exponentialDelaySource;
Expand Down

0 comments on commit beb14d0

Please sign in to comment.