private static async Task GetAsHumanReadable(IOwinResponse owinResponse, MetricsConfig config) { var report = new StringReporter(); report.RunReport(config.Registry, config.HealthStatus); owinResponse.ContentType = "text/plain"; await owinResponse.WriteAsync(report.Result); }
static Metric() { globalContext = new DefaultMetricsContext(GetGlobalContextName()); if (MetricsConfig.GlobalyDisabledMetrics) { globalContext.CompletelyDisableMetrics(); log.Info(() => "Metrics: Metrics.NET Library is completely disabled. Set Metrics.CompetelyDisableMetrics to false to re-enable."); } config = new MetricsConfig(globalContext); config.ApplySettingsFromConfigFile(); }
/// <summary> /// Register application level, CLR related performance counters as Gauge metrics. /// This includes: Mb in all heaps, time in GC, exceptions per sec, Threads etc. /// Note: The Performance Counters API can hang and cause other potential issues. /// If you're experiencing any issues, consider not using this configuration method. /// </summary> public static MetricsConfig WithAppCounters(this MetricsConfig config, string context = DefaultApplicationCountersContext) { config.WithConfigExtension((ctx, hs) => PerformanceCounters.RegisterAppCounters(ctx.Context(context))); return(config); }
/// <summary> /// Register all pre-defined performance counters as Gauge metrics. /// This includes System Counters, CLR Global Counters and CLR App Counters. /// Note: The Performance Counters API can hang and cause other potential issues. /// If you're experiencing any issues, consider not using this configuration method. /// </summary> public static MetricsConfig WithAllCounters(this MetricsConfig config, string systemContext = DefaultMachineCountersContext, string applicationContext = DefaultApplicationCountersContext) { return(config.WithSystemCounters(systemContext) .WithAppCounters(applicationContext)); }
private static async Task GetHealthStatus(IOwinResponse owinResponse, MetricsConfig config) { var status = config.HealthStatus(); var content = HealthCheckSerializer.Serialize(status); owinResponse.ContentType = "application/json"; owinResponse.StatusCode = (int)(status.IsHealty ? HttpStatusCode.OK : HttpStatusCode.InternalServerError); await owinResponse.WriteAsync(content); }
private static async Task GetJsonContent(IOwinResponse owinResponse, MetricsConfig config) { var content = RegistrySerializer.GetAsJson(config.Registry); owinResponse.ContentType = "text/json"; await owinResponse.WriteAsync(content); }
/// <summary> /// Register all pre-defined performance counters as Gauge metrics. /// This includes System Counters, CLR Global Counters and CLR App Counters. /// </summary> public static MetricsConfig WithAllCounters(this MetricsConfig config, string systemContext = "Machine", string applicationContext = "Application") { return(config.WithSystemCounters(systemContext) .WithCLRGlobalCounters(systemContext) .WithCLRAppCounters(applicationContext)); }
/// <summary> /// Register global, CLR related performance counters as Gauge metrics. /// This includes: total .NET Mb in all heaps and total .NET time spent in GC /// </summary> public static MetricsConfig WithCLRGlobalCounters(this MetricsConfig config, string context) { config.WithConfigExtension((ctx, hs) => PerformanceCounters.RegisterCLRGlobalCounters(ctx.Context(context))); return(config); }