microsoft / ApplicationInsights-Kubernetes

Enrich the telemetry data for .NET applications running inside containers that are managed by Kubernetes.
Other
135 stars 57 forks source link

Support manual bootstrap in console application #326

Closed xiaomi7732 closed 1 year ago

xiaomi7732 commented 1 year ago

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.

// Bootstrap k8s cluster-info. Only run this once.
serviceProvider.StartApplicationInsightsKubernetesEnricher();

Alterntaives considered

Trade-offs

Tests