public TransactionTransformer(ITransactionMetricNameMaker transactionMetricNameMaker, ISegmentTreeMaker segmentTreeMaker, IMetricNameService metricNameService, IMetricAggregator metricAggregator, IConfigurationService configurationService, ITransactionTraceAggregator transactionTraceAggregator, ITransactionTraceMaker transactionTraceMaker, ITransactionEventAggregator transactionEventAggregator, ITransactionEventMaker transactionEventMaker, ITransactionAttributeMaker transactionAttributeMaker, IErrorTraceAggregator errorTraceAggregator, IErrorTraceMaker errorTraceMaker, IErrorEventAggregator errorEventAggregator, IErrorEventMaker errorEventMaker, ISqlTraceAggregator sqlTraceAggregator, ISqlTraceMaker sqlTraceMaker, ISpanEventAggregator spanEventAggregator, ISpanEventMaker spanEventMaker, IAgentTimerService agentTimerService,
                               IAdaptiveSampler adaptiveSampler, IErrorService errorService, ISpanEventAggregatorInfiniteTracing spanEventAggregatorInfiniteTracing)
 {
     _transactionMetricNameMaker = transactionMetricNameMaker;
     _segmentTreeMaker           = segmentTreeMaker;
     _metricNameService          = metricNameService;
     _metricAggregator           = metricAggregator;
     _configurationService       = configurationService;
     _transactionTraceAggregator = transactionTraceAggregator;
     _transactionTraceMaker      = transactionTraceMaker;
     _transactionEventAggregator = transactionEventAggregator;
     _transactionEventMaker      = transactionEventMaker;
     _transactionAttributeMaker  = transactionAttributeMaker;
     _errorTraceAggregator       = errorTraceAggregator;
     _errorTraceMaker            = errorTraceMaker;
     _errorEventAggregator       = errorEventAggregator;
     _errorEventMaker            = errorEventMaker;
     _sqlTraceAggregator         = sqlTraceAggregator;
     _sqlTraceMaker       = sqlTraceMaker;
     _spanEventAggregator = spanEventAggregator;
     _spanEventAggregatorInfiniteTracing = spanEventAggregatorInfiniteTracing;
     _spanEventMaker    = spanEventMaker;
     _agentTimerService = agentTimerService;
     _adaptiveSampler   = adaptiveSampler;
     _errorService      = errorService;
 }
        public void SetUp()
        {
            _localConfig = new configuration();
            _localConfig.distributedTracing.enabled = true;
            _serverConfig  = new ServerConfiguration();
            _runTimeConfig = new RunTimeConfiguration();
            _defaultConfig = new TestableDefaultConfiguration(Mock.Create <IEnvironment>(), _localConfig, _serverConfig, _runTimeConfig,
                                                              new SecurityPoliciesConfiguration(), Mock.Create <IProcessStatic>(), Mock.Create <IHttpRuntimeStatic>(), Mock.Create <IConfigurationManagerStatic>(),
                                                              Mock.Create <IDnsStatic>());

            _transactionMetricNameMaker = Mock.Create <ITransactionMetricNameMaker>();
            Mock.Arrange(() => _transactionMetricNameMaker.GetTransactionMetricName(Arg.Matches <ITransactionName>(txName => txName.IsWeb)))
            .Returns(new TransactionMetricName("WebTransaction", "TransactionName"));
            Mock.Arrange(() => _transactionMetricNameMaker.GetTransactionMetricName(Arg.Matches <ITransactionName>(txName => !txName.IsWeb))).Returns(new TransactionMetricName("OtherTransaction", "TransactionName"));

            _transactionSegmentState = Mock.Create <ITransactionSegmentState>();
            Mock.Arrange(() => _transactionSegmentState.GetRelativeTime()).Returns(() => TimeSpan.Zero);
            Mock.Arrange(() => _transactionSegmentState.AttribDefs).Returns(() => new AttributeDefinitions(new AttributeFilter(new AttributeFilter.Settings())));

            _segmentTreeMaker = Mock.Create <ISegmentTreeMaker>();

            _metricNameService = Mock.Create <IMetricNameService>();

            _metricBuilder    = Mock.Create <IMetricBuilder>();
            _metricAggregator = Mock.Create <IMetricAggregator>();

            _configurationService = Mock.Create <IConfigurationService>();
            Mock.Arrange(() => _configurationService.Configuration).Returns(_defaultConfig);

            _transactionTraceAggregator = Mock.Create <ITransactionTraceAggregator>();
            _transactionTraceMaker      = Mock.Create <ITransactionTraceMaker>();
            _transactionEventAggregator = Mock.Create <ITransactionEventAggregator>();
            _transactionEventMaker      = Mock.Create <ITransactionEventMaker>();
            _transactionAttributeMaker  = Mock.Create <ITransactionAttributeMaker>();
            _errorTraceAggregator       = Mock.Create <IErrorTraceAggregator>();
            _errorTraceMaker            = Mock.Create <IErrorTraceMaker>();
            _errorEventAggregator       = Mock.Create <IErrorEventAggregator>();
            _errorEventMaker            = Mock.Create <IErrorEventMaker>();
            _sqlTraceAggregator         = Mock.Create <ISqlTraceAggregator>();
            _sqlTraceMaker = Mock.Create <ISqlTraceMaker>();

            _spanEventAggregator = Mock.Create <ISpanEventAggregator>();
            Mock.Arrange(() => _spanEventAggregator.IsServiceEnabled).Returns(() => _defaultConfig != null && _defaultConfig.SpanEventsEnabled && _defaultConfig.SpanEventsMaxSamplesStored > 0 && _defaultConfig.DistributedTracingEnabled);
            Mock.Arrange(() => _spanEventAggregator.IsServiceAvailable).Returns(() => _defaultConfig != null && _defaultConfig.SpanEventsEnabled && _defaultConfig.SpanEventsMaxSamplesStored > 0 && _defaultConfig.DistributedTracingEnabled);

            _spanEventAggregatorInfiniteTracing = Mock.Create <ISpanEventAggregatorInfiniteTracing>();
            Mock.Arrange(() => _spanEventAggregatorInfiniteTracing.IsServiceEnabled).Returns(() => !string.IsNullOrWhiteSpace(_defaultConfig?.InfiniteTracingTraceObserverHost));
            Mock.Arrange(() => _spanEventAggregatorInfiniteTracing.IsServiceAvailable).Returns(() => !string.IsNullOrWhiteSpace(_defaultConfig?.InfiniteTracingTraceObserverHost));

            _spanEventMaker        = Mock.Create <ISpanEventMaker>();
            _customEventAggregator = Mock.Create <ICustomEventAggregator>();
            _errorService          = Mock.Create <IErrorService>();

            _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));

            _agentTimerService      = Mock.Create <IAgentTimerService>();
            _transactionTransformer = new TransactionTransformer(_transactionMetricNameMaker, _segmentTreeMaker, _metricNameService, _metricAggregator, _configurationService, _transactionTraceAggregator, _transactionTraceMaker, _transactionEventAggregator, _transactionEventMaker, _transactionAttributeMaker, _errorTraceAggregator, _errorTraceMaker, _errorEventAggregator, _errorEventMaker, _sqlTraceAggregator, _sqlTraceMaker, _spanEventAggregator, _spanEventMaker, _agentTimerService, Mock.Create <IAdaptiveSampler>(), _errorService, _spanEventAggregatorInfiniteTracing);
            _customEventTransformer = new CustomEventTransformer(_configurationService, _customEventAggregator, _attribDefSvc);
        }
        public void SetUp()
        {
            // Mocks
            _transactionMetricNameMaker = Mock.Create <ITransactionMetricNameMaker>();
            Mock.Arrange(() => _transactionMetricNameMaker.GetTransactionMetricName(Arg.Matches <ITransactionName>(txName => txName.IsWeb)))
            .Returns(new TransactionMetricName("WebTransaction", "TransactionName"));
            Mock.Arrange(() => _transactionMetricNameMaker.GetTransactionMetricName(Arg.Matches <ITransactionName>(txName => !txName.IsWeb))).Returns(new TransactionMetricName("OtherTransaction", "TransactionName"));

            _metricAggregator = Mock.Create <IMetricAggregator>();

            _configuration        = GetDefaultConfiguration();
            _configurationService = Mock.Create <IConfigurationService>();
            Mock.Arrange(() => _configurationService.Configuration).Returns(_configuration);

            _transactionTraceAggregator         = Mock.Create <ITransactionTraceAggregator>();
            _transactionTraceMaker              = Mock.Create <ITransactionTraceMaker>();
            _transactionEventAggregator         = Mock.Create <ITransactionEventAggregator>();
            _transactionEventMaker              = Mock.Create <ITransactionEventMaker>();
            _transactionAttributeMaker          = Mock.Create <ITransactionAttributeMaker>();
            _errorTraceAggregator               = Mock.Create <IErrorTraceAggregator>();
            _errorTraceMaker                    = Mock.Create <IErrorTraceMaker>();
            _errorEventAggregator               = Mock.Create <IErrorEventAggregator>();
            _errorEventMaker                    = Mock.Create <IErrorEventMaker>();
            _spanEventAggregator                = Mock.Create <ISpanEventAggregator>();
            _spanEventAggregatorInfiniteTracing = Mock.Create <ISpanEventAggregatorInfiniteTracing>();
            _spanEventMaker    = Mock.Create <ISpanEventMaker>();
            _agentTimerService = Mock.Create <IAgentTimerService>();

            _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));
            _errorService = Mock.Create <IErrorService>();

            // Non-Mocks
            _segmentTreeMaker = new SegmentTreeMaker();

            _metricNameService = Mock.Create <IMetricNameService>();
            Mock.Arrange(() => _metricNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => name);

            var dataTransportService = Mock.Create <DataTransport.IDataTransportService>();
            var scheduler            = Mock.Create <Time.IScheduler>();
            var processStatic        = Mock.Create <SystemInterfaces.IProcessStatic>();
            var agentHealthReporter  = Mock.Create <AgentHealth.IAgentHealthReporter>();

            _sqlTraceAggregator = new SqlTraceAggregator(dataTransportService, scheduler, processStatic, agentHealthReporter);

            _transactionAttributeMaker = new TransactionAttributeMaker(_configurationService, _attribDefSvc);

            _sqlTraceMaker = new SqlTraceMaker(_configurationService, _attribDefSvc, new DatabaseService(Mock.Create <ICacheStatsReporter>()));

            // create TransactionTransformer
            _transactionTransformer = new TransactionTransformer(_transactionMetricNameMaker, _segmentTreeMaker, _metricNameService, _metricAggregator, _configurationService, _transactionTraceAggregator, _transactionTraceMaker, _transactionEventAggregator, _transactionEventMaker, _transactionAttributeMaker, _errorTraceAggregator, _errorTraceMaker, _errorEventAggregator, _errorEventMaker, _sqlTraceAggregator, _sqlTraceMaker, _spanEventAggregator, _spanEventMaker, _agentTimerService, Mock.Create <IAdaptiveSampler>(), _errorService, _spanEventAggregatorInfiniteTracing);
        }