private void RecordStats() { try { var stats = new Stats { AuthRejections = _telemetryStorageConsumer.PopAuthRejections(), EventsDropped = _telemetryStorageConsumer.GetEventsStats(EventsEnum.EventsDropped), EventsQueued = _telemetryStorageConsumer.GetEventsStats(EventsEnum.EventsQueued), HTTPErrors = _telemetryStorageConsumer.PopHttpErrors(), HTTPLatencies = _telemetryStorageConsumer.PopHttpLatencies(), ImpressionsDeduped = _telemetryStorageConsumer.GetImpressionsStats(ImpressionsEnum.ImpressionsDeduped), ImpressionsDropped = _telemetryStorageConsumer.GetImpressionsStats(ImpressionsEnum.ImpressionsDropped), ImpressionsQueued = _telemetryStorageConsumer.GetImpressionsStats(ImpressionsEnum.ImpressionsQueued), LastSynchronizations = _telemetryStorageConsumer.GetLastSynchronizations(), MethodExceptions = _telemetryStorageConsumer.PopExceptions(), MethodLatencies = _telemetryStorageConsumer.PopLatencies(), SessionLengthMs = _telemetryStorageConsumer.GetSessionLength(), StreamingEvents = _telemetryStorageConsumer.PopStreamingEvents().ToList(), Tags = _telemetryStorageConsumer.PopTags().ToList(), TokenRefreshes = _telemetryStorageConsumer.PopTokenRefreshes(), SplitCount = _splitCache.SplitsCount(), SegmentCount = _segmentCache.SegmentsCount(), SegmentKeyCount = _segmentCache.SegmentKeysCount() }; _telemetryAPI.RecordStats(stats); } catch (Exception ex) { _log.Error("Something were wrong posting Stats.", ex); } }
public void RecordStats() { // Arrange. var stats = new Stats { AuthRejections = 2, HTTPLatencies = new HTTPLatencies { Events = new List <long> { 55, 66, 77 }, Segments = new List <long> { 88, 22, 99 }, }, HTTPErrors = new HTTPErrors { Splits = new Dictionary <int, long> { { 500, 5 }, { 400, 5 } }, Events = new Dictionary <int, long> { { 500, 2 }, { 400, 2 } } } }; var data = "{\"hE\":{\"sp\":{\"500\":5,\"400\":5},\"ev\":{\"500\":2,\"400\":2}},\"hL\":{\"se\":[88,22,99],\"ev\":[55,66,77]},\"tR\":0,\"aR\":2,\"iQ\":0,\"iDe\":0,\"iDr\":0,\"spC\":0,\"seC\":0,\"skC\":0,\"sL\":0,\"eQ\":0,\"eD\":0}"; _splitioHttpClient .Setup(mock => mock.PostAsync("www.fake-url.com/metrics/usage", data)) .ReturnsAsync(new HTTPResult { statusCode = System.Net.HttpStatusCode.OK }); // Act. _telemetryAPI.RecordStats(stats); // Assert. _splitioHttpClient.Verify(mock => mock.PostAsync("www.fake-url.com/metrics/usage", data), Times.Once); _log.Verify(mock => mock.Error(It.IsAny <string>()), Times.Never); }