Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: SessionStatistics <real-time session name> <seconds>");
                return;
            }

            string sessionName = args[0];
            int    seconds     = int.Parse(args[1]);

            Console.WriteLine("Measuring provider verbosity for session '{0}' for {1} seconds", sessionName, seconds);
            IObservable <EtwNativeEvent> session = EtwObservable.FromSession(sessionName);

            var timeSource = new TimeSource <EtwNativeEvent>(session, e => e.TimeStamp);

            var countPerWindow = from e in timeSource.Take(TimeSpan.FromSeconds(seconds), timeSource.Scheduler)
                                 group e by new { e.ProviderId } into g
            from total in g.Count()
            select new { Provider = g.Key, Count = total };

            ManualResetEvent evt = new ManualResetEvent(false);

            IDisposable output = countPerWindow.Subscribe(
                stat => Console.WriteLine("{0} {1}", stat.Provider, stat.Count), // OnNext
                e => Console.WriteLine(e.Message),                               // OnError
                () => { evt.Set(); });                                           // OnCompleted

            IDisposable input = timeSource.Connect();

            evt.WaitOne();

            output.Dispose();
            input.Dispose();
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: SessionStatistics <real-time session name> <seconds>");
                return;
            }

            string sessionName = args[0];
            int seconds = int.Parse(args[1]);

            Console.WriteLine("Measuring provider verbosity for session '{0}' for {1} seconds", sessionName, seconds);
            IObservable<EtwNativeEvent> session = EtwObservable.FromSession(sessionName);

            var timeSource = new TimeSource<EtwNativeEvent>(session, e => e.TimeStamp);

            var countPerWindow = from e in timeSource.Take(TimeSpan.FromSeconds(seconds), timeSource.Scheduler)
                                 group e by new {e.ProviderId} into g
                                 from total in g.Count()
                                 select new {Provider = g.Key, Count = total};

            ManualResetEvent evt = new ManualResetEvent(false);

            IDisposable output = countPerWindow.Subscribe(
                stat => Console.WriteLine("{0} {1}", stat.Provider, stat.Count), // OnNext
                e => Console.WriteLine(e.Message),                               // OnError
                () =>{ evt.Set();});                                             // OnCompleted

            IDisposable input  = timeSource.Connect();
            evt.WaitOne();

            output.Dispose();
            input.Dispose();
        }
Пример #3
0
        static void Option1_TimeSource()
        {
            IObservable<PublishedEvent> obs = XeObservable.FromFiles(@"..\..\gatewaysample*.xel");
            TimeSource<PublishedEvent> timeSource = new TimeSource<PublishedEvent>(obs, e => e.Timestamp);

            timeSource
                .Take(TimeSpan.FromMinutes(1), timeSource.Scheduler)
                .Where(e=>(double)e.Fields["LoginDurationMs"].Value > 100)
                .Subscribe(e =>
                {
                    Console.WriteLine("--- {0} {1}.{2} ---", e.Name, e.Timestamp, e.Timestamp.Millisecond);
                    foreach (PublishedEventField f in e.Fields)
                    {
                        Console.WriteLine("{0} = {1}", f.Name, f.Value);
                    }
                });

            timeSource.Connect();

            Console.ReadLine();
        }
Пример #4
0
        static void Option1_TimeSource()
        {
            IObservable <PublishedEvent> obs        = XeObservable.FromFiles(@"gatewaysample.xel");
            TimeSource <PublishedEvent>  timeSource = new TimeSource <PublishedEvent>(obs, e => e.Timestamp);

            timeSource
            .Take(TimeSpan.FromMinutes(1), timeSource.Scheduler)
            .Where(e => (double)e.Fields["LoginDurationMs"].Value > 100)
            .Subscribe(e =>
            {
                Console.WriteLine("--- {0} {1}.{2} ---", e.Name, e.Timestamp, e.Timestamp.Millisecond);
                foreach (PublishedEventField f in e.Fields)
                {
                    Console.WriteLine("{0} = {1}", f.Name, f.Value);
                }
            });

            using (timeSource.Connect())
            {
                Console.ReadLine();
            }
        }