Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

ProfileQueryEndpoint is not overridable => application identifiers cannot be resolved #853

Closed
zakimaksyutov opened this issue Mar 12, 2018 · 7 comments
Assignees
Labels

Comments

@zakimaksyutov
Copy link
Member

zakimaksyutov commented Mar 12, 2018

Description

Application ID resolution feature does not work in our own PPE environment. As a result we cannot use new correlation-based features for monitoring our production.

Repro Steps

  1. Override EndpointAddress to PPE endpoint

Actual Behavior

Notice that application identifiers are still resolved (ProfileQueryEndpoint) against original endpoint. Application Insights doesn't allow to configure this endpoint.

Expected Behavior

Allow applications to configure ProfileQueryEndpoint or construct based on EndpointAddress

Version Info

SDK Version : 2.6-beta2

Code

using System.Net.Http;
using System.Threading;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;

namespace OverrideProfileApp
{
    class Program
    {
        public static readonly HttpClient client = new HttpClient();

        static void Main(string[] args)
        {
            TelemetryConfiguration.Active.InstrumentationKey = "11111111-1111-1111-1111-111111111111";
            TelemetryConfiguration.Active.TelemetryChannel.EndpointAddress =
                "https://myingestionpoint.com/v2/track";

            var a = TelemetryModules.Instance;

            var telemetryClient = new TelemetryClient();

            while (true)
            {
                Thread.Sleep(1000);

                using (var operation = telemetryClient.StartOperation<RequestTelemetry>("MyOperation"))
                {
                    client.GetStringAsync("https://bing.com").Wait();
                }
            }
        }
    }
}
@SergeyKanzhelev
Copy link
Contributor

SergeyKanzhelev commented Mar 12, 2018

This is by design. Please configure ProfileQueryEndpoint explicitly instead of taking unnecessary dependency on channel's EndpointAddress. Two reasons - 1. EndpointAddress property may throw NotImplementedException for the non-standard channels 2. If proxy is specified for telemetry upload - this proxy is not necessarily proxies profile requests.

@zakimaksyutov
Copy link
Member Author

zakimaksyutov commented Mar 12, 2018

Chatted with @SergeyKanzhelev - the issue of not being able to override ProfileQueryEndpoint is still an issue =) Agree that it should be a different setting and not depend on EndpointAddress. Reactivating.

@zakimaksyutov zakimaksyutov reopened this Mar 12, 2018
@SergeyKanzhelev
Copy link
Contributor

sorry for miunderstanding. Definitely should be fixed

@TimothyMothra TimothyMothra changed the title ProfileQueryUrl is not overridable => application identifiers cannot be resolved ProfileQueryEndpoint is not overridable => application identifiers cannot be resolved Mar 13, 2018
@TimothyMothra
Copy link
Member

TimothyMothra commented Mar 13, 2018

Adding some context to the conversation while planning how to fix this...

This affects the CorrelationIdLookupHelper's endpointAddress which is responsible for resolving the Application Id.
https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/113cf9ec4aa3dfd0d1c6443ded1700a0fa65972b/Src/Common/CorrelationIdLookupHelper.cs#L82

Our current documentation says to override the TelemetryChannel's EndpointAddress if a user is behind a proxy. This is questionably incorrect. Microsoft Docs: "AppInsights Proxy" This should work for a configuration scenario but won't for programmatic configuration.

Currently today, ProfileQueryEndpoint is copied to dependent modules when initialized. As a workaround, It is technically possible to overwrite these manually, although that's a far from ideal scenario for an end-user.

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/33696c0d09a3c6e93a690198a09bd49d84a63c58/Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs#L83-L94

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/e95d9caac611d3da55879fefba149f4d793dffff/Src/DependencyCollector/Shared/DependencyTrackingTelemetryModule.cs#L98-L109

@TimothyMothra
Copy link
Member

TimothyMothra commented Mar 20, 2018

@zakimaksyutov I've got a workaround for you until we release a more permanent solution.

Run this snippet after customizing your config:

foreach (var module in TelemetryModules.Instance.Modules)
{
    module.Initialize(TelemetryConfiguration.Active);
}

This will ensure that ANY config customizations are applied to all modules.

EDIT:
Actually no, that won't work. The CorrelationIdLookupHelper is not aware that it could be behind a proxy and does not take that account when building the query URL.

@zakimaksyutov
Copy link
Member Author

@MS-TimothyMothra, tried to add above snippet to above repro and it doesn't look like that it helped. AppIDs are still resolved against main endpoint.

@TimothyMothra
Copy link
Member

Fix will be released with 2.6.0-Beta4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants