Skip to content

Commit f6d82a8

Browse files
committed
docs: add trace2 to config/env documentation
Add Trace2 config/env var options to GCM's configuration/environment documentation to improve discoverability.
1 parent d6a4cf3 commit f6d82a8

File tree

6 files changed

+399
-0
lines changed

6 files changed

+399
-0
lines changed

docs/configuration.md

+75
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,75 @@ git config --global credential.azreposCredentialType oauth
661661

662662
**Also see: [GCM_AZREPOS_CREDENTIALTYPE][gcm-azrepos-credentialtype]**
663663

664+
---
665+
666+
### trace2.normalTarget
667+
668+
Turns on Trace2 Normal Format tracing - see [Git's Trace2 Normal Format
669+
documentation][trace2-normal-docs] for more details.
670+
671+
#### Example
672+
673+
```shell
674+
git config --global trace2.normalTarget ~/log.normal
675+
```
676+
677+
If the value of `trace2.normalTarget` is a full path to a file in an existing
678+
directory, logs are appended to the file.
679+
680+
If the value of `trace2.normalTarget` is `true` or `1`, logs are written to
681+
standard error.
682+
683+
Defaults to disabled.
684+
685+
**Also see: [GIT_TRACE2][trace2-normal-env]**
686+
687+
---
688+
689+
### trace2.eventTarget
690+
691+
Turns on Trace2 Event Format tracing - see [Git's Trace2 Event Format
692+
documentation][trace2-event-docs] for more details.
693+
694+
#### Example
695+
696+
```shell
697+
git config --global trace2.eventTarget ~/log.event
698+
```
699+
700+
If the value of `trace2.eventTarget` is a full path to a file in an existing
701+
directory, logs are appended to the file.
702+
703+
If the value of `trace2.eventTarget` is `true` or `1`, logs are written to
704+
standard error.
705+
706+
Defaults to disabled.
707+
708+
**Also see: [GIT_TRACE2_EVENT][trace2-event-env]**
709+
710+
---
711+
712+
### trace2.perfTarget
713+
714+
Turns on Trace2 Performance Format tracing - see [Git's Trace2 Performance
715+
Format documentation][trace2-performance-docs] for more details.
716+
717+
#### Example
718+
719+
```shell
720+
git config --global trace2.perfTarget ~/log.perf
721+
```
722+
723+
If the value of `trace2.perfTarget` is a full path to a file in an existing
724+
directory, logs are appended to the file.
725+
726+
If the value of `trace2.perfTarget` is `true` or `1`, logs are written to
727+
standard error.
728+
729+
Defaults to disabled.
730+
731+
**Also see: [GIT_TRACE2_PERF][trace2-performance-env]**
732+
664733
[auto-detection]: autodetect.md
665734
[azure-tokens]: azrepos-users-and-tokens.md
666735
[use-http-path]: https://git-scm.com/docs/gitcredentials/#Documentation/gitcredentials.txt-useHttpPath
@@ -701,4 +770,10 @@ git config --global credential.azreposCredentialType oauth
701770
[provider-migrate]: migration.md#gcm_authority
702771
[cache-options]: https://git-scm.com/docs/git-credential-cache#_options
703772
[pass]: https://www.passwordstore.org/
773+
[trace2-normal-docs]: https://git-scm.com/docs/api-trace2#_the_normal_format_target
774+
[trace2-normal-env]: environment.md#GIT_TRACE2
775+
[trace2-event-docs]: https://git-scm.com/docs/api-trace2#_the_event_format_target
776+
[trace2-event-env]: environment.md#GIT_TRACE2_EVENT
777+
[trace2-performance-docs]: https://git-scm.com/docs/api-trace2#_the_performance_format_target
778+
[trace2-performance-env]: environment.md#GIT_TRACE2_PERF
704779
[wam]: windows-broker.md

docs/environment.md

+93
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,93 @@ export GCM_AZREPOS_CREDENTIALTYPE="oauth"
830830

831831
**Also see: [credential.azreposCredentialType][credential-azrepos-credential-type]**
832832

