Flush() public method

Flushes all queued metrics.
public Flush ( ) : void
return void
Example #1
0
        static void Main(string[] args)
        {
            var httpService = new SimpleHttpService();
            var postUrl = "http://localhost:3000/emit";

            // Create the metrics with batching.
            var metrics = new Metrics(new HttpJsonPostEmitter(postUrl, httpService), 5);

            // Create some dummy metrics data
            metrics.SetProperty("Metrics entry", "test");
            for (var i = 0; i < 10; i++)
            {
                metrics.Entry("Test int entry", i);
            }
            metrics.SetProperty("Second property", "true");
            metrics.Event("An event occurred");
            metrics.Entry("Test string entry", "foo");

            // Flush the metrics before in case there are still queued metrics.
            metrics.Flush();

            Console.WriteLine("Sent metrics data to " + postUrl);
        }