コード例 #1
0
        public void DataSinceFromLastDiagnostic()
        {
            var             store         = new DiagnosticStoreImpl();
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(periodicEvent.JsonValue.Get("creationDate").AsLong,
                         UnixMillisecondTime.FromDateTime(store.DataSince).Value);
        }
コード例 #2
0
        public void CanRecordEventsInBatch()
        {
            var store = new DiagnosticStoreImpl();

            store.RecordEventsInBatch(4);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(4, periodicEvent.JsonValue.Get("eventsInLastBatch").AsInt);
        }
コード例 #3
0
        public void CanIncrementDroppedEvents()
        {
            var store = new DiagnosticStoreImpl();

            store.IncrementDroppedEvents();
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(1, periodicEvent.JsonValue.Get("droppedEvents").AsInt);
        }
コード例 #4
0
        public void PeriodicEventUsesIdFromInit()
        {
            var             store     = new DiagnosticStoreImpl();
            DiagnosticEvent?initEvent = store.InitEvent;

            Assert.True(initEvent.HasValue);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(initEvent.Value.JsonValue.Get("id"), periodicEvent.JsonValue.Get("id"));
        }
コード例 #5
0
        public void CreatingEventResetsFields()
        {
            var store = new DiagnosticStoreImpl();

            store.IncrementDroppedEvents();
            store.IncrementDeduplicatedUsers();
            store.RecordEventsInBatch(10);
            store.AddStreamInit(DateTime.Now, TimeSpan.FromMilliseconds(200.0), true);
            LdValue firstPeriodicEvent = store.CreateEventAndReset().JsonValue;
            LdValue nextPeriodicEvent  = store.CreateEventAndReset().JsonValue;

            Assert.Equal(firstPeriodicEvent.Get("creationDate"), nextPeriodicEvent.Get("dataSinceDate"));
            Assert.Equal(0, nextPeriodicEvent.Get("eventsInLastBatch").AsInt);
            Assert.Equal(0, nextPeriodicEvent.Get("droppedEvents").AsInt);
            Assert.Equal(0, nextPeriodicEvent.Get("deduplicatedUsers").AsInt);
            Assert.Equal(0, nextPeriodicEvent.Get("eventsInLastBatch").AsInt);
            LdValue streamInits = nextPeriodicEvent.Get("streamInits");

            Assert.Equal(0, streamInits.Count);
        }
コード例 #6
0
        public void PeriodicEventDefaultValuesAreCorrect()
        {
            var      store         = new DiagnosticStoreImpl();
            DateTime dataSince     = store.DataSince;
            LdValue  periodicEvent = store.CreateEventAndReset().JsonValue;

            Assert.Equal("diagnostic", periodicEvent.Get("kind").AsString);
            Assert.Equal(UnixMillisecondTime.FromDateTime(dataSince).Value, periodicEvent.Get("dataSinceDate").AsLong);
            Assert.Equal(0, periodicEvent.Get("eventsInLastBatch").AsInt);
            Assert.Equal(0, periodicEvent.Get("droppedEvents").AsInt);
            Assert.Equal(0, periodicEvent.Get("deduplicatedUsers").AsInt);

            LdValue streamInits = periodicEvent.Get("streamInits");

            Assert.Equal(0, streamInits.Count);
        }
コード例 #7
0
        public void CanAddStreamInit()
        {
            var      store     = new DiagnosticStoreImpl();
            DateTime timestamp = DateTime.Now;

            store.AddStreamInit(timestamp, TimeSpan.FromMilliseconds(200.0), true);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            LdValue streamInits = periodicEvent.JsonValue.Get("streamInits");

            Assert.Equal(1, streamInits.Count);

            LdValue streamInit = streamInits.Get(0);

            Assert.Equal(UnixMillisecondTime.FromDateTime(timestamp).Value, streamInit.Get("timestamp").AsLong);
            Assert.Equal(200, streamInit.Get("durationMillis").AsInt);
            Assert.True(streamInit.Get("failed").AsBool);
        }