Exemple #1
0
 public void SetUp()
 {
     _configuration = Mock.Create <IConfiguration>();
     Mock.Arrange(() => _configuration.ConfigurationVersion).Returns(2);
     _configurationResponder = new ConfigurationAutoResponder(_configuration);
     _metricNameService      = new MetricNameService();
 }
Exemple #2
0
        public void SetUp()
        {
            var configuration = Mock.Create <IConfiguration>();

            Mock.Arrange(() => configuration.CollectorSendDataOnExit).Returns(true);
            Mock.Arrange(() => configuration.CollectorSendDataOnExitThreshold).Returns(0);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);

            _dataTransportService   = Mock.Create <IDataTransportService>();
            _metricBuilder          = WireModels.Utilities.GetSimpleMetricBuilder();
            _agentHealthReporter    = Mock.Create <IAgentHealthReporter>();
            _outOfBandMetricSources = new IOutOfBandMetricSource[] { (IOutOfBandMetricSource)_agentHealthReporter };
            _dnsStatic         = Mock.Create <IDnsStatic>();
            _processStatic     = Mock.Create <IProcessStatic>();
            _metricNameService = Mock.Create <IMetricNameService>();
            Mock.Arrange(() => _metricNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => name);

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

            Mock.Arrange(() => scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; });
            _metricAggregator = new MetricAggregator(_dataTransportService, _metricBuilder, _metricNameService, _outOfBandMetricSources, _processStatic, scheduler);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());
        }
        public void SetUp()
        {
            _environment = Mock.Create <IEnvironment>();

            Mock.Arrange(() => _environment.GetEnvironmentVariable(Arg.IsAny <string>()))
            .Returns(null as string);

            _processStatic              = Mock.Create <IProcessStatic>();
            _httpRuntimeStatic          = Mock.Create <IHttpRuntimeStatic>();
            _configurationManagerStatic = new ConfigurationManagerStaticMock();
            _dnsStatic = Mock.Create <IDnsStatic>();
            _securityPoliciesConfiguration = new SecurityPoliciesConfiguration();

            _runTimeConfiguration = new RunTimeConfiguration();
            _serverConfig         = new ServerConfiguration();
            _localConfig          = new configuration();

            _localConfig.crossApplicationTracingEnabled = true;
            _localConfig.attributes.enabled             = true;
            _localConfig.spanEvents.enabled             = true;
            _localConfig.distributedTracing.enabled     = true;

            _configurationService = Mock.Create <IConfigurationService>();

            UpdateConfig();

            _configAutoResponder = new ConfigurationAutoResponder(_configuration);

            _transactionMetricNameMaker = Mock.Create <ITransactionMetricNameMaker>();
            _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));
            _transactionAttributeMaker = new TransactionAttributeMaker(_configurationService, _attribDefSvc);
        }
            public void Setup()
            {
                var config = CreateMockConfiguration();

                _configAutoResponder = new ConfigurationAutoResponder(config);
                _attribDefSvc        = new AttributeDefinitionService((f) => new AttributeDefinitions(f));
            }
Exemple #5
0
        public void SetUp()
        {
            _configAutoResponder = new ConfigurationAutoResponder(DefaultConfiguration.Instance);

            _healthReporter = Mock.Create <IAgentHealthReporter>();
            _timerSvc       = new AgentTimerService(_healthReporter);

            PushConfiguration(GetNewConfiguration());
        }
Exemple #6
0
        public void SetUp()
        {
            _environment                = Mock.Create <IEnvironment>();
            _processStatic              = Mock.Create <IProcessStatic>();
            _httpRuntimeStatic          = Mock.Create <IHttpRuntimeStatic>();
            _configurationManagerStatic = Mock.Create <IConfigurationManagerStatic>();
            _dnsStatic = Mock.Create <IDnsStatic>();
            _securityPoliciesConfiguration = new SecurityPoliciesConfiguration();

            _runTimeConfiguration = new RunTimeConfiguration();
            _serverConfig         = new ServerConfiguration();

            SetLocalConfigurationDefaults();
            PublishConfig();

            _configAutoResponder = new ConfigurationAutoResponder(_config);

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

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

            _metricNameSvc = new MetricNameService();
            _transactionMetricNameMaker = new TransactionMetricNameMaker(_metricNameSvc);

            _transactionAttribMaker = new TransactionAttributeMaker(_configurationService, _attribDefSvc);

            _spanEventMaker  = new SpanEventMaker(_attribDefSvc, _configurationService);
            _databaseService = new DatabaseService(Mock.Create <ICacheStatsReporter>());

            _transactionEventMaker = new TransactionEventMaker(_attribDefSvc);


            _transactionGuid = GuidGenerator.GenerateNewRelicGuid();
            _startTime       = new DateTime(2018, 7, 18, 7, 0, 0, DateTimeKind.Utc); // unixtime = 1531897200000

            // Generic Segments
            _baseGenericSegment = new Segment(CreateTransactionSegmentState(3, null, 777), new MethodCallData(MethodCallType, MethodCallMethod, 1));
            _baseGenericSegment.SetSegmentData(new SimpleSegmentData(SegmentName));

            _childGenericSegment = new Segment(CreateTransactionSegmentState(4, 3, 777), new MethodCallData(MethodCallType, MethodCallMethod, 1));
            _childGenericSegment.SetSegmentData(new SimpleSegmentData(SegmentName));

            // Datastore Segments
            _connectionInfo       = new ConnectionInfo("localhost", "1234", "default", "maininstance");
            _parsedSqlStatement   = SqlParser.GetParsedDatabaseStatement(DatastoreVendor.MSSQL, System.Data.CommandType.Text, ShortQuery);
            _obfuscatedSql        = _databaseService.GetObfuscatedSql(ShortQuery, DatastoreVendor.MSSQL);
            _baseDatastoreSegment = new Segment(CreateTransactionSegmentState(3, null, 777), new MethodCallData(MethodCallType, MethodCallMethod, 1));
            _baseDatastoreSegment.SetSegmentData(new DatastoreSegmentData(_databaseService, _parsedSqlStatement, ShortQuery, _connectionInfo));

            // Http Segments
            _baseHttpSegment = new Segment(CreateTransactionSegmentState(3, null, 777), new MethodCallData(MethodCallType, MethodCallMethod, 1));
            _baseHttpSegment.SetSegmentData(new ExternalSegmentData(new Uri(HttpUri), HttpMethod));
        }
Exemple #7
0
        public void When_error_traces_disabled_harvest_is_not_scheduled()
        {
            _configurationAutoResponder.Dispose();
            _errorTraceAggregator.Dispose();
            var configuration = Mock.Create <IConfiguration>();

            Mock.Arrange(() => configuration.ErrorCollectorEnabled).Returns(false);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);
            _errorTraceAggregator       = new ErrorTraceAggregator(_dataTransportService, _scheduler, _processStatic, _agentHealthReporter);

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

            Mock.Assert(() => _scheduler.StopExecuting(null, null), Args.Ignore());
        }
        public void SetUp()
        {
            var configuration = GetDefaultConfiguration();

            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);

            _dataTransportService = Mock.Create <IDataTransportService>();
            _scheduler            = Mock.Create <IScheduler>();
            Mock.Arrange(() => _scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; });
            _processStatic       = Mock.Create <IProcessStatic>();
            _agentHealthReporter = Mock.Create <IAgentHealthReporter>();

            _sqlTraceAggregator = new SqlTraceAggregator(_dataTransportService, _scheduler, _processStatic, _agentHealthReporter);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());
        }
        private void SetUp(TestCase testCase)
        {
            _environment = Mock.Create <IEnvironment>();

            Mock.Arrange(() => _environment.GetEnvironmentVariable(Arg.IsAny <string>()))
            .Returns(null as string);

            _processStatic              = Mock.Create <IProcessStatic>();
            _httpRuntimeStatic          = Mock.Create <IHttpRuntimeStatic>();
            _configurationManagerStatic = new ConfigurationManagerStaticMock();
            _dnsStatic = Mock.Create <IDnsStatic>();
            _securityPoliciesConfiguration = new SecurityPoliciesConfiguration();

            _runTimeConfiguration = new RunTimeConfiguration();
            _serverConfig         = new ServerConfiguration();
            _localConfig          = new configuration();


            _localConfig.crossApplicationTracingEnabled = true;
            _localConfig.attributes.enabled             = true;
            _localConfig.service.licenseKey             = testCase.LicenseKey;
            _localConfig.appSettings.Add(new configurationAdd()
            {
                key = "NewRelic.LicenseKey", value = testCase.LicenseKey
            });
            _serverConfig.RumSettingsJavaScriptAgentLoader = "JSAGENT";
            _serverConfig.RumSettingsJavaScriptAgentFile   = testCase.ConnectReply.JsAgentFile;
            _serverConfig.RumSettingsBeacon = testCase.ConnectReply.Beacon;

            _serverConfig.RumSettingsErrorBeacon              = testCase.ConnectReply.ErrorBeacon;
            _serverConfig.RumSettingsBrowserKey               = testCase.ConnectReply.BrowserKey;
            _serverConfig.RumSettingsApplicationId            = testCase.ConnectReply.ApplicationId;
            _localConfig.browserMonitoring.attributes.enabled = testCase.BrowserMonitoringAttributesEnabled;

            _configuration        = new TestableDefaultConfiguration(_environment, _localConfig, _serverConfig, _runTimeConfiguration, _securityPoliciesConfiguration, _processStatic, _httpRuntimeStatic, _configurationManagerStatic, _dnsStatic);
            _configurationService = Mock.Create <IConfigurationService>();
            Mock.Arrange(() => _configurationService.Configuration).Returns(_configuration);

            _configAutoResponder = new ConfigurationAutoResponder(_configuration);

            _transactionMetricNameMaker = Mock.Create <ITransactionMetricNameMaker>();
            _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));
            _transactionAttributeMaker    = new TransactionAttributeMaker(_configurationService, _attribDefSvc);
            _browserMonitoringScriptMaker = new BrowserMonitoringScriptMaker(_configurationService, _transactionMetricNameMaker, _transactionAttributeMaker, _attribDefSvc);
        }
        public void SetUp()
        {
            UpdateDefaultConfiguration();

            var configurationService = Mock.Create <IConfigurationService>();

            Mock.Arrange(() => configurationService.Configuration).Returns(() => _configuration);

            _configurationAutoResponder = new ConfigurationAutoResponder(_configuration);

            _transactionMetricNameMaker = Mock.Create <ITransactionMetricNameMaker>();
            Mock.Arrange(() => _transactionMetricNameMaker.GetTransactionMetricName(Arg.IsAny <ITransactionName>())).Returns(new TransactionMetricName("prefix", "suffix"));

            _transactionAttributeMaker = Mock.Create <ITransactionAttributeMaker>();
            _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));

            _browserMonitoringScriptMaker = new BrowserMonitoringScriptMaker(configurationService, _transactionMetricNameMaker, _transactionAttributeMaker, _attribDefSvc);
        }
