Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7169d3a
Refactor CorrelationIdLookupHelper to depend on config value (not imp…
Mar 21, 2018
a33ce43
code cleanup
Mar 21, 2018
347a85f
update name of Config method
Mar 23, 2018
a05aa2f
change to use new config.ApplicationIdProvider
Apr 2, 2018
9c34877
remove commented code
Apr 3, 2018
a8dd9e7
added nuget install scripts
Apr 3, 2018
b882b97
marked property as obsolete
Apr 3, 2018
8e74714
Update CHANGELOG.md
Apr 9, 2018
2fa47f4
Merge branch 'develop' into tilee/remove_CorrelationIdLookupHelper
Apr 9, 2018
09b7643
Update CHANGELOG.md
Apr 9, 2018
4f9e5f7
Merge branch 'develop' into tilee/remove_CorrelationIdLookupHelper
Apr 9, 2018
e4c5167
fix stylecop
Apr 9, 2018
9a75dd9
Merge branch 'develop' into tilee/remove_CorrelationIdLookupHelper
Apr 9, 2018
b5dcee0
fix stylecop issues
Apr 9, 2018
a134797
cleanup usings
Apr 9, 2018
52c56cc
cleanup usings
Apr 9, 2018
17fcc1d
Merge branch 'tilee/remove_CorrelationIdLookupHelper' of https://gith…
Apr 9, 2018
479015f
update test app configs
Apr 10, 2018
26cd6ee
Merge branch 'develop' into tilee/remove_CorrelationIdLookupHelper
Apr 10, 2018
927fb69
removed incorrect comment
Apr 10, 2018
4a3dbff
Merge branch 'develop' into tilee/remove_CorrelationIdLookupHelper
Apr 13, 2018
9a53f19
fix ai.config and update test to be more meaningful
Apr 16, 2018
c64617f
correct ai.config
Apr 16, 2018
2f72f86
update ai.config
Apr 16, 2018
0008364
update config
Apr 16, 2018
d7ecf13
Merge branch 'tilee/remove_CorrelationIdLookupHelper' of https://gith…
Apr 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 2.6.0-beta4
- [Remove CorrelationIdLookupHelper. Use TelemetryConfiguration.ApplicationIdProvider instead.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/pull/880)
This change also fixes [ProfileQueryEndpoint is not overridable](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/853)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to formulate it as what you can do now, not what was the issue before. Instead "This change also fixes ProfileQueryEndpoint is not overridable" say "with this change you can update URL to query application ID from which enables environments with reverse proxy configuration to access Application Insights ednpoints".



## Version 2.6.0-beta3
- [Ignore Deprecated events if running under netcore20](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/848)
- [Implement unhandled exception auto-tracking (500 requests) for MVC 5 and WebAPI 2 applications.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/pull/847)
Expand Down
2 changes: 0 additions & 2 deletions Src/Common/Common.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AppMapCorrelationEventSource.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConditionalWeakTableExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CorrelationIdLookupHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExceptionUtilities.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HeadersUtilities.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ICorrelationIdLookupHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InjectionGuardConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RequestResponseHeaders.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SdkVersionUtils.cs" />
Expand Down
393 changes: 0 additions & 393 deletions Src/Common/CorrelationIdLookupHelper.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Src/Common/ICorrelationIdLookupHelper.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ public void OnBeginOnEndAreNotCalledForAppInsightsUrl()
{
using (var module = new DependencyTrackingTelemetryModule())
{
module.ProfileQueryEndpoint = FakeProfileApiEndpoint;
module.Initialize(this.config);

using (var listener = new TestEventListener())
Expand Down Expand Up @@ -561,7 +560,6 @@ private DependencyTrackingTelemetryModule CreateDependencyTrackingModule(bool en
module.DisableDiagnosticSourceInstrumentation = true;
}

module.ProfileQueryEndpoint = FakeProfileApiEndpoint;
module.Initialize(this.config);
Assert.AreEqual(enableDiagnosticSource, DependencyTableStore.IsDesktopHttpDiagnosticSourceActivated);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
</IncludeDiagnosticSourceActivities>
</Add>
</TelemetryModules>
<ApplicationIdProvider xdt:Transform="InsertIfMissing" Type="Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights"/>
</ApplicationInsights>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<Add xdt:Transform="Remove" xdt:Locator="Match(Type)" Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector" />
</TelemetryModules>
<TelemetryModules xdt:Transform="Remove" xdt:Locator="Condition(count(*)=0)"/>

<ApplicationIdProvider xdt:Transform="Remove" xdt:Locator="Match(Type)" Type="Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a default one? Do we need to set it explicitly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently null by default.
Nothing uses it in the BaseSDK, but WebSDK would be expecting it.


</ApplicationInsights>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<Import_RootNamespace>Microsoft.ApplicationInsights.DependencyCollector</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)CorrelationIdLookupHelperTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HttpDependenciesParsingTelemetryInitializerTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HttpWebRequestUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\ApplicationInsightsUrlFilterTests.cs" />
Expand All @@ -22,7 +21,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Implementation\HttpParsers\AzureServiceBusHttpParserTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\HttpParsers\DocumentDbHttpParserTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\HttpParsers\HttpParsingHelperTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\MockCorrelationIdLookupHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\MockTelemetryInitializer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Operation\ObjectInstanceBasedOperationHolderTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\ServiceBusDiagnosticListenerTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public partial class DependencyCollectorDiagnosticListenerTests
private const string RequestUrlWithScheme = "https://" + RequestUrl;
private const string HttpOkResultCode = "200";
private const string NotFoundResultCode = "404";
private const string MockAppId = "MOCK_APP_ID";
private const string MockAppId2 = "MOCK_APP_ID_2";

private readonly List<ITelemetry> sentTelemetry = new List<ITelemetry>();

private string instrumentationKey;
private string testInstrumentationKey1 = nameof(testInstrumentationKey1);
private string testInstrumentationKey2 = nameof(testInstrumentationKey2);
private string testApplicationId1 = nameof(testApplicationId1);
private string testApplicationId2 = nameof(testApplicationId2);
private StubTelemetryChannel telemetryChannel;
private MockCorrelationIdLookupHelper mockCorrelationIdLookupHelper;
private HttpCoreDiagnosticSourceListener listener;

/// <summary>
Expand All @@ -44,32 +44,26 @@ public partial class DependencyCollectorDiagnosticListenerTests
[TestInitialize]
public void Initialize()
{
this.instrumentationKey = Guid.NewGuid().ToString();

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

this.mockCorrelationIdLookupHelper = new MockCorrelationIdLookupHelper(new Dictionary<string, string>()
{
[this.instrumentationKey] = MockAppId
});
this.testInstrumentationKey1 = Guid.NewGuid().ToString();

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

configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
this.listener = new HttpCoreDiagnosticSourceListener(
configuration,
this.telemetryChannel.EndpointAddress,
setComponentCorrelationHttpHeaders: true,
correlationDomainExclusionList: new string[] { "excluded.host.com" },
correlationIdLookupHelper: this.mockCorrelationIdLookupHelper);
correlationDomainExclusionList: new string[] { "excluded.host.com" });
}

/// <summary>
Expand Down Expand Up @@ -212,7 +206,7 @@ public void OnRequestWithRequestEvent()
Assert.AreEqual(string.Empty, telemetry.ResultCode);
Assert.AreEqual(true, telemetry.Success);

Assert.AreEqual(MockAppId, GetRequestContextKeyValue(request, RequestResponseHeaders.RequestContextCorrelationSourceKey));
Assert.AreEqual(this.testApplicationId1, GetRequestContextKeyValue(request, RequestResponseHeaders.RequestContextCorrelationSourceKey));
Assert.AreEqual(null, GetRequestContextKeyValue(request, RequestResponseHeaders.StandardRootIdHeader));

var legacyParentIdHeader = GetRequestHeaderValues(request, RequestResponseHeaders.StandardParentIdHeader).Single();
Expand Down Expand Up @@ -328,14 +322,14 @@ public void OnResponseWithSuccessfulResponseEventWithMatchingRequestAndSameTarge

DependencyTelemetry telemetry = dependency.Telemetry;
Assert.AreEqual(string.Empty, telemetry.ResultCode);
Assert.AreEqual(true, telemetry.Success);
Assert.AreEqual(true, telemetry.Success, "request was not successful");

HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
{
RequestMessage = request
};

response.Headers.Add(RequestResponseHeaders.RequestContextCorrelationTargetKey, MockAppId);
response.Headers.Add(RequestResponseHeaders.RequestContextCorrelationTargetKey, testApplicationId1);

this.listener.OnResponse(response, loggingRequestId);
Assert.IsFalse(this.listener.PendingDependencyTelemetry.TryGetValue(request, out dependency));
Expand All @@ -345,7 +339,7 @@ public void OnResponseWithSuccessfulResponseEventWithMatchingRequestAndSameTarge
Assert.AreEqual(RemoteDependencyConstants.HTTP, telemetry.Type);
Assert.AreEqual(RequestUrl, telemetry.Target);
Assert.AreEqual(HttpOkResultCode, telemetry.ResultCode);
Assert.AreEqual(true, telemetry.Success);
Assert.AreEqual(true, telemetry.Success, "response was not successful");
}

/// <summary>
Expand All @@ -370,7 +364,7 @@ public void OnResponseWithFailedResponseEventWithMatchingRequestAndSameTargetIns
RequestMessage = request
};

response.Headers.Add(RequestResponseHeaders.RequestContextCorrelationTargetKey, MockAppId);
response.Headers.Add(RequestResponseHeaders.RequestContextCorrelationTargetKey, testApplicationId1);

this.listener.OnResponse(response, loggingRequestId);
Assert.IsFalse(this.listener.PendingDependencyTelemetry.TryGetValue(request, out dependency));
Expand Down Expand Up @@ -405,7 +399,7 @@ public void OnResponseWithSuccessfulResponseEventWithMatchingRequestAndDifferent
RequestMessage = request
};

string targetApplicationId = MockAppId2;
string targetApplicationId = testApplicationId2;
HttpHeadersUtilities.SetRequestContextKeyValue(response.Headers, RequestResponseHeaders.RequestContextCorrelationTargetKey, targetApplicationId);

this.listener.OnResponse(response, loggingRequestId);
Expand Down Expand Up @@ -441,7 +435,7 @@ public void OnResponseWithFailedResponseEventWithMatchingRequestAndDifferentTarg
RequestMessage = request
};

string targetApplicationId = MockAppId2;
string targetApplicationId = testApplicationId2;
HttpHeadersUtilities.SetRequestContextKeyValue(response.Headers, RequestResponseHeaders.RequestContextCorrelationTargetKey, targetApplicationId);

