Beispiel #1
0
        public static void Initialize(string instrumentationKey)
        {
            configuration = new TelemetryConfiguration(instrumentationKey);
            var observer = new ApplicationInsightsKubernetesDiagnosticObserver(DiagnosticLogLevel.Trace);

            ApplicationInsightsKubernetesDiagnosticSource.Instance.Observable.SubscribeWithAdapter(observer);

            configuration.AddApplicationInsightsKubernetesEnricher(applyOptions: null);

            // client = new TelemetryClient();
            // client.InstrumentationKey = instrumentationKey;
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // To use this project for F5 debugging, follow these steps:

            // Output the diagnostic source logs to the console.
            var observer = new ApplicationInsightsKubernetesDiagnosticObserver(DiagnosticLogLevel.Trace);

            ApplicationInsightsKubernetesDiagnosticSource.Instance.Observable.SubscribeWithAdapter(observer);

            // Step 1. Set iKey in the parameter below.
            services.AddApplicationInsightsTelemetry("your-instrumentation-key");

            // Step 2. Call proper overloads of AddApplicationInsightsKubernetesEnricher.
            services.AddApplicationInsightsKubernetesEnricher(applyOptions: null,
                                                              kubernetesServiceCollectionBuilder: KubernetesDebuggingServiceCollectionBuilderFactory.Instance.Create(),
                                                              detectKubernetes: () => true);
            // Step 3. Set a break point and press F5.
            // ~

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }