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

Make W3C Correlation default and leverage native W3C support from new System.Diagnostics.DiagnosticSource Activity #958

Merged
merged 34 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bb75b72
wip 1
cijothomas Aug 21, 2019
557c43a
wip test1
cijothomas Aug 21, 2019
e55927c
aspnet 1.xx modified for w3c
cijothomas Aug 21, 2019
8e9d63b
unit testing
cijothomas Aug 22, 2019
0035667
update base sdk to private signed version
cijothomas Aug 22, 2019
4aa138c
fixes
cijothomas Aug 22, 2019
bc2faa7
fix tests
cijothomas Aug 22, 2019
a1ada4b
read trace state correct
cijothomas Aug 22, 2019
5e5209e
fix tests
cijothomas Aug 22, 2019
32e8ae6
new test
cijothomas Aug 22, 2019
9fd5ca5
more tst
cijothomas Aug 22, 2019
3f02039
config change and test
cijothomas Aug 23, 2019
47bf080
fix review comments
cijothomas Aug 26, 2019
2071a53
make legacyrootid from operationid if possible
cijothomas Aug 26, 2019
536b792
fix 956
cijothomas Aug 26, 2019
03ea036
fix webapi20 functional tests
cijothomas Aug 26, 2019
cb2de3a
reorder
cijothomas Aug 26, 2019
343ac9a
order
cijothomas Aug 26, 2019
1ae760b
ignore dep tests
cijothomas Aug 27, 2019
7e4279f
ignore more dep tests
cijothomas Aug 27, 2019
b5eade0
ignore dep tests in mvc1.0
cijothomas Aug 27, 2019
2f1427a
disable dep collection required tests
cijothomas Aug 27, 2019
e535282
Revert "disable dep collection required tests"
cijothomas Aug 27, 2019
a0abc0a
revert
cijothomas Aug 27, 2019
9d10126
merge conflict resolve
cijothomas Aug 27, 2019
8b15054
bump to beta3
cijothomas Aug 27, 2019
0d6be75
read cor context for w3c
cijothomas Aug 27, 2019
0604e73
func test with correlation header if either w3c or reqid is presnt
cijothomas Aug 27, 2019
34d51b9
fix review comments and whitespace issue
cijothomas Aug 27, 2019
7533468
conflict resolve
cijothomas Aug 27, 2019
26a407e
add event log events for correlation
cijothomas Aug 27, 2019
28ee89d
add langversion to 7.2
cijothomas Aug 27, 2019
2e3dded
modify linux ci to not test 1.xx tests. it cannot use language versio…
cijothomas Aug 27, 2019
a95a5c9
build and test netcoreapp20 in non windows
cijothomas Aug 27, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Version 2.8.0-beta2
- [Make W3C Correlation default and leverage native W3C support from Activity.](https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/958)
- [Correct names for Asp.Net Core EventCounters.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/945)
- [Obsolete extension methods on IWebHostBuilder in favor of AddApplicationInsights extension method on IServiceCollection.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/919)
- [Remove support for deprecated x-ms based correlation headers.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/939)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@ internal static class RequestResponseHeaders
/// Correlation-Context header.
/// </summary>
public const string CorrelationContextHeader = "Correlation-Context";

//
// Summary:
// W3C traceparent header name.
public const string TraceParentHeader = "traceparent";
//
// Summary:
// W3C tracestate header name.
public const string TraceStateHeader = "tracestate";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public RequestCollectionOptions()
#else
this.TrackExceptions = true;
#endif
this.EnableW3CDistributedTracing = false;
this.EnableW3CDistributedTracing = true;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public void Configure(TelemetryConfiguration configuration)

if (applicationInsightsServiceOptions.RequestCollectionOptions.EnableW3CDistributedTracing)
{
this.EnableW3CHeaders(configuration);
cijothomas marked this conversation as resolved.
Show resolved Hide resolved
configuration.EnableW3CCorrelation = true;
}
else
{
configuration.EnableW3CCorrelation = false;
}

configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.Build();
Expand Down Expand Up @@ -202,10 +206,5 @@ private void DisableHeartBeatIfConfigured()
}
}
}