this.listener.OnResponse(response, loggingRequestId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void OnActivityStartInjectsHeaders()
// check only legacy headers here
Assert.AreEqual(activity.RootId, request.Headers.GetValues(RequestResponseHeaders.StandardRootIdHeader).Single());
Assert.AreEqual(activity.Id, request.Headers.GetValues(RequestResponseHeaders.StandardParentIdHeader).Single());
Assert.AreEqual(MockAppId, GetRequestContextKeyValue(request, RequestResponseHeaders.RequestContextCorrelationSourceKey));
Assert.AreEqual(this.testApplicationId1, GetRequestContextKeyValue(request, RequestResponseHeaders.RequestContextCorrelationSourceKey));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,29 @@ namespace Microsoft.ApplicationInsights.Tests
public class DesktopDiagnosticSourceHttpProcessingTests
{
#region Fields
private const string RandomAppIdEndpoint = "http://app.id.endpoint"; // appIdEndpoint - this really won't be used for tests because of the app id provider override.
private const int TimeAccuracyMilliseconds = 50;
private Uri testUrl = new Uri("http://www.microsoft.com/");
private int sleepTimeMsecBetweenBeginAndEnd = 100;
private TelemetryConfiguration configuration;
private List<ITelemetry> sendItems;
private List<ITelemetry> sendItems = new List<ITelemetry>();
private DesktopDiagnosticSourceHttpProcessing httpDesktopProcessingFramework;
private const string testInstrumentationKey = nameof(testInstrumentationKey);
private const string testApplicationId = nameof(testApplicationId);
#endregion //Fields

#region TestInitialize

[TestInitialize]
public void TestInitialize()
{
this.configuration = new TelemetryConfiguration();
this.sendItems = new List<ITelemetry>();
this.configuration.TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) };
this.configuration.InstrumentationKey = Guid.NewGuid().ToString();
this.httpDesktopProcessingFramework = new DesktopDiagnosticSourceHttpProcessing(this.configuration, new CacheBasedOperationHolder("testCache", 100 * 1000), /*setCorrelationHeaders*/ true, new List<string>(), RandomAppIdEndpoint);
this.httpDesktopProcessingFramework.OverrideCorrelationIdLookupHelper(new CorrelationIdLookupHelper(new Dictionary<string, string> { { this.configuration.InstrumentationKey, "cid-v1:" + this.configuration.InstrumentationKey } }));
this.configuration = new TelemetryConfiguration()
{
TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) },
InstrumentationKey = testInstrumentationKey,
ApplicationIdProvider = new MockApplicationIdProvider(testInstrumentationKey, testApplicationId)
};

this.httpDesktopProcessingFramework = new DesktopDiagnosticSourceHttpProcessing(this.configuration, new CacheBasedOperationHolder("testCache", 100 * 1000), /*setCorrelationHeaders*/ true, new List<string>());
DependencyTableStore.IsDesktopHttpDiagnosticSourceActivated = false;
}

Expand Down Expand Up @@ -224,8 +227,7 @@ public void RddTestHttpDesktopProcessingFrameworkOnBeginSkipsAddingSourceHeaderP
this.configuration,
new CacheBasedOperationHolder("testCache", 100 * 1000),
false,
new List<string>(),
RandomAppIdEndpoint);
new List<string>());

localHttpProcessingFramework.OnBegin(request);
Assert.IsNull(request.Headers[RequestResponseHeaders.RequestContextHeader]);
Expand All @@ -236,8 +238,8 @@ public void RddTestHttpDesktopProcessingFrameworkOnBeginSkipsAddingSourceHeaderP
this.configuration,
new CacheBasedOperationHolder("testCache", 100 * 1000),
true,
exclusionList,
RandomAppIdEndpoint);
exclusionList);

localHttpProcessingFramework.OnBegin(request);
Assert.IsNull(request.Headers[RequestResponseHeaders.RequestContextHeader]);
Assert.AreEqual(0, request.Headers.Keys.Cast<string>().Count(x => x.StartsWith("x-ms-", StringComparison.OrdinalIgnoreCase)));
Expand Down
Loading