-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
Gauges can be distincted by tags, but process holds old gauge with old tags, after this removed from data source.
This behaviour is fine for counters, but make unuseful metrics values for gauges.
Reproduction Steps
Example source code:
using System.Diagnostics.Metrics;
namespace Test
{
public class Program
{
static Meter s_meter = new Meter("HatCo.HatStore", "1.0.0");
static IEnumerable<Measurement<int>> m;
static void Main(string[] args)
{
s_meter.CreateObservableGauge<int>("orders-pending", () => m);
m = new Measurement<int>[]
{
new Measurement<int>(1, new KeyValuePair<string,object>("Country", "Italy")),
};
Console.WriteLine("Change to Spain");
Console.ReadLine();
m = new Measurement<int>[]
{
new Measurement<int>(1, new KeyValuePair<string,object>("Country", "Spain")),
};
Console.WriteLine("Remove Spain, Update Italy");
Console.ReadLine();
m = new Measurement<int>[]
{
new Measurement<int>(2, new KeyValuePair<string,object>("Country", "Italy")),
};
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
}
}Expected behavior
Run example and watch its metrics:
dotnet-counters monitor --name ConsoleApp HatCo.HatStore
After process started metrics is:
[HatCo.HatStore]
orders-pending
Country=Italy 1
Press enter in example console, this will change metrics from Italy to Spain:
[HatCo.HatStore]
orders-pending
Country=Spain 1
Here is added Spain and removed Italy.
Press enter in example console, this will change metrics to Italy:
[HatCo.HatStore]
orders-pending
Country=Italy 2
Now we have updated Italy and removed Spain.
Actual behavior
Run example and watch its metrics:
dotnet-counters monitor --name ConsoleApp HatCo.HatStore
After process started metrics is:
[HatCo.HatStore]
orders-pending
Country=Italy 1
Press enter in example console, this will change metrics from Italy to Spain:
[HatCo.HatStore]
orders-pending
Country=Italy 1
Country=Spain 1
Here is added Spain, but removed Italy is remainded.
Press enter in example console, this will change metrics to Italy:
[HatCo.HatStore]
orders-pending
Country=Italy 2
Country=Spain 1
Now we have update Italy, but remainded Spain.
Regression?
No response
Known Workarounds
Track metrics+tags in own Measurement collection. Return this collection to CreateObservableGauge.
In own collection track missing metrics during update (with respect to metric name, tags, and tags combinations) - set its value to zero.
Configuration
No response
Other information
No response