Skip to content

Commit

Permalink
docs: add trace2 to config/env documentation
Browse files Browse the repository at this point in the history
Add Trace2 config/env var options to GCM's configuration/environment
documentation to improve discoverability.
  • Loading branch information
ldennington committed Apr 27, 2023
1 parent d6a4cf3 commit f6d82a8
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 0 deletions.
75 changes: 75 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,75 @@ git config --global credential.azreposCredentialType oauth

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

---

### trace2.normalTarget

Turns on Trace2 Normal Format tracing - see [Git's Trace2 Normal Format
documentation][trace2-normal-docs] for more details.

#### Example

```shell
git config --global trace2.normalTarget ~/log.normal
```

If the value of `trace2.normalTarget` is a full path to a file in an existing
directory, logs are appended to the file.

If the value of `trace2.normalTarget` is `true` or `1`, logs are written to
standard error.

Defaults to disabled.

**Also see: [GIT_TRACE2][trace2-normal-env]**

---

### trace2.eventTarget

Turns on Trace2 Event Format tracing - see [Git's Trace2 Event Format
documentation][trace2-event-docs] for more details.

#### Example

```shell
git config --global trace2.eventTarget ~/log.event
```

If the value of `trace2.eventTarget` is a full path to a file in an existing
directory, logs are appended to the file.

If the value of `trace2.eventTarget` is `true` or `1`, logs are written to
standard error.

Defaults to disabled.

**Also see: [GIT_TRACE2_EVENT][trace2-event-env]**

---

### trace2.perfTarget

Turns on Trace2 Performance Format tracing - see [Git's Trace2 Performance
Format documentation][trace2-performance-docs] for more details.

#### Example

```shell
git config --global trace2.perfTarget ~/log.perf
```

If the value of `trace2.perfTarget` is a full path to a file in an existing
directory, logs are appended to the file.

If the value of `trace2.perfTarget` is `true` or `1`, logs are written to
standard error.

Defaults to disabled.

**Also see: [GIT_TRACE2_PERF][trace2-performance-env]**

[auto-detection]: autodetect.md
[azure-tokens]: azrepos-users-and-tokens.md
[use-http-path]: https://git-scm.com/docs/gitcredentials/#Documentation/gitcredentials.txt-useHttpPath
Expand Down Expand Up @@ -701,4 +770,10 @@ git config --global credential.azreposCredentialType oauth
[provider-migrate]: migration.md#gcm_authority
[cache-options]: https://git-scm.com/docs/git-credential-cache#_options
[pass]: https://www.passwordstore.org/
[trace2-normal-docs]: https://git-scm.com/docs/api-trace2#_the_normal_format_target
[trace2-normal-env]: environment.md#GIT_TRACE2
[trace2-event-docs]: https://git-scm.com/docs/api-trace2#_the_event_format_target
[trace2-event-env]: environment.md#GIT_TRACE2_EVENT
[trace2-performance-docs]: https://git-scm.com/docs/api-trace2#_the_performance_format_target
[trace2-performance-env]: environment.md#GIT_TRACE2_PERF
[wam]: windows-broker.md
93 changes: 93 additions & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,93 @@ export GCM_AZREPOS_CREDENTIALTYPE="oauth"

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

---

### GIT_TRACE2

Turns on Trace2 Normal Format tracing - see [Git's Trace2 Normal Format
documentation][trace2-normal-docs] for more details.

#### Windows

```batch
SET GIT_TRACE2=%UserProfile%\log.normal
```

#### macOS/Linux

```bash
export GIT_TRACE2=~/log.normal
```

If the value of `GIT_TRACE2` is a full path to a file in an existing directory,
logs are appended to the file.

If the value of `GIT_TRACE2` is `true` or `1`, logs are written to standard
error.

Defaults to disabled.

**Also see: [trace2.normalFormat][trace2-normal-config]**

---

### GIT_TRACE2_EVENT

Turns on Trace2 Event Format tracing - see [Git's Trace2 Event Format
documentation][trace2-event-docs] for more details.

#### Windows

```batch
SET GIT_TRACE2_EVENT=%UserProfile%\log.event
```

#### macOS/Linux

```bash
export GIT_TRACE2_EVENT=~/log.event
```

If the value of `GIT_TRACE2_EVENT` is a full path to a file in an existing
directory, logs are appended to the file.

If the value of `GIT_TRACE2_EVENT` is `true` or `1`, logs are written to
standard error.

Defaults to disabled.

**Also see: [trace2.eventFormat][trace2-event-config]**

---

### GIT_TRACE2_PERF

Turns on Trace2 Performance Format tracing - see [Git's Trace2 Performance
Format documentation][trace2-event-docs] for more details.

#### Windows

```batch
SET GIT_TRACE2_PERF=%UserProfile%\log.perf
```

#### macOS/Linux

```bash
export GIT_TRACE2_PERF=~/log.perf
```

If the value of `GIT_TRACE2_PERF` is a full path to a file in an existing
directory, logs are appended to the file.

If the value of `GIT_TRACE2_PERF` is `true` or `1`, logs are written to
standard error.

Defaults to disabled.

