Skip to content

Commit 217c863

Browse files
committed
Add test verifying multiple tags per measurement display correctly
Adds a regression test for issue #5683 that explicitly verifies when a measurement has multiple tags (e.g. ExistingTag=Value1,NewTag=Value2), all tags are displayed in the console output. Note: This test passes both with and without the defensive code improvements in ConsoleWriter.cs, suggesting the core multi-tag functionality was already working. The defensive code improvements still add value by preventing potential crashes on malformed input.
1 parent 0b6acc6 commit 217c863

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/tests/dotnet-counters/ConsoleExporterTests.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,26 +284,28 @@ public void LongMultidimensionalTagsAreTruncated()
284284
public void MultipleTagsPerMeasurementAreDisplayed()
285285
{
286286
// Regression test for issue #5683
287-
// Verifies that when a single measurement has multiple tags,
288-
// all tags are displayed correctly
289-
MockConsole console = new MockConsole(70, 40);
287+
// User reported that when adding a second tag to their ObservableGauge/ObservableCounter,
288+
// only the first tag was displayed and the second tag (NewTag) was not shown
289+
MockConsole console = new MockConsole(90, 40); // Wide console to see both tags clearly
290290
ConsoleWriter exporter = new ConsoleWriter(console);
291291
exporter.Initialize();
292292

293-
// Simulate ObservableGauge/ObservableCounter with multiple tags per measurement
293+
// Simulate a single measurement with two tags: ExistingTag and NewTag
294+
// This matches the user's code: new Measurement<long>(value,
295+
// new KeyValuePair("ExistingTag", Value1),
296+
// new KeyValuePair("NewTag", "Value2"))
294297
exporter.CounterPayloadReceived(CreateMeterCounterPreNet8("MyApp", "RequestCount", "{requests}", "ExistingTag=Value1,NewTag=Value2", 100), false);
295-
exporter.CounterPayloadReceived(CreateMeterCounterPreNet8("MyApp", "RequestCount", "{requests}", "ExistingTag=Value3,NewTag=Value4", 200), false);
296298

299+
// Both tags should be displayed as columns
297300
console.AssertLinesEqual("Press p to pause, r to resume, q to quit.",
298301
" Status: Running",
299302
"",
300-
"Name Current Value",
303+
"Name Current Value",
301304
"[MyApp]",
302305
" RequestCount ({requests} / 1 sec)",
303306
" ExistingTag NewTag",
304307
" ----------- ------",
305-
" Value1 Value2 100",
306-
" Value3 Value4 200");
308+
" Value1 Value2 100");
307309
}
308310

309311
[Fact]

0 commit comments

Comments
 (0)