예제 #1
0
 private static void DoMathHomework(TimeSpan forHowLong)
 {
     //Track work as span
     SimpleTracer.TrackWork("Do Math Homework", () =>
     {
         Thread.Sleep(forHowLong);
     });
 }
예제 #2
0
 private static void CallMyBestFriend(TimeSpan forHowLong)
 {
     //Track work as span
     SimpleTracer.TrackWork("Call My Bestie", () =>
     {
         throw new Exception("Get back to work!!!");
     });
 }
예제 #3
0
 private static void DoComputerScienceHomework(TimeSpan forHowLong)
 {
     //Track work as span
     SimpleTracer.TrackWork("Do Computer Science Homework", () =>
     {
         SimpleTracer.CurrentSpan(s => s.WithAttribute("Method", "DoComputerScienceHomework"));
         Thread.Sleep(forHowLong);
     });
 }
예제 #4
0
 /// <summary>
 /// This method will be tracked as a span.  Since this is a topmost span, when this work is complete, the SpanBatch
 /// consisting of this span and all of its children will be sentt to New Relic.
 /// </summary>
 private static void DoHomework()
 {
     //Track work as span
     SimpleTracer.TrackWork("Do Homework", () =>
     {
         DoMathHomework(TimeSpan.FromSeconds(2));
         TakeABreak(TimeSpan.FromSeconds(1));
         DoScienceHomework();
     });
 }
예제 #5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Telemetry SDK sample Application.");
            Console.WriteLine(new String('-', 100));

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            SimpleTracer.WithConfiguration(config);
            SimpleTracer.EnableTracing();

            DoHomework();

            SimpleTracer.DisableTracing();
        }
예제 #6
0
        private static void DoScienceHomework()
        {
            //Track work as span
            SimpleTracer.TrackWork("Do Science Homework", () =>
            {
                DoComputerScienceHomework(TimeSpan.FromSeconds(1));
                TakeABreak(TimeSpan.FromSeconds(2));

                try
                {
                    CallMyBestFriend(TimeSpan.FromSeconds(20));
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine($"Captured Expected Exception - {ex.Message}");
                }

                DoBiologyHomework(TimeSpan.FromSeconds(1));
            });
        }
예제 #7
0
 /// <summary>
 /// This method introduces a delay that is not tracked by a span.
 /// Its time would be accounted for in the caller's span.
 /// </summary>
 /// <param name="forHowLong"></param>
 private static void TakeABreak(TimeSpan forHowLong)
 {
     SimpleTracer.CurrentSpan((s) => { s.WithAttribute("Length of Break", forHowLong.TotalSeconds); });
     Thread.Sleep(forHowLong);
 }