private void SendAndResetDiagnostics(EventBuffer buffer) { if (_diagnosticStore != null) { Task.Run(() => SendDiagnosticEventAsync(_diagnosticStore.CreateEventAndReset())); } }
public void DataSinceFromLastDiagnostic() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(periodicEvent.JsonValue.Get("creationDate").AsLong, Util.GetUnixTimestampMillis(_serverDiagnosticStore.DataSince)); }
public void DataSinceFromLastDiagnostic() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(null); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(periodicEvent.JsonValue.Get("creationDate").AsLong, UnixMillisecondTime.FromDateTime(_serverDiagnosticStore.DataSince).Value); }
public void CanRecordEventsInBatch() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); _serverDiagnosticStore.RecordEventsInBatch(4); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(4, periodicEvent.JsonValue.Get("eventsInLastBatch").AsInt); }
public void CanIncrementDroppedEvents() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); _serverDiagnosticStore.IncrementDroppedEvents(); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(1, periodicEvent.JsonValue.Get("droppedEvents").AsInt); }
public void CanIncrementDeduplicateUsers() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(null); _serverDiagnosticStore.IncrementDeduplicatedUsers(); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(1, periodicEvent.JsonValue.Get("deduplicatedUsers").AsInt); }
public void PeriodicEventUsesIdFromInit() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); DiagnosticEvent? initEvent = _serverDiagnosticStore.InitEvent; Assert.True(initEvent.HasValue); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); Assert.Equal(initEvent.Value.JsonValue.Get("id"), periodicEvent.JsonValue.Get("id")); }
public void CreatingEventResetsFields() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); _serverDiagnosticStore.IncrementDroppedEvents(); _serverDiagnosticStore.IncrementDeduplicatedUsers(); _serverDiagnosticStore.RecordEventsInBatch(10); _serverDiagnosticStore.AddStreamInit(DateTime.Now, TimeSpan.FromMilliseconds(200.0), true); LdValue firstPeriodicEvent = _serverDiagnosticStore.CreateEventAndReset().JsonValue; LdValue nextPeriodicEvent = _serverDiagnosticStore.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() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); DateTime dataSince = _serverDiagnosticStore.DataSince; LdValue periodicEvent = _serverDiagnosticStore.CreateEventAndReset().JsonValue; Assert.Equal("diagnostic", periodicEvent.Get("kind").AsString); Assert.Equal(Util.GetUnixTimestampMillis(dataSince), 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() { IDiagnosticStore _serverDiagnosticStore = CreateDiagnosticStore(); DateTime timestamp = DateTime.Now; _serverDiagnosticStore.AddStreamInit(timestamp, TimeSpan.FromMilliseconds(200.0), true); DiagnosticEvent periodicEvent = _serverDiagnosticStore.CreateEventAndReset(); LdValue streamInits = periodicEvent.JsonValue.Get("streamInits"); Assert.Equal(1, streamInits.Count); LdValue streamInit = streamInits.Get(0); Assert.Equal(Util.GetUnixTimestampMillis(timestamp), streamInit.Get("timestamp").AsLong); Assert.Equal(200, streamInit.Get("durationMillis").AsInt); Assert.Equal(true, streamInit.Get("failed").AsBool); }