etishor / Metrics.NET

The Metrics.NET library provides a way of instrumenting applications with custom metrics (timers, histograms, counters etc) that can be reported in various ways and can provide insights on what is happening inside a running application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CompetelyDisableMetrics is broken

o-mdr opened this issue · comments

I cannot disable metrics and suspect its a bug. Steps to reproduce:

  1. Set Metrics.Central as a startup project
  2. Insert <add key="Metrics.CompetelyDisableMetrics" value="true"/> into config file
  3. Run in Visual Studio

Code throws a NRE at line 251 of MetricsConfig.cs

private static bool ConfigureMetricsEnabledDisabled()
{
    try
    {
        var isDisabled = ConfigurationManager.AppSettings["Metrics.CompetelyDisableMetrics"];
        if (!string.IsNullOrEmpty(isDisabled) && isDisabled.ToUpperInvariant() == "TRUE")
        {
>>>>        Metric.Advanced.CompletelyDisableMetrics(); // <<<<< HERE Advanced is null
            log.Info(() => "Metrics: [...]");
            return true;
        }
        return false;
    }
    catch (Exception x)
    {
        log.ErrorException("Metrics: Error disabling metrics library", x);
        throw new InvalidOperationException("Invalid Metrics[...]", x);
    }
}

Fixed in dev, will be on nuget by Monday.
Thanks.