DEV Community

Discussion on: Monitoring Your Dotnet Service Using Prometheus

Collapse
 
theofilis profile image
George Theofilis

Hello, I think I found some errors in your code snippets.

The IMetricWithTimer should be:

public interface IMetricWithTimer
{
    IDisposable CreateTimer(params string[] labels);
}
Enter fullscreen mode Exit fullscreen mode

And the Counter

public class Counter : ICounter
{
    private readonly PrometheusCounter _counter;

    public Counter(PrometheusCounter counter)
    {
        _counter = counter;
    }

    public IDisposable CreateTimer(params string[] labels)
        => _counter.WithLabels(labels).NewTimer();

    public void Increment(double value = 1, params string[] labels) => _counter.WithLabels(labels).Inc(value);

    // etc...
}
Enter fullscreen mode Exit fullscreen mode