From 20415232d5ba0b884f41eb3474e7c7683ff2bdf9 Mon Sep 17 00:00:00 2001 From: Lessley Dennington Date: Tue, 14 Feb 2023 14:53:53 -0700 Subject: [PATCH 1/3] trace2: remove warning from tryparsesettings Remove warning about being unable to set up tracing from Trace2 TryParseSettings method. This method should just check to see whether TRACE2 is enabled - if it is not, it does not need to warn the user, as we only collect traces from those who actively choose to opt in. --- src/shared/Core/Trace2.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/shared/Core/Trace2.cs b/src/shared/Core/Trace2.cs index d929e0a29..ac9f72e88 100644 --- a/src/shared/Core/Trace2.cs +++ b/src/shared/Core/Trace2.cs @@ -200,11 +200,6 @@ private void TryParseSettings(TextWriter error, IFileSystem fileSystem) } } } - - if (_writers.Count == 0) - { - error.WriteLine("warning: unable to set up TRACE2 tracing. No traces will be written."); - } } private void WriteVersion( From 6b2459c3f359c2230cd6437ff075b32d36d5a691 Mon Sep 17 00:00:00 2001 From: Lessley Dennington Date: Thu, 16 Feb 2023 15:10:20 -0700 Subject: [PATCH 2/3] trace2: add exit event to UI helpers GCM's UI helpers are connected to the TRACE2 system via the Start() call in ApplicationBase.cs. Since this call records Version and Start events, ensure a corresponding Exit event is called before the helper process completes. --- src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs | 1 + src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs | 1 + src/shared/Git-Credential-Manager/Program.cs | 2 +- src/shared/GitHub.UI.Avalonia/Program.cs | 1 + src/shared/GitLab.UI.Avalonia/Program.cs | 1 + src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs | 1 + src/windows/Git-Credential-Manager.UI.Windows/Program.cs | 1 + src/windows/GitHub.UI.Windows/Program.cs | 1 + src/windows/GitLab.UI.Windows/Program.cs | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs b/src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs index ef4a5473f..be0ba8044 100644 --- a/src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs +++ b/src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs @@ -55,6 +55,7 @@ private static void AppMain(object o) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs b/src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs index 4fa10db4a..57f389879 100644 --- a/src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs +++ b/src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs @@ -55,6 +55,7 @@ private static void AppMain(object o) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/shared/Git-Credential-Manager/Program.cs b/src/shared/Git-Credential-Manager/Program.cs index d3e382548..bd62e8b5f 100644 --- a/src/shared/Git-Credential-Manager/Program.cs +++ b/src/shared/Git-Credential-Manager/Program.cs @@ -29,7 +29,7 @@ public static void Main(string[] args) ); } } - + // // Git Credential Manager's executable used to be named "git-credential-manager-core" before // dropping the "-core" suffix. In order to prevent "helper not found" errors for users who diff --git a/src/shared/GitHub.UI.Avalonia/Program.cs b/src/shared/GitHub.UI.Avalonia/Program.cs index 8c429415d..ad20374bc 100644 --- a/src/shared/GitHub.UI.Avalonia/Program.cs +++ b/src/shared/GitHub.UI.Avalonia/Program.cs @@ -57,6 +57,7 @@ private static void AppMain(object o) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/shared/GitLab.UI.Avalonia/Program.cs b/src/shared/GitLab.UI.Avalonia/Program.cs index 91d98a1c2..955e6dc0a 100644 --- a/src/shared/GitLab.UI.Avalonia/Program.cs +++ b/src/shared/GitLab.UI.Avalonia/Program.cs @@ -54,6 +54,7 @@ private static void AppMain(object o) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs b/src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs index f348a20cc..d6d1f49b5 100644 --- a/src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs +++ b/src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs @@ -28,6 +28,7 @@ public static async Task Main(string[] args) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/windows/Git-Credential-Manager.UI.Windows/Program.cs b/src/windows/Git-Credential-Manager.UI.Windows/Program.cs index ad675049d..63bfc8579 100644 --- a/src/windows/Git-Credential-Manager.UI.Windows/Program.cs +++ b/src/windows/Git-Credential-Manager.UI.Windows/Program.cs @@ -28,6 +28,7 @@ public static async Task Main(string[] args) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/windows/GitHub.UI.Windows/Program.cs b/src/windows/GitHub.UI.Windows/Program.cs index 7924b8f4b..f12235185 100644 --- a/src/windows/GitHub.UI.Windows/Program.cs +++ b/src/windows/GitHub.UI.Windows/Program.cs @@ -30,6 +30,7 @@ public static async Task Main(string[] args) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } diff --git a/src/windows/GitLab.UI.Windows/Program.cs b/src/windows/GitLab.UI.Windows/Program.cs index 6c58d8279..55a6d27c6 100644 --- a/src/windows/GitLab.UI.Windows/Program.cs +++ b/src/windows/GitLab.UI.Windows/Program.cs @@ -28,6 +28,7 @@ public static async Task Main(string[] args) .GetAwaiter() .GetResult(); + context.Trace2.Stop(exitCode); Environment.Exit(exitCode); } } From 247661467a8d5b5fe0c1f2fcd7505345ced54c25 Mon Sep 17 00:00:00 2001 From: Lessley Dennington Date: Fri, 17 Feb 2023 14:50:11 -0700 Subject: [PATCH 3/3] trace2: add default thread name value of "main" The TRACE2 convention for thread naming is for each child process's main thread of execution to be named "main." In GCM, however, we encountered an issue with our UI Helper exes - their main threads of execution are named AppMain. To temporarily work around this issue, we default the thread name for all TRACE2 events to "main" (rather than changing GCM's process names). This will do for our current events, which are all called from the main thread of execution. However, it is important to note that future events (i.e. regions) will require deeper thought around the GCM/TRACE2 process model, as they will be called on threads from .NET's ThreadPool rather than the main thread of execution. --- src/shared/Core/Trace2.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/Core/Trace2.cs b/src/shared/Core/Trace2.cs index ac9f72e88..116bf6612 100644 --- a/src/shared/Core/Trace2.cs +++ b/src/shared/Core/Trace2.cs @@ -309,8 +309,9 @@ public abstract class Trace2Message [JsonProperty("sid", Order = 2)] public string Sid { get; set; } + // TODO: Remove this default value when TRACE2 regions are introduced. [JsonProperty("thread", Order = 3)] - public string Thread { get; set; } + public string Thread { get; set; } = "main"; [JsonProperty("time", Order = 4)] public DateTimeOffset Time { get; set; }