コード例 #1
0
ファイル: Program.cs プロジェクト: tomaustin700/BosunExample
        public static async Task Time(Func <Task> action, EventGauge gauge)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            await action.Invoke();

            stopwatch.Stop();
            gauge.Record(stopwatch.Elapsed.TotalMilliseconds, DateTime.Now);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tomaustin700/BosunExample
        static void Main(string[] args)
        {
            _collector = new MetricsCollector(new BosunOptions(ex => Handle(ex))
            {
                MetricsNamePrefix = "TestApp.",
                BosunUrl          = new System.Uri("http://192.168.1.5:8070"),
                PropertyToTagName = NameTransformers.CamelToLowerSnakeCase,
                ThrowOnPostFail   = true,
                DefaultTags       = new Dictionary <string, string> {
                    { "host", NameTransformers.Sanitize(Environment.MachineName.ToLower()) },
                    { "client", "home" },
                }
            });

            _timer = _collector.CreateMetric <EventGauge>("GetWeather", "time taken", "measures time taken to get weather from api");

            var dispatcherTimer = new Timer();

            dispatcherTimer.Interval = 5000;
            dispatcherTimer.Start();
            dispatcherTimer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

            Console.ReadLine();
        }
コード例 #3
0
 protected override void UpdateMetric(EventGauge metric) => metric.Record(42.123d);