-
Notifications
You must be signed in to change notification settings - Fork 384
Fixed dotnet-counters rendering issues #3353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
1577f73
7de8e5b
3ecd952
ceab27b
c97259d
64129f8
5c0b595
13755a4
4f59900
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,9 @@ public ObservedTagSet(string tags) | |
| private readonly object _lock = new object(); | ||
| private readonly Dictionary<string, ObservedProvider> _providers = new Dictionary<string, ObservedProvider>(); // Tracks observed providers and counters. | ||
| private const int Indent = 4; // Counter name indent size. | ||
| private int _maxNameLength = 40; // Allow room for 40 character counter names by default. | ||
| private const int CounterValueLength = 15; | ||
|
|
||
| private int _maxNameLength = 60; // Allow room for 60 character counter names by default. | ||
| private int _statusRow; // Row # of where we print the status of dotnet-counters | ||
| private int _topRow; | ||
| private bool _paused = false; | ||
|
|
@@ -69,6 +70,9 @@ public ObservedTagSet(string tags) | |
| private int _maxRow = -1; | ||
| private bool _useAnsi = false; | ||
|
|
||
| private int _consoleHeight = -1; | ||
| private int _consoleWidth = -1; | ||
|
|
||
| public ConsoleWriter(bool useAnsi) | ||
| { | ||
| this._useAnsi = useAnsi; | ||
|
|
@@ -126,9 +130,14 @@ public void AssignRowsAndInitializeDisplay() | |
| { | ||
| Clear(); | ||
|
|
||
| _consoleWidth = Console.WindowWidth; | ||
| _consoleHeight = Console.WindowHeight; | ||
|
|
||
| int row = Console.CursorTop; | ||
| _topRow = row; | ||
| Console.WriteLine("Press p to pause, r to resume, q to quit."); row++; | ||
|
|
||
| string instructions = "Press p to pause, r to resume, q to quit."; | ||
| Console.WriteLine((instructions.Length < _consoleWidth) ? instructions : instructions.Substring(0, _consoleWidth)); row++; | ||
| Console.WriteLine($" Status: {GetStatus()}"); _statusRow = row++; | ||
| if (_errorText != null) | ||
| { | ||
|
|
@@ -140,22 +149,39 @@ public void AssignRowsAndInitializeDisplay() | |
| foreach (ObservedProvider provider in _providers.Values.OrderBy(p => p.KnownProvider == null).ThenBy(p => p.Name)) // Known providers first. | ||
| { | ||
| Console.WriteLine($"[{provider.Name}]"); row++; | ||
| int rowCount = 0; | ||
|
|
||
| foreach (ObservedCounter counter in provider.Counters.Values.OrderBy(c => c.DisplayName)) | ||
| { | ||
| if(rowCount >= _consoleHeight - 5) | ||
|
||
| { | ||
| break; | ||
| } | ||
|
|
||
| _maxNameLength = Math.Max(Math.Min(80, _consoleWidth) - (CounterValueLength + Indent + 1), 0); | ||
dramos020 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dramos020 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mikelle-rogers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| string name = MakeFixedWidth($"{new string(' ', Indent)}{counter.DisplayName}", Indent + _maxNameLength); | ||
| counter.Row = row++; | ||
| if (counter.RenderValueInline) | ||
| { | ||
| Console.WriteLine($"{name} {FormatValue(counter.LastValue)}"); | ||
| rowCount++; | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine(name); | ||
| rowCount++; | ||
| foreach (ObservedTagSet tagSet in counter.TagSets.Values.OrderBy(t => t.Tags)) | ||
| { | ||
| if(rowCount >= _consoleHeight - 5) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| _maxNameLength = Math.Max(Math.Min(80, _consoleWidth) - (CounterValueLength + Indent + 1), 0); | ||
mikelle-rogers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| string tagName = MakeFixedWidth($"{new string(' ', 2 * Indent)}{tagSet.Tags}", Indent + _maxNameLength); | ||
| Console.WriteLine($"{tagName} {FormatValue(tagSet.LastValue)}"); | ||
| tagSet.Row = row++; | ||
| rowCount++; | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -222,6 +248,11 @@ public void CounterPayloadReceived(CounterPayload payload, bool pauseCmdSet) | |
| redraw = true; | ||
| } | ||
|
|
||
| if(Console.WindowWidth != _consoleWidth || Console.WindowHeight != _consoleHeight) | ||
| { | ||
| redraw=true; | ||
| } | ||
|
|
||
| if (redraw) | ||
| { | ||
| AssignRowsAndInitializeDisplay(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.