From 31b80bb6f10988cb2dee7624344b59a981b82abd Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 29 Jul 2021 18:00:29 -0700 Subject: [PATCH 1/9] proof of concept --- .props/_GlobalStaticVersion.props | 1 + .../Implementation/Tracing/CoreEventSource.cs | 8 ++++++-- .../Extensibility/TelemetryConfiguration.cs | 15 ++++++++++++++ .../Microsoft.ApplicationInsights.csproj | 14 ++++++++++++- Directory.Build.props | 20 ++++++++++++++++--- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/.props/_GlobalStaticVersion.props b/.props/_GlobalStaticVersion.props index 9cc616c89d..dfb498f35c 100644 --- a/.props/_GlobalStaticVersion.props +++ b/.props/_GlobalStaticVersion.props @@ -14,6 +14,7 @@ 18 0 + redfield nightly - false + true true + + $(DefineConstants);REDFIELD - - + + + + + + + + + + From ae3c9df9a98b1c6ba6f8942c89eeed38c6ccb728 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 29 Jul 2021 18:05:13 -0700 Subject: [PATCH 2/9] revert --- .../Extensibility/TelemetryConfiguration.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs index 72b8d58a08..53d284b666 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs @@ -154,21 +154,6 @@ public string InstrumentationKey set { this.instrumentationKey = value ?? throw new ArgumentNullException(nameof(this.InstrumentationKey)); } } - - - /// - /// Gets a boolean indicating if this is a Redfield build. - /// - public bool Redfield - { -#if REDFIELD - get => true; -#else - get => false; -#endif - } - - /// /// Gets or sets a value indicating whether sending of telemetry to Application Insights is disabled. /// From 5470b3cfce4838c4d1143183b23ac36518f3c78e Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 29 Jul 2021 18:07:46 -0700 Subject: [PATCH 3/9] revert --- .../Extensibility/Implementation/Tracing/CoreEventSource.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs index 9ac618d2d4..c199cdf202 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs @@ -612,7 +612,7 @@ public void InitializationIsSkippedForSampledItem(string appDomainName = "Incorr [Event(60, Message = "MetricManager created {0} Tasks.", Level = EventLevel.Verbose)] public void MetricManagerCreatedTasks(int taskCount, string appDomainName = "Incorrect") => this.WriteEvent(60, taskCount, this.nameProvider.Name); -#region FileDiagnosticsTelemetryModule + #region FileDiagnosticsTelemetryModule [Event(61, Message = "Logs file name: {0}.", Level = EventLevel.Verbose)] public void LogsFileName(string fileName, string appDomainName = "Incorrect") => this.WriteEvent(61, fileName ?? string.Empty, this.nameProvider.Name); @@ -634,7 +634,7 @@ public void InitializationIsSkippedForSampledItem(string appDomainName = "Incorr [Event(66, Message = "Call to WindowsIdentity.Current failed with the exception: {0}.", Level = EventLevel.Warning)] public void LogWindowsIdentityAccessSecurityException(string error, string appDomainName = "Incorrect") => this.WriteEvent(66, error ?? string.Empty, this.nameProvider.Name); -#endregion + #endregion [Event(67, Message = "Backend has responded with {0} status code in {1}ms.", Level = EventLevel.Informational)] public void IngestionResponseTime(int responseCode, float responseDurationInMs, string appDomainName = "Incorrect") => this.WriteEvent(67, responseCode, responseDurationInMs, this.nameProvider.Name); From 4e46f9627faed26b44850757a85188fb803349c1 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 29 Jul 2021 18:09:44 -0700 Subject: [PATCH 4/9] update comment --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1ab463c697..128f2e9485 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,11 +3,12 @@ - true + false true + $(DefineConstants);REDFIELD From 76746a8385487dd377f1dc546d7f26b33a7b3439 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Fri, 30 Jul 2021 12:00:40 -0700 Subject: [PATCH 5/9] cleanup --- Directory.Build.props | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 128f2e9485..42b378a87a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,13 +28,6 @@ - - - - - - - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) From 9721e191bdfc1e52ab0576dd2732c7b7a658966f Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Fri, 30 Jul 2021 12:04:09 -0700 Subject: [PATCH 6/9] copy paste error --- Directory.Build.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index 42b378a87a..ef0d9c5ccc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,6 +21,10 @@ + + + + From 91bcc85510ae9d1556bb67d0735f66b5cfa6c521 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Fri, 30 Jul 2021 12:04:54 -0700 Subject: [PATCH 7/9] cleanup --- .../Microsoft.ApplicationInsights.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 6f5858de25..0adc47fc4b 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -28,7 +28,7 @@ - + From ad2ad8d0693f35fbceac49789b25c6321823db41 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 12 Aug 2021 17:38:08 -0700 Subject: [PATCH 8/9] extra test --- .../Tracing/CoreEventSourceTest.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs index 28e83e46c2..054f53dc68 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs @@ -4,6 +4,7 @@ using Microsoft.ApplicationInsights.TestFramework; using System.Diagnostics.Tracing; using Microsoft.VisualStudio.TestTools.UnitTesting; + using System.Linq; [TestClass] public class CoreEventSourceTest @@ -25,5 +26,26 @@ private static EventAttribute GetEventAttribute(string methodName) MethodInfo method = typeof(CoreEventSource).GetMethod(methodName); return method.GetCustomAttribute(); } + +#if Redfield + /// + /// This is a sanitiy check. + /// The 'Redfield' compilation flag should switch the name of EventSource class. + /// Devs can review the test log and confirm that this test runs and passes. + /// This will serve as a verification that the Redfield compilation flag worked as expected. + /// + [TestMethod] + public void VerifyRedfieldEventSourceName() + { + var expectedName = "Redfield-Microsoft-ApplicationInsights-Core"; + + var eventSourceAttribute = typeof(CoreEventSource) + .GetCustomAttributes(typeof(EventSourceAttribute)) + .Single() as EventSourceAttribute; + + Assert.IsNotNull(eventSourceAttribute); + Assert.AreEqual(expectedName, eventSourceAttribute.Name); + } +#endif } -} \ No newline at end of file +} From 45f76063c05861ab53c1328bddcd990a02f8dd85 Mon Sep 17 00:00:00 2001 From: TimothyMothra Date: Thu, 12 Aug 2021 17:48:26 -0700 Subject: [PATCH 9/9] update --- .../Implementation/Tracing/CoreEventSourceTest.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs index 054f53dc68..26088e82bb 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/CoreEventSourceTest.cs @@ -27,12 +27,16 @@ private static EventAttribute GetEventAttribute(string methodName) return method.GetCustomAttribute(); } -#if Redfield +#if REDFIELD /// /// This is a sanitiy check. /// The 'Redfield' compilation flag should switch the name of EventSource class. /// Devs can review the test log and confirm that this test runs and passes. /// This will serve as a verification that the Redfield compilation flag worked as expected. + /// + /// To run this test: + /// dotnet build /p:Redfield=True ".\dotnet\BASE\Microsoft.ApplicationInsights.sln" + /// dotnet test ".\bin\Debug\test\Microsoft.ApplicationInsights.Tests\net5.0\Microsoft.ApplicationInsights.Tests.dll" --filter Name~VerifyRedfieldEventSourceName /// [TestMethod] public void VerifyRedfieldEventSourceName()