Skip to content

Commit

Permalink
trace2: remove inaccurate warning and add UI helper exit calls (#1114)
Browse files Browse the repository at this point in the history
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.

Additionally, 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.
  • Loading branch information
ldennington committed Feb 21, 2023
2 parents ce9f845 + 2476614 commit cf4b3e9
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static void AppMain(object o)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/shared/Core/Trace2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -314,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; }
Expand Down
1 change: 1 addition & 0 deletions src/shared/Git-Credential-Manager.UI.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static void AppMain(object o)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Git-Credential-Manager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/shared/GitHub.UI.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static void AppMain(object o)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/GitLab.UI.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private static void AppMain(object o)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/windows/Atlassian.Bitbucket.UI.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static async Task Main(string[] args)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/windows/Git-Credential-Manager.UI.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static async Task Main(string[] args)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/windows/GitHub.UI.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static async Task Main(string[] args)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/windows/GitLab.UI.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static async Task Main(string[] args)
.GetAwaiter()
.GetResult();

context.Trace2.Stop(exitCode);
Environment.Exit(exitCode);
}
}
Expand Down

0 comments on commit cf4b3e9

Please sign in to comment.