-
Couldn't load subscription status.
- Fork 381
Closed
Description
Description
👍 This will correctly register 1 metrics with 2 different tag values for type:
Meter meter = new Meter("HatCo.Store");
Counter<int> blueHatsSold = meter.CreateCounter<int>("hatco.store.hats_sold");
Counter<int> redHatsSold = meter.CreateCounter<int>("hatco.store.hats_sold");
Console.WriteLine("Press any key to exit");
while (!Console.KeyAvailable)
{
// Pretend our store has a transaction each second that sells 4 hats
Thread.Sleep(1000);
redHatsSold.Add(4, tag: new("type", "red"));
blueHatsSold.Add(5, tag: new("type", "blue"));
}👎 This creates 2 counter with same name, but tags specified at creation:
Meter meter = new Meter("HatCo.Store");
Counter<int> blueHatsSold = meter.CreateCounter<int>("hatco.store.hats_sold", null, null, [new("type", "blue")]);
Counter<int> redHatsSold = meter.CreateCounter<int>("hatco.store.hats_sold", null, null, [new("type", "red")]);
Console.WriteLine("Press any key to exit");
while (!Console.KeyAvailable)
{
// Pretend our store has a transaction each second that sells 4 hats
Thread.Sleep(1000);
redHatsSold.Add(4);
blueHatsSold.Add(5);
}dotnet-counters monitor -n ConsoleApp10 --counters HatCo.Store --showDeltas shows just 1 metric label for type=blue, that consistently shows a value that matches the blue; but a delta value that is the difference between blue and red.
So somehow the same metrics is reported on top of itself with wrong tags.
Reproduction Steps
See above code examples
Expected behavior
Both code examples work the same
Actual behavior
invalid metrics reported
Regression?
No response
Known Workarounds
The first example obviously works
Configuration
8.0
Other information
No response