public DiagnosticEvent CreateEventAndReset()
        {
            DateTime currentTime       = DateTime.Now;
            long     droppedEvents     = Interlocked.Exchange(ref DroppedEvents, 0);
            long     deduplicatedUsers = Interlocked.Exchange(ref DeduplicatedUsers, 0);
            long     eventsInLastBatch = Interlocked.Exchange(ref EventsInLastBatch, 0);
            long     dataSince         = Interlocked.Exchange(ref DataSince, currentTime.ToBinary());

            var statEvent = LdValue.BuildObject();

            AddDiagnosticCommonFields(statEvent, "diagnostic", currentTime);
            statEvent.Add("eventsInLastBatch", eventsInLastBatch);
            statEvent.Add("dataSinceDate", Util.GetUnixTimestampMillis(DateTime.FromBinary(dataSince)));
            statEvent.Add("droppedEvents", droppedEvents);
            statEvent.Add("deduplicatedUsers", deduplicatedUsers);
            lock (StreamInitsLock) {
                statEvent.Add("streamInits", StreamInits.Build());
                StreamInits = LdValue.BuildArray();
            }

            return(new DiagnosticEvent(statEvent.Build()));
        }