Exemple #11
0
        public void SetUp()
        {
            var configuration = GetDefaultConfiguration();

            Mock.Arrange(() => configuration.CollectorSendDataOnExit).Returns(true);
            Mock.Arrange(() => configuration.CollectorSendDataOnExitThreshold).Returns(0);
            Mock.Arrange(() => configuration.TransactionEventsHarvestCycle).Returns(ConfiguredHarvestCycle);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);

            _dataTransportService = Mock.Create <IDataTransportService>();
            _agentHealthReporter  = Mock.Create <IAgentHealthReporter>();
            _processStatic        = Mock.Create <IProcessStatic>();

            _scheduler = Mock.Create <IScheduler>();
            Mock.Arrange(() => _scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; });
            _transactionEventAggregator = new TransactionEventAggregator(_dataTransportService, _scheduler, _processStatic, _agentHealthReporter);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());
        }
Exemple #12
0
        public void SetUp()
        {
            var configuration = Mock.Create <IConfiguration>();

            Mock.Arrange(() => configuration.CollectorSendDataOnExit).Returns(true);
            Mock.Arrange(() => configuration.CollectorSendDataOnExitThreshold).Returns(0);
            Mock.Arrange(() => configuration.TransactionTracerEnabled).Returns(true);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);

            _dataTransportService = Mock.Create <IDataTransportService>();
            _dnsStatic            = Mock.Create <IDnsStatic>();
            _processStatic        = Mock.Create <IProcessStatic>();

            _transactionCollector1 = Mock.Create <ITransactionCollector>();
            _transactionCollector2 = Mock.Create <ITransactionCollector>();
            _transactionCollectors = new[] { _transactionCollector1, _transactionCollector2 };

            _scheduler = Mock.Create <IScheduler>();
            Mock.Arrange(() => _scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; });
            _transactionTraceAggregator = new TransactionTraceAggregator(_dataTransportService, _scheduler, _processStatic, _transactionCollectors);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());
        }
Exemple #13
0
 public void SetUp()
 {
     _configAutoResponder = new ConfigurationAutoResponder(GetConfiguration());
     _attribDefSvc        = new AttributeDefinitionService((f) => new AttributeDefinitions(f));
 }