Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type initializer exception in Metrics.MetricsErrorHandler (NRE in cctor) when starting Metrics.NET in my service #137

Open
sixlettervariables opened this issue Feb 16, 2017 · 3 comments

Comments

@sixlettervariables
Copy link

sixlettervariables commented Feb 16, 2017

Using the code from the quick start in my service, I receive the following TypeInitializationException:

System.TypeInitializationException: The type initializer for 'Metrics.MetricsErrorHandler' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Metrics.MetricsErrorHandler..cctor()
   --- End of inner exception stack trace ---
   at Metrics.MetricsErrorHandler.get_Handler()
   at Metrics.PerfCounters.PerformanceCounters.Register(MetricsContext context, String name, Unit unit, String category, String counter, String instance, Func`2 derivate, MetricTags tags)
   at Metrics.PerfCounters.PerformanceCounters.RegisterSystemCounters(MetricsContext context)
   at Metrics.PerformanceCountersConfigExtensions.<>c__DisplayClass3_0.<WithSystemCounters>b__0(MetricsContext ctx, Func`1 hs)
   at Metrics.MetricsConfig.<>c__DisplayClass18_0.<WithConfigExtension>b__0(MetricsContext m, Func`1 h)
   at Metrics.MetricsConfig.WithConfigExtension[T](Func`3 extension, Func`1 defaultValueProvider)
   at Metrics.MetricsConfig.WithConfigExtension(Action`2 extension)
   at Metrics.PerformanceCountersConfigExtensions.WithSystemCounters(MetricsConfig config, String context)
   at Metrics.PerformanceCountersConfigExtensions.WithAllCounters(MetricsConfig config, String systemContext, String applicationContext)

In-use code looks like this:

            try
            {
                Metric.Config
                      .WithHttpEndpoint("https://localhost:50000/")
                      .WithAllCounters();
            }
            catch (Exception ex)
            {
                this.Log().Error("Could not start Metrics.NET", ex);
            }

Using v0.4.8.

@yanjost
Copy link

yanjost commented Feb 21, 2017

Same here.

Error happens at this line:

private static readonly Meter errorMeter = Metric.Internal.Meter("Metrics Errors", Unit.Errors);

Metric.Internal is null when debugging

@AlexisColes
Copy link

did anyone have any other answer for this rather vague error? I am getting this error occur on one server but not another, can't work out what it is unhappy about!

@aheubusch
Copy link

The project is now worked on in a different repository: https://github.com/Recognos/Metrics.NET
Same issue with the cause for the exception: Recognos/Metrics.NET#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants