public void CreateAndLoad()
        {
            RegistryStore prp = new RegistryStore("test2");

            var x = new XEPosition { LastFile = "MyLastFile", Offset = 2000 };

            prp.Update(x);

            var x2 = prp.Read();

            Assert.AreEqual(x, x2);
        }
        public void TestEventConsumer()
        {
            DatabaseContext context = new DatabaseContext(Parameters.CONNECTION_STRING);

            IStore store = new RegistryStore(Parameters.XESESSION_NAME);

            EventConsumer ec = new EventConsumer(context, Parameters.XE_PATH, store);

            var events = ec.GetLastEvents();

            string s = EventHubWriter.Serialize(events[0].Dictionary);
        }
Exemple #3
0
        public static void sp_send_xe_to_eventhub(string trace_name, string event_hub_name, string service_bus_namespace, string policy, string policy_key)
        {
            CheckNullParameter(trace_name, "@trace_name");
            CheckNullParameter(event_hub_name, "@event_hub_name");
            CheckNullParameter(service_bus_namespace, "@service_bus_namespace");
            CheckNullParameter(policy, "@policy");
            CheckNullParameter(policy_key, "@policy_key");

            List<XEPayload> payloads = null;

            SqlContext.Pipe.Send("Opening context connection...");

            if (SqlContext.IsAvailable)
            {
                using (DatabaseContext context = new DatabaseContext("context connection = true"))
                {
                    using (context)
                    {
                        if (DBHelper.XESessionExist(context, trace_name))
                        {
                            SqlContext.Pipe.Send("Reading XE session info...");
                            XESession session = DBHelper.GetSession(context, trace_name);

                            SqlContext.Pipe.Send("Reading last position...");
                            RegistryStore rs = new RegistryStore(trace_name);

                            SqlContext.Pipe.Send(string.Format("last position is {0:S}", rs.ToString()));
                            EventConsumer c = new EventConsumer(context, session.FilePath, rs);

                            SqlContext.Pipe.Send("reading events...");
                            payloads = c.GetLastEvents();
                            SqlContext.Pipe.Send(string.Format("{0:N0} events read", payloads.Count));
                        }
                        else
                            throw new Exception(String.Format("Session {0:S} does not exists or is not running.", trace_name));
                    }
                }
            }

            if (payloads != null)
            {
                EventHubWriter writer = new EventHubWriter(event_hub_name, service_bus_namespace, policy, policy_key);
                foreach (XEPayload p in payloads)
                {
                    SqlContext.Pipe.Send("Sending one event to EH");
                    writer.Send(p);
                }
            }
        }
 public void Create()
 {
     RegistryStore prp = new RegistryStore("test");
     prp.Update(new XEPosition { LastFile = "LastFile", Offset = 2000 });
 }