static void Main(string[] args) { const string url = "http://localhost:1235/"; using (var scheduler = new ActionScheduler()) { using (WebApp.Start <Startup>(url)) { Console.WriteLine("Owin Running at {0}", url); Console.WriteLine("Press any key to exit"); Process.Start($"{url}metrics/"); SampleMetrics.RunSomeRequests(); scheduler.Start(TimeSpan.FromMilliseconds(500), () => { SetCounterSample.RunSomeRequests(); SetMeterSample.RunSomeRequests(); UserValueHistogramSample.RunSomeRequests(); UserValueTimerSample.RunSomeRequests(); SampleMetrics.RunSomeRequests(); }); HealthChecksSample.RegisterHealthChecks(); Console.ReadKey(); } } }
static void Main(string[] args) { JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Formatting.Indented }; using (ActionScheduler scheduler = new ActionScheduler()) using (var host = new NancyHost(new Uri("http://localhost:8090"))) { host.Start(); Console.WriteLine("Nancy Running at http://localhost:8090"); Console.WriteLine("Press any key to exit"); Process.Start("http://localhost:8090/metrics/"); SampleMetrics.RunSomeRequests(); scheduler.Start(TimeSpan.FromMilliseconds(500), () => { SetCounterSample.RunSomeRequests(); SetMeterSample.RunSomeRequests(); UserValueHistogramSample.RunSomeRequests(); UserValueTimerSample.RunSomeRequests(); SampleMetrics.RunSomeRequests(); }); HealthChecksSample.RegisterHealthChecks(); Console.ReadKey(); } }
static void Main(string[] args) { //Metric.CompletelyDisableMetrics(); Metric.Config .WithHttpEndpoint("http://*****:*****@"c:\temp\reports\", TimeSpan.FromSeconds(10)) //.WithTextFileReport(@"C:\temp\reports\metrics.txt", TimeSpan.FromSeconds(10)) //.WithGraphite(new Uri("net.udp://localhost:2003"), TimeSpan.FromSeconds(1)) //.WithInfluxDb("192.168.1.8", 8086, "admin", "admin", "metrics", TimeSpan.FromSeconds(1)) .WithElasticSearch(new ElasticSearch.ElasticReportsConfig() { Host = "192.168.1.8", Port = 9200, Index = "metrics", RollingIndexType = ElasticSearch.RollingIndexType.Daily, ReportingApplication = ApplicationInfo.Default }, TimeSpan.FromSeconds(5)) ); using (var scheduler = new ActionScheduler()) { SampleMetrics.RunSomeRequests(); scheduler.Start(TimeSpan.FromMilliseconds(500), () => { SetCounterSample.RunSomeRequests(); SetMeterSample.RunSomeRequests(); UserValueHistogramSample.RunSomeRequests(); UserValueTimerSample.RunSomeRequests(); SampleMetrics.RunSomeRequests(); }); Metric.Gauge("Errors", () => 1, Unit.None); Metric.Gauge("% Percent/Gauge|test", () => 1, Unit.None); Metric.Gauge("& AmpGauge", () => 1, Unit.None); Metric.Gauge("()[]{} ParantesisGauge", () => 1, Unit.None); Metric.Gauge("Gauge With No Value", () => double.NaN, Unit.None); //Metric.Gauge("Gauge Resulting in division by zero", () => 5 / 0.0, Unit.None); ////Metrics.Samples.FSharp.SampleMetrics.RunSomeRequests(); HealthChecksSample.RegisterHealthChecks(); //Metrics.Samples.FSharp.HealthChecksSample.RegisterHealthChecks(); Console.WriteLine("done setting things up"); Console.ReadKey(); } }
static void Main(string[] args) { //Metric.CompletelyDisableMetrics(); Metric.Config .WithHttpEndpoint("http://localhost:1234/metrics/", config => config .WithEndpointReport("/test", (d, h, c) => new MetricsEndpointResponse("test", "text/plain"))) .WithAllCounters() .WithInternalMetrics() .WithReporting(config => config .WithConsoleReport(TimeSpan.FromSeconds(30))); using (var scheduler = new ActionScheduler()) { SampleMetrics.RunSomeRequests(); scheduler.Start(TimeSpan.FromMilliseconds(500), () => { SetCounterSample.RunSomeRequests(); SetMeterSample.RunSomeRequests(); UserValueHistogramSample.RunSomeRequests(); UserValueTimerSample.RunSomeRequests(); SampleMetrics.RunSomeRequests(); }); Metric.Gauge("Errors", () => 1, Unit.None); Metric.Gauge("% Percent/Gauge|test", () => 1, Unit.None); Metric.Gauge("& AmpGauge", () => 1, Unit.None); Metric.Gauge("()[]{} ParantesisGauge", () => 1, Unit.None); Metric.Gauge("Gauge With No Value", () => double.NaN, Unit.None); //Metric.Gauge("Gauge Resulting in division by zero", () => 5 / 0.0, Unit.None); ////Metrics.Samples.FSharp.SampleMetrics.RunSomeRequests(); HealthChecksSample.RegisterHealthChecks(); //Metrics.Samples.FSharp.HealthChecksSample.RegisterHealthChecks(); Console.WriteLine("done setting things up"); Console.ReadKey(); } }
public static void Main() { var cpuUsage = new CpuUsage(); cpuUsage.Start(); IServiceCollection serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); ConfigureMetrics(serviceCollection); var process = Process.GetCurrentProcess(); var provider = serviceCollection.BuildServiceProvider(); var application = new Application(provider); var scheduler = new DefaultTaskScheduler(); var simpleMetrics = new SampleMetrics(application.Metrics); var setCounterSample = new SetCounterSample(application.Metrics); var setMeterSample = new SetMeterSample(application.Metrics); var userValueHistogramSample = new UserValueHistogramSample(application.Metrics); var userValueTimerSample = new UserValueTimerSample(application.Metrics); //var rnd = new Random(); //foreach (var index in Enumerable.Range(0, 30)) //{ // using (application.Metrics.Track(AppMetricsRegistry.ApdexScores.AppApdex)) // { // if (index % 4 == 0) // { // Thread.Sleep(rnd.Next(2100, 2200)); // } // else if (index % 2 == 0) // { // Thread.Sleep(rnd.Next(600, 700)); // } // else // { // Thread.Sleep(rnd.Next(0, 300)); // } // } //} var cancellationTokenSource = new CancellationTokenSource(); var task = scheduler.Interval( TimeSpan.FromMilliseconds(300), () => { using (application.Metrics.Track(AppMetricsRegistry.ApdexScores.AppApdex)) { setCounterSample.RunSomeRequests(); setMeterSample.RunSomeRequests(); userValueHistogramSample.RunSomeRequests(); //userValueTimerSample.RunSomeRequests(); //TODO: AH - why's this taking so long? simpleMetrics.RunSomeRequests(); } application.Metrics.Gauge(AppMetricsRegistry.Gauges.Errors, () => 1); application.Metrics.Gauge(AppMetricsRegistry.Gauges.PercentGauge, () => 1); application.Metrics.Gauge(AppMetricsRegistry.Gauges.ApmGauge, () => 1); application.Metrics.Gauge(AppMetricsRegistry.Gauges.ParenthesisGauge, () => 1); application.Metrics.Gauge(AppMetricsRegistry.Gauges.GaugeWithNoValue, () => double.NaN); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.CpuUsageTotal, () => { cpuUsage.CallCpu(); return(cpuUsage.CpuUsageTotal); }); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessPagedMemorySizeGauge, () => process.PagedMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessPeekPagedMemorySizeGauge, () => process.PeakPagedMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessPeekVirtualMemorySizeGauge, () => process.PeakVirtualMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessPeekWorkingSetSizeGauge, () => process.WorkingSet64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessPrivateMemorySizeGauge, () => process.PrivateMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.ProcessVirtualMemorySizeGauge, () => process.VirtualMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.SystemNonPagedMemoryGauge, () => process.NonpagedSystemMemorySize64); application.Metrics.Gauge(AppMetricsRegistry.ProcessMetrics.SystemPagedMemorySizeGauge, () => process.PagedSystemMemorySize64); }, cancellationTokenSource.Token); application.Reporter.RunReportsAsync(application.Metrics, cancellationTokenSource.Token); Console.WriteLine("Setup Complete, waiting for report run..."); Console.ReadKey(); }
public static void Main() { var cpuUsage = new CpuUsage(); cpuUsage.Start(); IServiceCollection serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); ConfigureMetrics(serviceCollection); var process = Process.GetCurrentProcess(); var provider = serviceCollection.BuildServiceProvider(); var application = new Application(provider); var scheduler = new DefaultTaskScheduler(); var simpleMetrics = new SampleMetrics(application.Metrics); var setCounterSample = new SetCounterSample(application.Metrics); var setMeterSample = new SetMeterSample(application.Metrics); var userValueHistogramSample = new UserValueHistogramSample(application.Metrics); var userValueTimerSample = new UserValueTimerSample(application.Metrics); var cancellationTokenSource = new CancellationTokenSource(); //cancellationTokenSource.CancelAfter(TimeSpan.FromSeconds(10)); var task = scheduler.Interval( TimeSpan.FromMilliseconds(300), TaskCreationOptions.LongRunning, () => { using (application.Metrics.Measure.Apdex.Track(AppMetricsRegistry.ApdexScores.AppApdex)) { setCounterSample.RunSomeRequests(); setMeterSample.RunSomeRequests(); userValueHistogramSample.RunSomeRequests(); userValueTimerSample.RunSomeRequests(); simpleMetrics.RunSomeRequests(); } application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.Gauges.Errors, () => 1); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.Gauges.PercentGauge, () => 1); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.Gauges.ApmGauge, () => 1); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.Gauges.ParenthesisGauge, () => 1); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.Gauges.GaugeWithNoValue, () => double.NaN); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.CpuUsageTotal, () => { cpuUsage.CallCpu(); return(cpuUsage.CpuUsageTotal); }); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessPagedMemorySizeGauge, () => process.PagedMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessPeekPagedMemorySizeGauge, () => process.PeakPagedMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessPeekVirtualMemorySizeGauge, () => process.PeakVirtualMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessPeekWorkingSetSizeGauge, () => process.WorkingSet64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessPrivateMemorySizeGauge, () => process.PrivateMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.ProcessVirtualMemorySizeGauge, () => process.VirtualMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.SystemNonPagedMemoryGauge, () => process.NonpagedSystemMemorySize64); application.Metrics.Measure.Gauge.SetValue(AppMetricsRegistry.ProcessMetrics.SystemPagedMemorySizeGauge, () => process.PagedSystemMemorySize64); }, cancellationTokenSource.Token); application.Reporter.RunReports(application.Metrics, cancellationTokenSource.Token); Console.WriteLine("Report Cancelled..."); Console.ReadKey(); }