833+
---
834+
835+
### GIT_TRACE2
836+
837+
Turns on Trace2 Normal Format tracing - see [Git's Trace2 Normal Format
838+
documentation][trace2-normal-docs] for more details.
839+
840+
#### Windows
841+
842+
```batch
843+
SET GIT_TRACE2=%UserProfile%\log.normal
844+
```
845+
846+
#### macOS/Linux
847+
848+
```bash
849+
export GIT_TRACE2=~/log.normal
850+
```
851+
852+
If the value of `GIT_TRACE2` is a full path to a file in an existing directory,
853+
logs are appended to the file.
854+
855+
If the value of `GIT_TRACE2` is `true` or `1`, logs are written to standard
856+
error.
857+
858+
Defaults to disabled.
859+
860+
**Also see: [trace2.normalFormat][trace2-normal-config]**
861+
862+
---
863+
864+
### GIT_TRACE2_EVENT
865+
866+
Turns on Trace2 Event Format tracing - see [Git's Trace2 Event Format
867+
documentation][trace2-event-docs] for more details.
868+
869+
#### Windows
870+
871+
```batch
872+
SET GIT_TRACE2_EVENT=%UserProfile%\log.event
873+
```
874+
875+
#### macOS/Linux
876+
877+
```bash
878+
export GIT_TRACE2_EVENT=~/log.event
879+
```
880+
881+
If the value of `GIT_TRACE2_EVENT` is a full path to a file in an existing
882+
directory, logs are appended to the file.
883+
884+
If the value of `GIT_TRACE2_EVENT` is `true` or `1`, logs are written to
885+
standard error.
886+
887+
Defaults to disabled.
888+
889+
**Also see: [trace2.eventFormat][trace2-event-config]**
890+
891+
---
892+
893+
### GIT_TRACE2_PERF
894+
895+
Turns on Trace2 Performance Format tracing - see [Git's Trace2 Performance
896+
Format documentation][trace2-event-docs] for more details.
897+
898+
#### Windows
899+
900+
```batch
901+
SET GIT_TRACE2_PERF=%UserProfile%\log.perf
902+
```
903+
904+
#### macOS/Linux
905+
906+
```bash
907+
export GIT_TRACE2_PERF=~/log.perf
908+
```
909+
910+
If the value of `GIT_TRACE2_PERF` is a full path to a file in an existing
911+
directory, logs are appended to the file.
912+
913+
If the value of `GIT_TRACE2_PERF` is `true` or `1`, logs are written to
914+
standard error.
915+
916+
Defaults to disabled.
917+
918+
**Also see: [trace2.perfFormat][trace2-performance-config]**
919+
833920
[autodetect]: autodetect.md
834921
[azure-access-tokens]: azrepos-users-and-tokens.md
835922
[configuration]: configuration.md
@@ -867,4 +954,10 @@ export GCM_AZREPOS_CREDENTIALTYPE="oauth"
867954
[libsecret]: https://wiki.gnome.org/Projects/Libsecret
868955
[migration-guide]: migration.md#gcm_authority
869956
[passwordstore]: https://www.passwordstore.org/
957+
[trace2-normal-docs]: https://git-scm.com/docs/api-trace2#_the_normal_format_target
958+
[trace2-normal-config]: configuration.md#trace2normalTarget
959+
[trace2-event-docs]: https://git-scm.com/docs/api-trace2#_the_event_format_target
960+
[trace2-event-config]: configuration.md#trace2eventTarget
961+
[trace2-performance-docs]: https://git-scm.com/docs/api-trace2#_the_performance_format_target
962+
[trace2-performance-config]: configuration.md#trace2perfTarget
870963
[windows-broker]: windows-broker.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Threading;
4+
using Atlassian.Bitbucket.UI.Commands;
5+
using Atlassian.Bitbucket.UI.Controls;
6+
using Avalonia;
7+
using GitCredentialManager;
8+
using GitCredentialManager.UI;
9+
10+
namespace Atlassian.Bitbucket.UI
11+
{
12+
public static class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
// If we have no arguments then just start the app with the test window.
17+
if (args.Length == 0)
18+
{
19+
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
20+
return;
21+
}
22+
23+
// Create the dispatcher on the main thread. This is required
24+
// for some platform UI services such as macOS that mandates
25+
// all controls are created/accessed on the initial thread
26+
// created by the process (the process entry thread).
27+
Dispatcher.Initialize();
28+
29+
// Run AppMain in a new thread and keep the main thread free
30+
// to process the dispatcher's job queue.
31+
var appMain = new Thread(AppMain) {Name = nameof(AppMain)};
32+
appMain.Start(args);
33+
34+
// Process the dispatcher job queue (aka: message pump, run-loop, etc...)
35+
// We must ensure to run this on the same thread that it was created on
36+
// (the main thread) so we cannot use any async/await calls between
37+
// Dispatcher.Create and Run.
38+
Dispatcher.MainThread.Run();
39+
40+
// Execution should never reach here as AppMain terminates the process on completion.
41+
throw new InvalidOperationException("Main dispatcher job queue shutdown unexpectedly");
42+
}
43+
44+
private static void AppMain(object o)
45+
{
46+
string[] args = (string[]) o;
47+
48+
// Set the session id (sid) for the helper process, to be
49+
// used when TRACE2 tracing is enabled.
50+
ProcessManager.CreateSid();
51+
using (var context = new CommandContext())
52+
using (var app = new HelperApplication(context))
53+
{
54+
// Initialize TRACE2 system
55+
context.Trace2.Initialize(DateTimeOffset.UtcNow);
56+
57+
// Write the start and version events
58+
context.Trace2.Start(context.ApplicationPath, args);
59+
60+
app.RegisterCommand(new CredentialsCommandImpl(context));
61+
62+
int exitCode = app.RunAsync(args)
63+
.ConfigureAwait(false)
64+
.GetAwaiter()
65+
.GetResult();
66+
67+
context.Trace2.Stop(exitCode);
68+
Environment.Exit(exitCode);
69+
}
70+
}
71+
72+
public static AppBuilder BuildAvaloniaApp()
73+
=> AppBuilder.Configure(() => new AvaloniaApp(() => new TesterWindow()))
74+
.UsePlatformDetect()
75+
.LogToTrace();
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Threading;
4+
using Atlassian.Bitbucket.UI.Commands;
5+
using Atlassian.Bitbucket.UI.Controls;
6+
using Avalonia;
7+
using GitCredentialManager;
8+
using GitCredentialManager.UI;
9+
10+
namespace Atlassian.Bitbucket.UI
11+
{
12+
public static class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
// If we have no arguments then just start the app with the test window.
17+
if (args.Length == 0)
18+
{
19+
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
20+
return;
21+
}
22+
23+
// Create the dispatcher on the main thread. This is required
24+
// for some platform UI services such as macOS that mandates
25+
// all controls are created/accessed on the initial thread
26+
// created by the process (the process entry thread).
27+
Dispatcher.Initialize();
28+
29+
// Run AppMain in a new thread and keep the main thread free
30+
// to process the dispatcher's job queue.
31+
var appMain = new Thread(AppMain) {Name = nameof(AppMain)};
32+
appMain.Start(args);
33+
34+
// Process the dispatcher job queue (aka: message pump, run-loop, etc...)
35+
// We must ensure to run this on the same thread that it was created on
36+
// (the main thread) so we cannot use any async/await calls between
37+
// Dispatcher.Create and Run.
38+
Dispatcher.MainThread.Run();
39+
40+
// Execution should never reach here as AppMain terminates the process on completion.
41+
throw new InvalidOperationException("Main dispatcher job queue shutdown unexpectedly");
42+
}
43+
44+
private static void AppMain(object o)
45+
{
46+
string[] args = (string[]) o;
47+
48+
// Set the session id (sid) for the helper process, to be
49+
// used when TRACE2 tracing is enabled.
50+
SidManager.CreateSid();
51+
using (var context = new CommandContext())
52+
using (var app = new HelperApplication(context))
53+
{
54+
// Initialize TRACE2 system
55+
context.Trace2.Initialize(DateTimeOffset.UtcNow);
56+
57+
// Write the start and version events
58+
context.Trace2.Start(context.ApplicationPath, args);
59+
60+
app.RegisterCommand(new CredentialsCommandImpl(context));
61+
62+
int exitCode = app.RunAsync(args)
63+
.ConfigureAwait(false)
64+
.GetAwaiter()
65+
.GetResult();
66+
67+
context.Trace2.Stop(exitCode);
68+
Environment.Exit(exitCode);
69+
}
70+
}
71+
72+
public static AppBuilder BuildAvaloniaApp()
73+
=> AppBuilder.Configure(() => new AvaloniaApp(() => new TesterWindow()))
74+
.UsePlatformDetect()
75+
.LogToTrace();
76+
}
77+
}

src/shared/Atlassian.Bitbucket.UI.Avalonia/Program_LOCAL_61045.cs

Whitespace-only changes.

0 commit comments

Comments
 (0)