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) { 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(string.Format("{0}metrics", url)); 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("192.168.1.8", 9200, "metrics", TimeSpan.FromSeconds(1)) ); 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 void ActionSchedulerExecutesScheduledActionWithToken() { using (ActionScheduler scheduler = new ActionScheduler()) { int data = 0; var tcs = new TaskCompletionSource<bool>(); scheduler.Start(TimeSpan.FromMilliseconds(10), t => { data++; tcs.SetResult(true); }); tcs.Task.Wait(); scheduler.Stop(); data.Should().Be(1); } }
public void ActionSchedulerExecutesScheduledFunction() { using (ActionScheduler scheduler = new ActionScheduler()) { var tcs = new TaskCompletionSource<bool>(); int data = 0; Func<CancellationToken, Task> function = (t) => Task.Factory.StartNew(() => { data++; tcs.SetResult(true); }); scheduler.Start(TimeSpan.FromMilliseconds(10), function); tcs.Task.Wait(); scheduler.Stop(); data.Should().Be(1); } }
public void ActionSchedulerReportsExceptionWithGlobalMetricHandler() { Exception x = null; var tcs = new TaskCompletionSource<bool>(); Metric.Config.WithErrorHandler(e => { x = e; tcs.SetResult(true); }); using (ActionScheduler scheduler = new ActionScheduler()) { scheduler.Start(TimeSpan.FromMilliseconds(10), t => { throw new InvalidOperationException("boom"); }); tcs.Task.Wait(1000); scheduler.Stop(); } x.Should().NotBeNull(); }