Performance Counter for Critical Time won't install

I’m have problems getting the Critical Time performance counter to work. I have the SLA violations countdown in, but we want to monitor Critical Time as well.

We host NServiceBus as a windows service, and I install with two profiles: nservicebus.production and nservicebus.performancecounters

NuGet Components Versions
NServiceBus 6.4.0
NServiceBus.Host 7.0.2
NServiceBus.Metrics 1.1.0
NServiceBus.Metrics.PerformanceCounters 1.1.2
NServiceBus.Metrics.PerformanceCounters.MsBuild 1.1.2 (for script creation)

From my EndpointConfig

var performanceCounters = endpointConfiguration.EnableWindowsPerformanceCounters();
performanceCounters.EnableSLAPerformanceCounters(System.TimeSpan.FromMinutes(1)); // to enable the SLA counter
endpointConfiguration.EnableMetrics(); // try to enable duration counters

I use the MsBuild-package to create PowerShell scripts, but it only creates the counter category for “SLA violations countdown” – not for any durations:

Function InstallNSBPerfCounters {
    
    $category = @{Name="NServiceBus"; Description="NServiceBus statistics"}
    $counters = New-Object System.Diagnostics.CounterCreationDataCollection
    $counters.AddRange(@(
        New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.",  NumberOfItems32

    ))
...

I have no error messages during installation, but I only get the “SLA violations countdown counter” in Performance Monitor.

Have I missed something?

Hi @rune.rystad,

You’re not missing something, I just verified this with our sample from docs website. I get the same behavior.

This is weird, because we actually have a test that verifies script creation is still working. I need to investigate this further and figure why it’s not producing the correct script.

In the meantime, you can use the script from the GitHub repo used in the test : https://github.com/Particular/NServiceBus.Metrics.PerformanceCounters/blob/master/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1

I also zipped it and attached it to this post:

CreateNSBPerfCounters.zip (896 Bytes)

Let me know if this helps you out, or if you wanted the C# script.

Regards,
Dennis

Thanks for the script! It helped me install the counters, and now I can
select them in Performance Monitor.

However, the counters does not seem to be counting. I’ve activated
journaling on the queue, so I see that a message have arrived, but “#of
msgs pulled from the input queue / sec” still shows a Maximum value of
0,000. Maybe the counter metrics are really missing…? Even though I
do: endpointConfiguration.EnableMetrics();

Still puzzled,

Rune

2017-09-28 10:23 GMT+02:00 Dennis van der Stelt <
discourse@discuss.particular.net>:

Hmmm, I tested it with the sample, but with me the counters do show values.
Processing Time and Critical Time only display values when they’re above 1 second. We are aware of this and are almost done with a solution for it. But successfully processed and pulled from queue should definitely show values. Are you sending enough messages at the same time? The current solution works with Metrics.NET library, which averages out the numbers. Exactly the reason why we’re building a different solution, but this might influence your numbers.

I just pushed 2000 messages (processing at about 3 per sec) and should
definitely have values, but still silence in Performance Monitor.

I’ve recreated the counters (again) and reinstalled the service.

But thanks for testing - now I know that it should work (and I made the
counters install at least)!

Rune

2017-09-28 11:32 GMT+02:00 Dennis van der Stelt <
discourse@discuss.particular.net>:

Are you looking at the correct instance in PerfMon? Every endpoint creates its own instance for the performance counters.
If you can’t get it to work, we can get on a quick call to have a look, if you’d like.

Yes, correct instance.

I’ve been testing on a development server so far - but now I’ve found that it actually works on my computer. Will have to ship it, then.

Most developers I know are satisfied when it compiles on their computer, so kudos to you for the extra effort! :slight_smile:

But let me know if the behavior remains and we can set up a call to check. Otherwise you could check the Sample and see if that works. Or we can have a call. What suits you best!

Oh, what I suddenly remember. Sometimes the performance counters are messed up. Deleting them and recreating them might help. But since you just created them, this is probably not an issue. But it’s always good to know.

Thanks, I’m currently investigating if it can be related to permissions.

I’ve already adjusted the script to deleted and recreate :slight_smile:

I’ll let you know what I find out.