'Custom metrics missing when using dotnet-monitor

I am trying to set up the dotnet-monitor to get Prometheus style metrics on the metrics endpoint, but I cannot get my custom metrics reported through the API.

I made an application from the example in Collect metrics from .NET documentation. Using dotnet-counters monitor -p <ProcessID> HatCo.HatStore The result is the expected:

[HatCo.HatStore]
    hats-sold (Count / 1 sec)                          4    

Trying to get it through the dotnet-monitor does not include this counter, neither in the metrics or the livemetrics endpoint.

The settings.json (as described in the documentation) used by dotnet-monitor looks like this:

{
    "$schema": "https://aka.ms/dotnet-monitor-schema",
    "DefaultProcess": {
        "Filters": [{
            "Key": "ProcessName",
            "Value": "ToBeMeasured"
        }]
    },
    "Metrics": {
        "Providers": [
            {"ProviderName": "HatCo.HatStore"}
        ]
    }
}

And I have played with the parameter "IncludeDefaultProviders": false, which works as expected (the systemruntime metrics are not produced).

Do I need to register the "HatCo.HatStore" somewhere in the application?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source