**Also see: [trace2.perfFormat][trace2-performance-config]**

[autodetect]: autodetect.md
[azure-access-tokens]: azrepos-users-and-tokens.md
[configuration]: configuration.md
Expand Down Expand Up @@ -867,4 +954,10 @@ export GCM_AZREPOS_CREDENTIALTYPE="oauth"
[libsecret]: https://wiki.gnome.org/Projects/Libsecret
[migration-guide]: migration.md#gcm_authority
[passwordstore]: https://www.passwordstore.org/
[trace2-normal-docs]: https://git-scm.com/docs/api-trace2#_the_normal_format_target
[trace2-normal-config]: configuration.md#trace2normalTarget
[trace2-event-docs]: https://git-scm.com/docs/api-trace2#_the_event_format_target
[trace2-event-config]: configuration.md#trace2eventTarget
[trace2-performance-docs]: https://git-scm.com/docs/api-trace2#_the_performance_format_target
[trace2-performance-config]: configuration.md#trace2perfTarget
[windows-broker]: windows-broker.md
77 changes: 77 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI.Avalonia/Program_BACKUP_61045.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Diagnostics;
using System.Threading;
using Atlassian.Bitbucket.UI.Commands;
using Atlassian.Bitbucket.UI.Controls;
using Avalonia;
using GitCredentialManager;
using GitCredentialManager.UI;

namespace Atlassian.Bitbucket.UI
{
public static class Program
{
public static void Main(string[] args)
{
// If we have no arguments then just start the app with the test window.
if (args.Length == 0)
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
return;
}

// Create the dispatcher on the main thread. This is required
// for some platform UI services such as macOS that mandates
// all controls are created/accessed on the initial thread
// created by the process (the process entry thread).
Dispatcher.Initialize();

// Run AppMain in a new thread and keep the main thread free
// to process the dispatcher's job queue.
var appMain = new Thread(AppMain) {Name = nameof(AppMain)};
appMain.Start(args);

// Process the dispatcher job queue (aka: message pump, run-loop, etc...)
// We must ensure to run this on the same thread that it was created on
// (the main thread) so we cannot use any async/await calls between
// Dispatcher.Create and Run.
Dispatcher.MainThread.Run();

// Execution should never reach here as AppMain terminates the process on completion.
throw new InvalidOperationException("Main dispatcher job queue shutdown unexpectedly");
}

private static void AppMain(object o)
{
string[] args = (string[]) o;

// Set the session id (sid) for the helper process, to be
// used when TRACE2 tracing is enabled.
ProcessManager.CreateSid();
using (var context = new CommandContext())
using (var app = new HelperApplication(context))
{
// Initialize TRACE2 system
context.Trace2.Initialize(DateTimeOffset.UtcNow);

// Write the start and version events
context.Trace2.Start(context.ApplicationPath, args);

app.RegisterCommand(new CredentialsCommandImpl(context));

int exitCode = app.RunAsync(args)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();

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

public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure(() => new AvaloniaApp(() => new TesterWindow()))
.UsePlatformDetect()
.LogToTrace();
}
}
77 changes: 77 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI.Avalonia/Program_BASE_61045.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Diagnostics;
using System.Threading;
using Atlassian.Bitbucket.UI.Commands;
using Atlassian.Bitbucket.UI.Controls;
using Avalonia;
using GitCredentialManager;
using GitCredentialManager.UI;

namespace Atlassian.Bitbucket.UI
{
public static class Program
{
public static void Main(string[] args)
{
// If we have no arguments then just start the app with the test window.
if (args.Length == 0)
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
return;
}

// Create the dispatcher on the main thread. This is required
// for some platform UI services such as macOS that mandates
// all controls are created/accessed on the initial thread
// created by the process (the process entry thread).
Dispatcher.Initialize();

// Run AppMain in a new thread and keep the main thread free
// to process the dispatcher's job queue.
var appMain = new Thread(AppMain) {Name = nameof(AppMain)};
appMain.Start(args);

// Process the dispatcher job queue (aka: message pump, run-loop, etc...)
// We must ensure to run this on the same thread that it was created on
// (the main thread) so we cannot use any async/await calls between
// Dispatcher.Create and Run.
Dispatcher.MainThread.Run();

// Execution should never reach here as AppMain terminates the process on completion.
throw new InvalidOperationException("Main dispatcher job queue shutdown unexpectedly");
}

private static void AppMain(object o)
{
string[] args = (string[]) o;

// Set the session id (sid) for the helper process, to be
// used when TRACE2 tracing is enabled.
SidManager.CreateSid();
using (var context = new CommandContext())
using (var app = new HelperApplication(context))
{
// Initialize TRACE2 system
context.Trace2.Initialize(DateTimeOffset.UtcNow);

// Write the start and version events
context.Trace2.Start(context.ApplicationPath, args);

app.RegisterCommand(new CredentialsCommandImpl(context));

int exitCode = app.RunAsync(args)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();

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

public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure(() => new AvaloniaApp(() => new TesterWindow()))
.UsePlatformDetect()
.LogToTrace();
}
}
Empty file.
Loading

0 comments on commit f6d82a8

Please sign in to comment.