-
-
Notifications
You must be signed in to change notification settings - Fork 312
Closed
Description
Given the following code, I expect 3 different counters each with a value of 1. However, it appears that a single counter is increased 3 times.
using ConsoleApp1;
using Prometheus;
Console.WriteLine( "Hello, World!" );
Metrics.SuppressDefaultMetrics();
var metricServer = new KestrelMetricServer( port: 1234 );
metricServer.Start();
Metrics.DefaultRegistry.SetStaticLabels( new Dictionary<string, string>
{
// Labels applied to all metrics in the registry.
{ "DefaultRegistry", "testing" }
}
);
var c1 = new Class1( "c1" );
var c2 = new Class1( "c2" );
var c3 = new Class1( "c3" );
Console.ReadKey();
using Prometheus;
namespace ConsoleApp1
{
internal class Class1
{
private IMetricFactory MetricFactory { get; set; }
private Counter c1 { get; set; }
public Class1( string name )
{
// Labels applied to all metrics created via this factory.
MetricFactory = Metrics.WithLabels( new Dictionary<string, string> { { "testname", name } } );
c1 = MetricFactory.CreateCounter( "test", "test counter" );
c1.Inc();
}
}
}
results
Metadata
Metadata
Assignees
Labels
No labels