public void Reset() { devices.Clear(); TotalMessages = 0; DeviceToIoTHubDelay.Reset(); E2EDelay.Reset(); SampleEventSender = string.Empty; SampleEvent = string.Empty; }
public void Push(EventData eventData) { var receiveTimeUtc = DateTime.UtcNow; TotalMessages++; var deviceId = eventData.SystemProperties["iothub-connection-device-id"].ToString(); if (!devices.Contains(deviceId)) { lock (devices) { devices.Add(deviceId); } } var bytes = eventData.GetBytes(); var content = Encoding.UTF8.GetString(bytes); SampleEventSender = deviceId; SampleEvent = content; var root = JsonConvert.DeserializeObject(content) as JToken; if (root != null) { var sendTimeUtc = root.Value <DateTime>("DeviceUtcDatetime"); if (sendTimeUtc > DateTime.MinValue) { var enqueueTimeUtc = eventData.EnqueuedTimeUtc; var deviceToIoTHubDelay = (enqueueTimeUtc - sendTimeUtc).TotalMilliseconds; var e2eDelay = (receiveTimeUtc - sendTimeUtc).TotalMilliseconds; DeviceToIoTHubDelay.Push(receiveTimeUtc, deviceToIoTHubDelay); E2EDelay.Push(receiveTimeUtc, e2eDelay); } } }