Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

Continue the work of #5242 and add a --dsrouter switch to dotnet-gcdump collect

fixes #5436

Continue the work of dotnet#5242 and add a --dsrouter switch to `dotnet-gcdump collect`

fixes dotnet#5436
tommcdon
tommcdon previously approved these changes Jun 3, 2025
Copy link
Member

@tommcdon tommcdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tommcdon
Copy link
Member

tommcdon commented Jun 3, 2025

@StephaneDelcroix would you mind submitting a docs PR for the new --dsrouter switch on dotnet-gcdump?

@StephaneDelcroix
Copy link
Contributor Author

that's mainly unfinished work from last time

Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@StephaneDelcroix
Copy link
Contributor Author

StephaneDelcroix commented Jun 4, 2025

@StephaneDelcroix would you mind submitting a docs PR for the new --dsrouter switch on dotnet-gcdump?

dotnet/docs#46547

@tommcdon tommcdon enabled auto-merge (squash) July 16, 2025 20:54
@tommcdon
Copy link
Member

/ba-g failures are unrelated

@steveisok
Copy link
Member

We're going to need to give this another run through CI.

@tommcdon
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tommcdon tommcdon merged commit fcaeae3 into dotnet:main Jul 18, 2025
20 of 21 checks passed
jonathanpeppers added a commit that referenced this pull request Jul 21, 2025
Context: #5494
Context: #5241
Fixes: #5435

We added `--dsrouter` switch to both `dotnet-trace` and
`dotnet-gcdump`, which runs `dotnet-dsrouter` as a child process.

Many of `dotnet-dsrouter`'s console messages are pretty useful for
developers, but we are simply ignoring them:

    private static async Task ReadAndIgnoreAllStreamAsync(StreamReader streamToIgnore, CancellationToken cancelToken)
    {
        Memory<char> memory = new char[4096];
        while (await streamToIgnore.ReadAsync(memory, cancelToken).ConfigureAwait(false) != 0)
        {
        }
    }

To make this a bit more useful, we now log the output to either
`Console.Out` or `Console.Error` where appropriate.

If we simply did:

    string line;
    while ((line = await streamToRead.ReadLineAsync(cancelToken).ConfigureAwait(false)) != null)
    {
        output.WriteLine(line);
    }

This would work fine, but we'd lose all coloring.

`dotnet-dsrouter` uses `SimpleConsoleFormatter` to colorize its output:

https://github.com/dotnet/runtime/blob/aadcceeb03ce0ecbc2ad645de0feb10189daa64c/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs#L163-L199

So, for now, a very simple solution is to check the known prefixes and
add coloring. This looks to have a pretty good result.

I also dropped the duplicate message:

    WARNING: dotnet-dsrouter is a development tool not intended for production environments.

Now that we print all of `dotnet-dsrouter`'s output, we can handle
this case and color it yellow.
jonathanpeppers added a commit that referenced this pull request Jul 21, 2025
Context: #5494
Context: #5241
Fixes: #5435

We added `--dsrouter` switch to both `dotnet-trace` and `dotnet-gcdump`,
which runs `dotnet-dsrouter` as a child process.

Many of `dotnet-dsrouter`'s console messages are pretty useful for
developers, but we are simply ignoring them:

private static async Task ReadAndIgnoreAllStreamAsync(StreamReader
streamToIgnore, CancellationToken cancelToken)
    {
        Memory<char> memory = new char[4096];
while (await streamToIgnore.ReadAsync(memory,
cancelToken).ConfigureAwait(false) != 0)
        {
        }
    }

To make this a bit more useful, we now log the output to either
`Console.Out` or `Console.Error` where appropriate.

If we simply did:

    string line;
while ((line = await
streamToRead.ReadLineAsync(cancelToken).ConfigureAwait(false)) != null)
    {
        output.WriteLine(line);
    }

This would work fine, but we'd lose all coloring.

`dotnet-dsrouter` uses `SimpleConsoleFormatter` to colorize its output:


https://github.com/dotnet/runtime/blob/aadcceeb03ce0ecbc2ad645de0feb10189daa64c/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs#L163-L199

So, for now, a very simple solution is to check the known prefixes and
add coloring. This looks to have a pretty good result.

I also dropped the duplicate message:

WARNING: dotnet-dsrouter is a development tool not intended for
production environments.

Now that we print all of `dotnet-dsrouter`'s output, we can handle this
case and color it yellow.

<img width="2524" height="582" alt="image"
src="https://github.com/user-attachments/assets/4924ec93-c616-4511-83f8-f318f4ce4471"
/>
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet-gcdump collect --dsrouter switch

4 participants