Esempio n. 1
0
        private void SetUpTelemetryClient()
        {
            this.endToEndTraceHelper.ExtensionInformationalEvent(
                hubName: this.options.HubName,
                functionName: string.Empty,
                instanceId: string.Empty,
                message: "Setting up the telemetry client...",
                writeToUserLogs: true);

            TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();

            if (this.OnSend != null)
            {
                config.TelemetryChannel = new NoOpTelemetryChannel {
                    OnSend = this.OnSend
                };
            }

            var telemetryInitializer = new DurableTaskCorrelationTelemetryInitializer();

            telemetryInitializer.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("127.0.0.1");
            config.TelemetryInitializers.Add(telemetryInitializer);

            string resolvedInstrumentationKey = this.nameResolver.Resolve("APPINSIGHTS_INSTRUMENTATIONKEY");

            if (!string.IsNullOrEmpty(resolvedInstrumentationKey))
            {
                this.endToEndTraceHelper.ExtensionInformationalEvent(
                    hubName: this.options.HubName,
                    functionName: string.Empty,
                    instanceId: string.Empty,
                    message: "Reading APPINSIGHTS_INSTRUMENTATIONKEY...",
                    writeToUserLogs: true);

                config.InstrumentationKey = resolvedInstrumentationKey;
            }
            else
            {
                this.endToEndTraceHelper.ExtensionWarningEvent(
                    hubName: this.options.HubName,
                    functionName: string.Empty,
                    instanceId: string.Empty,
                    message: "'APPINSIGHTS_INSTRUMENTATIONKEY' isn't defined in the current environment variables, but Distributed Tracing is enabled. Please set 'APPINSIGHTS_INSTRUMENTATIONKEY' to use Distributed Tracing.");
            }

            this.telemetryClient = new TelemetryClient(config);
        }
        private void SetUpTelemetryClient()
        {
            TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();

            if (this.OnSend != null)
            {
                config.TelemetryChannel = new NoOpTelemetryChannel {
                    OnSend = this.OnSend
                };
            }

            var telemetryInitializer = new DurableTaskCorrelationTelemetryInitializer();

            telemetryInitializer.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("127.0.0.1");
            config.TelemetryInitializers.Add(telemetryInitializer);

            config.InstrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");

            this.telemetryClient = new TelemetryClient(config);
        }