Metrics with Prometheus missing counters

Hello.

We’ve been using prometheus for a while on our endpoints (to let the infra scrape some basic stats) and now I’m trying to add NServiceBus specific metrics.

I’m looking at Capture and visualize metrics using Prometheus and Grafana • Metrics Samples • Particular Docs and we do get metrics, but we’re missing two:

nservicebus_criticaltime_seconds
nservicebus_processingtime_seconds

We do however have

nservicebus_criticaltime_seconds_sum
nservicebus_criticaltime_seconds_count
nservicebus_processingtime_seconds_sum
nservicebus_processingtime_seconds_count

but not the ones without the suffix.

If I run the sample Metrics 3 I do however get all the counters. I’ve found out that the difference from our services are that we’re using a newer version of prometheus-net (as we’re running on .net core).

If I update the prometheus-net in the sample from 1.3.5 to 3.1.4 (latest atm) that sample also misses the two metrics I mentioned.

Any ideas?

//J

Hi Jens

I have a hunch it is related to a breaking change or a regression in the client. I’ve downloaded the sample and let it run with 2.x version of prometheus net client and it works fine. Once I upgrade to the 3.0 version of the client it no longer works.

Regards
Daniel

Any ideas if it’s possible to make it work with the 3.0 client? Anything I can do on my side or is it something within NServiceBus.Metrics or the prometheus lib itself? We have other prometheus metrics which at the moment has a dependency on the 3.x client and I would rather not have to downgrade those things…

If it isn’t anything you guys can do, I will check elsewhere! :slight_smile:

Jens according to my brief research it looks like something in the prometheus lib itself because the sample code did not change between those two versions nor did the metrics library in ways that would explain the behavior.

Maybe I can shuffle some time free to have a deeper look into it but I can’t promise because I’m traveling soon and will be unavailable for a few days.

No worries, Daniel! Have a nice trip!

Hi,

I just came across this and did some digging and found this in the documentation.

prometheus-net#summary

So for the example the CreateSummary needs changing to

var summary = Metrics.CreateSummary(prometheusName, duration.Description,
                                    new SummaryConfiguration
                                    {
                                        Objectives = new[]
                                                     {
                                                         new QuantileEpsilonPair(0.5, 0.05),
                                                         new QuantileEpsilonPair(0.9, 0.01),
                                                         new QuantileEpsilonPair(0.99, 0.001)
                                                     },
                                        LabelNames = Labels
                                    });

I realise this is an old thread, but thought it might save someone time in the future.

Nic.

Hi Nicholas,

Thanks for the heads up. Would you be able to contribute this improvement to the sample and then ping me as a reviewer?

Regards
Daniel

Nicholas has update the sample

and the changes have already been merged

Thanks again for the contribution Nic!

1 Like