Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BASE SDK Use W3C Correlation by default. #1193

Merged
merged 21 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.set -> void
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.get -> bool
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.ExperimentalFeatures.get -> System.Collections.Generic.IList<string>
static Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension.EvaluateExperimentalFeature(this Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration telemetryConfiguration, string featureName) -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationExtensions
Expand Down Expand Up @@ -45,7 +47,6 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.IsSampledOutAtHea
Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.IsSampledOutAtHead.set -> void
Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.IsSampledOutAtHead.set -> void
Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.IsSampledOutAtHead.set -> void

Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.TaskTimer() -> void
Microsoft.ApplicationInsights.Extensibility.W3C.W3COperationCorrelationTelemetryInitializer.W3COperationCorrelationTelemetryInitializer() -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryDebugWriter.TelemetryDebugWriter() -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.set -> void
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.get -> bool
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.ExperimentalFeatures.get -> System.Collections.Generic.IList<string>
static Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension.EvaluateExperimentalFeature(this Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration telemetryConfiguration, string featureName) -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.set -> void
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.get -> bool
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.ExperimentalFeatures.get -> System.Collections.Generic.IList<string>
static Microsoft.ApplicationInsights.Extensibility.Implementation.Experimental.ExperimentalFeaturesExtension.EvaluateExperimentalFeature(this Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration telemetryConfiguration, string featureName) -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.set -> void
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.EnableW3CCorrelation.get -> bool
Microsoft.ApplicationInsights.Extensibility.W3C.W3CUtilities
static Microsoft.ApplicationInsights.Extensibility.W3C.W3CUtilities.GenerateTraceId() -> string
Microsoft.ApplicationInsights.Extensibility.W3C.W3COperationCorrelationTelemetryInitializer
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,38 @@
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.TestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using System.Diagnostics;

[TestClass]
public class TelemetryConfigurationTest
{
#region W3C
[TestMethod]
public void TelemetryConfigurationConstructorSetsW3CToTrueByDefault()
{
var tc = new TelemetryConfiguration();
Assert.IsTrue(tc.EnableW3CCorrelation);
}

[TestMethod]
public void TelemetryConfigurationEnableW3CCorrelationSetsActivityDefaultFormatToW3C()
{
var tc = new TelemetryConfiguration();
tc.EnableW3CCorrelation = true;
Assert.AreEqual(ActivityIdFormat.W3C, Activity.DefaultIdFormat);
}

[TestMethod]
public void TelemetryConfigurationDisableW3CCorrelationRestoresActivityDefaultFormat()
{
Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical;
var tc = new TelemetryConfiguration();
// DisablingW3C should reset default id format to Hierrachical
tc.EnableW3CCorrelation = false;
Assert.AreEqual(ActivityIdFormat.Hierarchical, Activity.DefaultIdFormat);
}
#endregion

[TestMethod]
public void TelemetryConfigurationIsPublicToAllowUsersManipulateConfigurationProgrammatically()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Metrics\TestUtility\StubApplicationInsightsTelemetryChannel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Metrics\TestUtility\TestCategoryNames.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Metrics\TestUtility\TestUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)W3C\W3CActivityExtensionsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)W3C\W3COperationCorrelationTelemetryInitializerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)W3C\W3CUtilitiesTests.cs" />
<None Include="$(MSBuildThisFileDirectory)Metrics\TestUtility\Materials\StdDev Test Tool.xlsx" />
<Compile Include="$(MSBuildThisFileDirectory)Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Extensibility.Implementation;
using TestFramework;
using Microsoft.ApplicationInsights.Extensibility.W3C;

/// <summary>
/// This class tests TelemetryClientEzxtensions.StartOperation<T>(TelemetryClient c, Activity a) overload
/// This class tests TelemetryClientExtensions.StartOperation<T>(TelemetryClient c, Activity a) overload
/// </summary>
[TestClass]
public class StartOperationActivityTests
Expand Down Expand Up @@ -272,10 +273,18 @@ private async Task ProcessAsync(Activity activity, Activity parentActivity)
return telemetry;
}

private void ValidateTelemetry<T>(T telemetry, Activity activity) where T : OperationTelemetry
private void ValidateTelemetry<T>(T telemetry, Activity activity, bool isW3C = true) where T : OperationTelemetry
{
Assert.AreEqual(activity.OperationName, telemetry.Name);
Assert.AreEqual(activity.Id, telemetry.Id);
if (isW3C)
{
Assert.AreEqual(W3CUtilities.FormatTelemetryId(activity.TraceId.ToHexString(), activity.SpanId.ToHexString()), telemetry.Id);
}
else
{
Assert.AreEqual(activity.Id, telemetry.Id);
}

Assert.AreEqual(activity.ParentId, telemetry.Context.Operation.ParentId);
Assert.AreEqual(activity.RootId, telemetry.Context.Operation.Id);

Expand Down
Loading