private void EnableW3CHeaders(TelemetryConfiguration configuration)
{
configuration.TelemetryInitializers.Add(new W3COperationCorrelationTelemetryInitializer());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.11.0-beta1" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.11.0-beta1-build12825" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.11.0-beta1" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.11.0-beta1" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.11.0-beta1" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.11.0-beta1" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.11.0-beta1-build12825" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.0.2" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.3.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void Initialize(TelemetryConfiguration configuration)

this.subscriptions?.Add(DiagnosticListener.AllListeners.Subscribe(this));

// Questionable to modify the configuration here.
configuration.EnableW3CCorrelation = this.CollectionOptions.EnableW3CDistributedTracing;
this.isInitialized = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.ApplicationInsights.AspNetCore.Tests
{
public enum AspNetCoreMajorVersion { One, Two, Three};
}
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ public static void HeartbeatIsDisabledWithServiceOptions()
}

[Fact]
public static void W3CIsDisabledByDefault()
public static void W3CIsEnabledByDefault()
{
var services = CreateServicesAndAddApplicationinsightsTelemetry(null, "http://localhost:1234/v2/track/");
IServiceProvider serviceProvider = services.BuildServiceProvider();
Expand All @@ -1066,30 +1066,29 @@ public static void W3CIsDisabledByDefault()
Assert.Single(requestTracking);
Assert.Single(dependencyTracking);

Assert.False(requestTracking.Single().CollectionOptions.EnableW3CDistributedTracing);
Assert.False(dependencyTracking.Single().EnableW3CHeadersInjection);
Assert.True(requestTracking.Single().CollectionOptions.EnableW3CDistributedTracing);
Assert.True(dependencyTracking.Single().EnableW3CHeadersInjection);
}

[Fact]
public static void W3CIsEnabledWhenConfiguredInOptions()
public static void W3CIsDisabledWhenConfiguredInOptions()
{
var services = CreateServicesAndAddApplicationinsightsTelemetry(null,
"http://localhost:1234/v2/track/",
o => o.RequestCollectionOptions.EnableW3CDistributedTracing = true);
o => o.RequestCollectionOptions.EnableW3CDistributedTracing = false);
IServiceProvider serviceProvider = services.BuildServiceProvider();
var telemetryConfiguration = serviceProvider.GetTelemetryConfiguration();

Assert.Contains(telemetryConfiguration.TelemetryInitializers, t => t is W3COperationCorrelationTelemetryInitializer);


var modules = serviceProvider.GetServices<ITelemetryModule>().ToList();

var requestTracking = modules.OfType<RequestTrackingTelemetryModule>().ToList();
var dependencyTracking = modules.OfType<DependencyTrackingTelemetryModule>().ToList();
Assert.Single(requestTracking);
Assert.Single(dependencyTracking);

Assert.True(requestTracking.Single().CollectionOptions.EnableW3CDistributedTracing);
Assert.True(dependencyTracking.Single().EnableW3CHeadersInjection);
Assert.False(requestTracking.Single().CollectionOptions.EnableW3CDistributedTracing);
Assert.False(dependencyTracking.Single().EnableW3CHeadersInjection);
Assert.False(telemetryConfiguration.EnableW3CCorrelation);
}

private static int GetTelemetryProcessorsCountInConfiguration<T>(TelemetryConfiguration telemetryConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
public static class CommonMocks
{
public const string InstrumentationKey = "REQUIRED";
public const string InstrumentationKeyHash = "0KNjBVW77H/AWpjTEcI7AP0atNgpasSkEll22AtqaVk=";
public const string TestApplicationId = nameof(TestApplicationId);

public static TelemetryClient MockTelemetryClient(Action<ITelemetry> onSendCallback)
public static TelemetryClient MockTelemetryClient(Action<ITelemetry> onSendCallback, bool isW3C = true)
{
return new TelemetryClient(new TelemetryConfiguration()
{
InstrumentationKey = InstrumentationKey,
TelemetryChannel = new FakeTelemetryChannel { OnSend = onSendCallback }
TelemetryChannel = new FakeTelemetryChannel { OnSend = onSendCallback },
EnableW3CCorrelation = isW3C
cijothomas marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down
Loading