Microsoft.ApplicationInsights.Kubernetes.3.x leverages the hosted background service to fetch Kubernetes cluster properties. When there is no hoster, a plain console application, for example, there's no code to start the fetch of the cluster-info.
Solution
Provides another extension method that can bootstrap the fetch of cluster-info.
// Bootstrap k8s cluster-info. Only run this once.
serviceProvider.StartApplicationInsightsKubernetesEnricher();
Alterntaives considered
Expose a loose service for the user to get out of the IoC container - not as convenient; 1 additional public interface;
Fully support non-IoC scenario - big change with little gain.
Trade-offs
For ConsoleApplication author, an additional line of code become required - StartApplicationInsightsKubernetesEnricher();
Under some circumstances, it might bring confusion for non-console users.
Tests
[x] Unit tests pass.
[x] Console app reporting cluster-info.
[x] F5 project deployed to non-k8s - no crash, proper logging.
[x] F5 project deployed to k8s - cluster info fetched correctly.
Addresses #325.
Problem
Microsoft.ApplicationInsights.Kubernetes.3.x
leverages the hosted background service to fetch Kubernetes cluster properties. When there is no hoster, a plain console application, for example, there's no code to start the fetch of the cluster-info.Solution
Provides another extension method that can bootstrap the fetch of cluster-info.
Alterntaives considered
Trade-offs
Tests