Beispiel #1
0
        public void RetainTransactionTraces_IfServerErrorException()
        {
            var transactionCollector  = new SlowestTransactionCollector();
            var transactionCollectors = new[] { transactionCollector };

            var scheduler = Mock.Create <IScheduler>();

            Mock.Arrange(() => scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, _, __) => _harvestAction = action);
            _transactionTraceAggregator = new TransactionTraceAggregator(_dataTransportService, scheduler, _processStatic, transactionCollectors);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());

            var sentTraces = Enumerable.Empty <TransactionTraceWireModel>();

            Mock.Arrange(() => _dataTransportService.Send(Arg.IsAny <IEnumerable <TransactionTraceWireModel> >()))
            .Returns <IEnumerable <TransactionTraceWireModel> >(traces =>
            {
                sentTraces = traces;
                return(DataTransportResponseStatus.Retain);
            });

            var trace = new TransactionTraceWireModelComponents(new TransactionMetricName(), TimeSpan.FromSeconds(5), false, () => Mock.Create <TransactionTraceWireModel>());

            _transactionTraceAggregator.Collect(trace);

            _harvestAction();
            sentTraces = Enumerable.Empty <TransactionTraceWireModel>(); //reset
            _harvestAction();

            Assert.AreEqual(1, sentTraces.Count());
        }
        public void Collect(TransactionTraceWireModelComponents transactionTraceWireModelComponents)
        {
            var isKeyTransaction = ConfigurationSubscription.Configuration.WebTransactionsApdex.TryGetValue(transactionTraceWireModelComponents.TransactionMetricName.ToString(), out double apdexT);

            if (!isKeyTransaction)
            {
                return;
            }

            var apdexTime = TimeSpan.FromSeconds(apdexT);

            if (transactionTraceWireModelComponents.Duration <= apdexTime)
            {
                return;
            }

            // larger the score, the larger the diff
            var score = 100.0 * (transactionTraceWireModelComponents.Duration.TotalMilliseconds / apdexTime.TotalMilliseconds);

            if (_slowTransaction != null && _score > score)
            {
                return;
            }

            _slowTransaction = transactionTraceWireModelComponents;
            _score           = score;
        }
Beispiel #3
0
        public void Collect(TransactionTraceWireModelComponents transactionTraceWireModelComponents)
        {
            if (!transactionTraceWireModelComponents.IsSynthetics)
            {
                return;
            }
            if (_collectedSamples.Count >= SyntheticsHeader.MaxTraceCount)
            {
                return;
            }

            _collectedSamples.Add(transactionTraceWireModelComponents);
        }
Beispiel #4
0
        public void Collect(TransactionTraceWireModelComponents transactionTraceWireModelComponents)
        {
            if (transactionTraceWireModelComponents.Duration <= ConfigurationSubscription.Configuration.TransactionTraceThreshold)
            {
                return;
            }

            if (_slowTransaction != null && _slowTransaction.Duration > transactionTraceWireModelComponents.Duration)
            {
                return;
            }

            _slowTransaction = transactionTraceWireModelComponents;
        }
Beispiel #5
0
 public void ClearCollectedSamples()
 {
     _slowTransaction = null;
 }