public UtilizationStore(ISystemInfo systemInfo, IDnsStatic dnsStatic, IConfiguration configuration, IAgentHealthReporter agentHealthReporter)
 {
     _systemInfo          = systemInfo;
     _dnsStatic           = dnsStatic;
     _configuration       = configuration;
     _agentHealthReporter = agentHealthReporter;
 }
Exemplo n.º 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);
        }
Exemplo n.º 4
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));
        }
 public void Setup()
 {
     _environment                   = Mock.Create <IEnvironment>();
     _processStatic                 = Mock.Create <IProcessStatic>();
     _httpRuntimeStatic             = Mock.Create <IHttpRuntimeStatic>();
     _configurationManagerStatic    = Mock.Create <IConfigurationManagerStatic>();
     _localConfig                   = new configuration();
     _serverConfig                  = new ServerConfiguration();
     _runTimeConfig                 = new RunTimeConfiguration();
     _securityPoliciesConfiguration = new SecurityPoliciesConfiguration();
     _dnsStatic     = Mock.Create <IDnsStatic>();
     _defaultConfig = new TestDefaultConfiguration(_environment, _localConfig, _serverConfig, _runTimeConfig, _securityPoliciesConfiguration, _processStatic, _httpRuntimeStatic, _configurationManagerStatic, _dnsStatic);
 }
Exemplo n.º 6
0
        public ConnectionHandler(ISerializer serializer, ICollectorWireFactory collectorWireFactory, IProcessStatic processStatic, IDnsStatic dnsStatic, ILabelsService labelsService, Environment environment, ISystemInfo systemInfo, IAgentHealthReporter agentHealthReporter, IEnvironment environmentVariableHelper)
        {
            _serializer                = serializer;
            _collectorWireFactory      = collectorWireFactory;
            _processStatic             = processStatic;
            _dnsStatic                 = dnsStatic;
            _labelsService             = labelsService;
            _environment               = environment;
            _systemInfo                = systemInfo;
            _agentHealthReporter       = agentHealthReporter;
            _environmentVariableHelper = environmentVariableHelper;

            _connectionInfo  = new ConnectionInfo(_configuration);
            _dataRequestWire = new NoOpCollectorWire();
        }
        public void Setup()
        {
            _systemInfo          = Mock.Create <ISystemInfo>();
            _agentHealthReporter = Mock.Create <IAgentHealthReporter>();

            Mock.Arrange(() => _systemInfo.GetTotalLogicalProcessors()).Returns(6);
            Mock.Arrange(() => _systemInfo.GetTotalPhysicalMemoryBytes()).Returns((ulong)16000 * 1024 * 1024);

            _dnsStatic = Mock.Create <IDnsStatic>();
            Mock.Arrange(() => _dnsStatic.GetHostName()).Returns("Host-Name");
            Mock.Arrange(() => _dnsStatic.GetFullHostName()).Returns("Host-Name.Domain");
            Mock.Arrange(() => _dnsStatic.GetIpAddresses()).Returns(new List <string> {
                "127.0.0.1", "0.0.0.0"
            });
        }
        public ConfigurationService(IEnvironment environment, IProcessStatic processStatic, IHttpRuntimeStatic httpRuntimeStatic, IConfigurationManagerStatic configurationManagerStatic, IDnsStatic dnsStatic)
        {
            _environment                = environment;
            _processStatic              = processStatic;
            _httpRuntimeStatic          = httpRuntimeStatic;
            _configurationManagerStatic = configurationManagerStatic;
            _dnsStatic = dnsStatic;

            Configuration = new InternalConfiguration(_environment, _localConfiguration, _serverConfiguration, _runTimeConfiguration, _securityPoliciesConfiguration, _processStatic, _httpRuntimeStatic, _configurationManagerStatic, dnsStatic);

            _subscriptions.Add <ConfigurationDeserializedEvent>(OnConfigurationDeserialized);
            _subscriptions.Add <ServerConfigurationUpdatedEvent>(OnServerConfigurationUpdated);
            _subscriptions.Add <AppNameUpdateEvent>(OnAppNameUpdate);
            _subscriptions.Add <GetCurrentConfigurationRequest, IConfiguration>(OnGetCurrentConfiguration);
            _subscriptions.Add <SecurityPoliciesConfigurationUpdatedEvent>(OnSecurityPoliciesUpdated);
        }
        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);
        }
Exemplo n.º 10
0
        public AgentHealthReporter(IMetricBuilder metricBuilder, IScheduler scheduler, IDnsStatic dnsStatic)
        {
            _metricBuilder = metricBuilder;
            _dnsStatic     = dnsStatic;
            _scheduler     = scheduler;
            _scheduler.ExecuteEvery(LogRecurringLogs, _timeBetweenExecutions);
            var agentHealthEvents = Enum.GetValues(typeof(AgentHealthEvent)) as AgentHealthEvent[];

            foreach (var agentHealthEvent in agentHealthEvents)
            {
                _agentHealthEventCounters[agentHealthEvent] = new InterlockedCounter();
            }

            _payloadCreateSuccessCounter      = new InterlockedCounter();
            _payloadAcceptSuccessCounter      = new InterlockedCounter();
            _traceContextAcceptSuccessCounter = new InterlockedCounter();
            _traceContextCreateSuccessCounter = new InterlockedCounter();
        }
Exemplo n.º 11
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());
        }
 public TestDefaultConfiguration(IEnvironment environment, configuration localConfig, ServerConfiguration serverConfig, RunTimeConfiguration runTimeConfiguration, SecurityPoliciesConfiguration _securityPoliciesConfiguration, IProcessStatic processStatic, IHttpRuntimeStatic httpRuntimeStatic, IConfigurationManagerStatic configurationManagerStatic, IDnsStatic dnsStatic) : base(environment, localConfig, serverConfig, runTimeConfiguration, _securityPoliciesConfiguration, processStatic, httpRuntimeStatic, configurationManagerStatic, dnsStatic)
 {
 }
Exemplo n.º 13
0
 public SystemInfo(IDnsStatic dnsStatic)
 {
     _dnsStatic = dnsStatic;
 }