Example #1
0
        public void Initialize()
        {
            this.sentTelemetry   = new List <DependencyTelemetry>();
            this.request         = null;
            this.response        = null;
            this.responseHeaders = null;

            this.channel = new StubTelemetryChannel
            {
                OnSend = telemetry =>
                {
                    // The correlation id lookup service also makes http call, just make sure we skip that
                    DependencyTelemetry depTelemetry = telemetry as DependencyTelemetry;
                    if (depTelemetry != null)
                    {
                        this.sentTelemetry.Add(depTelemetry);
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpRequestOperationDetailName, out this.request);
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseOperationDetailName, out this.response);
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseHeadersOperationDetailName, out this.responseHeaders);
                    }
                },
                EndpointAddress = FakeProfileApiEndpoint
            };

            this.config = new TelemetryConfiguration
            {
                InstrumentationKey = IKey,
                TelemetryChannel   = this.channel
            };

            this.config.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
        }
Example #2
0
        public void TestInitialize()
        {
            this.sendItems       = new List <ITelemetry>();
            this.request         = null;
            this.response        = null;
            this.responseHeaders = null;

            this.configuration = new TelemetryConfiguration()
            {
                TelemetryChannel = new StubTelemetryChannel
                {
                    OnSend = telemetry =>
                    {
                        this.sendItems.Add(telemetry);

                        // The correlation id lookup service also makes http call, just make sure we skip that
                        DependencyTelemetry depTelemetry = telemetry as DependencyTelemetry;
                        if (depTelemetry != null)
                        {
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpRequestOperationDetailName, out this.request);
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseOperationDetailName, out this.response);
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseHeadersOperationDetailName, out this.responseHeaders);
                        }
                    },
                },
                InstrumentationKey    = TestInstrumentationKey,
                ApplicationIdProvider = new MockApplicationIdProvider(TestInstrumentationKey, TestApplicationId)
            };

            this.httpDesktopProcessingFramework = new DesktopDiagnosticSourceHttpProcessing(this.configuration, new CacheBasedOperationHolder("testCache", 100 * 1000), /*setCorrelationHeaders*/ true, new List <string>(), false);
            DependencyTableStore.IsDesktopHttpDiagnosticSourceActivated = false;
        }
        public void Initialize()
        {
            this.sentTelemetry   = new List <ITelemetry>();
            this.request         = null;
            this.response        = null;
            this.responseHeaders = null;

            this.telemetryChannel = new StubTelemetryChannel()
            {
                EndpointAddress = "https://endpointaddress",
                OnSend          = telemetry =>
                {
                    this.sentTelemetry.Add(telemetry);

                    // The correlation id lookup service also makes http call, just make sure we skip that
                    DependencyTelemetry depTelemetry = telemetry as DependencyTelemetry;
                    if (depTelemetry != null)
                    {
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpRequestOperationDetailName, out this.request);
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseOperationDetailName, out this.response);
                        depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseHeadersOperationDetailName, out this.responseHeaders);
                    }
                },
            };

            this.testInstrumentationKey1 = Guid.NewGuid().ToString();

            this.configuration = new TelemetryConfiguration
            {
                TelemetryChannel      = this.telemetryChannel,
                InstrumentationKey    = this.testInstrumentationKey1,
                ApplicationIdProvider = new MockApplicationIdProvider(this.testInstrumentationKey1, this.testApplicationId1)
            };

            this.configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
            this.listener = new HttpCoreDiagnosticSourceListener(
                this.configuration,
                setComponentCorrelationHttpHeaders: true,
                correlationDomainExclusionList: new string[] { "excluded.host.com" },
                injectLegacyHeaders: false,
                injectW3CHeaders: false);
        }
        public void TestInitialize()
        {
            this.sendItems       = new List <ITelemetry>();
            this.request         = null;
            this.response        = null;
            this.responseHeaders = null;

            this.configuration = new TelemetryConfiguration()
            {
                TelemetryChannel = new StubTelemetryChannel
                {
                    OnSend = telemetry =>
                    {
                        this.sendItems.Add(telemetry);

                        // The correlation id lookup service also makes http call, just make sure we skip that
                        DependencyTelemetry depTelemetry = telemetry as DependencyTelemetry;
                        if (depTelemetry != null)
                        {
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpRequestOperationDetailName, out this.request);
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseOperationDetailName, out this.response);
                            depTelemetry.TryGetOperationDetail(RemoteDependencyConstants.HttpResponseHeadersOperationDetailName, out this.responseHeaders);
                        }
                    },
                },
                InstrumentationKey    = TestInstrumentationKey,
                ApplicationIdProvider = new MockApplicationIdProvider(TestInstrumentationKey, TestApplicationId)
            };

            this.configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
            this.httpProcessingProfiler = new ProfilerHttpProcessing(
                this.configuration,
                null,
                new ObjectInstanceBasedOperationHolder(),
                setCorrelationHeaders: true,
                correlationDomainExclusionList: new List <string>(),
                injectLegacyHeaders: false);
        }
        private static void AddResponseBody(DependencyTelemetry dependencyTelemetry)
        {
            dependencyTelemetry.TryGetOperationDetail(HttpResponseOperationDetailName, out var result);

            if (result == null)
            {
                return;
            }

            if (result is HttpResponseMessage responseMessage)
            {
                if (responseMessage.Content == null)
                {
                    return;
                }

                var content = responseMessage
                              .Content
                              .ReadAsStringAsync().Result;
                dependencyTelemetry.Properties.Add("response-body", content);
            }
        }