private void Retain(IEnumerable <ErrorTraceWireModel> errorTraceWireModels)
        {
            errorTraceWireModels = errorTraceWireModels.ToList();
            _agentHealthReporter.ReportErrorTracesRecollected(errorTraceWireModels.Count());

            // It is possible, but unlikely, to lose incoming error traces here due to a race condition
            var savedErrorTraceWireModels = GetAndResetCollection();

            // It is possible that newer, incoming error traces will be added to our collection before we add the retained and saved ones.
            foreach (var model in errorTraceWireModels)
            {
                if (model != null)
                {
                    AddToCollection(model);
                }
            }

            foreach (var model in savedErrorTraceWireModels)
            {
                if (model != null)
                {
                    AddToCollection(model);
                }
            }
        }
Example #2
0
        public void error_trace_recollected_is_reported_to_agent_health()
        {
            // Arrange
            Mock.Arrange(() => _dataTransportService.Send(Arg.IsAny <IEnumerable <ErrorTraceWireModel> >()))
            .Returns <IEnumerable <ErrorTraceWireModel> >(errors =>
            {
                return(DataTransportResponseStatus.Retain);
            });
            _errorTraceAggregator.Collect(Mock.Create <ErrorTraceWireModel>());
            _harvestAction();

            // Act
            _harvestAction();

            // Assert
            Mock.Assert(() => _agentHealthReporter.ReportErrorTracesRecollected(1));
        }