public void DataSinceFromLastDiagnostic() { var store = new DiagnosticStoreImpl(); DiagnosticEvent periodicEvent = store.CreateEventAndReset(); Assert.Equal(periodicEvent.JsonValue.Get("creationDate").AsLong, UnixMillisecondTime.FromDateTime(store.DataSince).Value); }
public void CanRecordEventsInBatch() { var store = new DiagnosticStoreImpl(); store.RecordEventsInBatch(4); DiagnosticEvent periodicEvent = store.CreateEventAndReset(); Assert.Equal(4, periodicEvent.JsonValue.Get("eventsInLastBatch").AsInt); }
public void CanIncrementDroppedEvents() { var store = new DiagnosticStoreImpl(); store.IncrementDroppedEvents(); DiagnosticEvent periodicEvent = store.CreateEventAndReset(); Assert.Equal(1, periodicEvent.JsonValue.Get("droppedEvents").AsInt); }
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")); }
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); }
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); }
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); }