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 MergeScopedStats_VerifyRenaming() { IMetricNameService mNameService = Mock.Create <IMetricNameService>(); Mock.Arrange(() => mNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => "IAmRenamed"); var metric1 = MetricWireModel.BuildMetric(_metricNameService, "name", "myscope", MetricDataWireModel.BuildTimingData(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(2))); var engine = new MetricStatsCollection(); var scopedStats = new MetricStatsDictionary <string, MetricDataWireModel>(); scopedStats[metric1.MetricName.Name] = metric1.Data; engine.MergeScopedStats(metric1.MetricName.Scope, scopedStats); IEnumerable <MetricWireModel> stats = engine.ConvertToJsonForSending(mNameService); var count = 0; foreach (MetricWireModel current in stats) { count++; Assert.AreEqual("IAmRenamed", current.MetricName.Name); Assert.AreEqual("myscope", current.MetricName.Scope); Assert.AreEqual(1, current.Data.Value0); Assert.AreEqual(3, current.Data.Value1); Assert.AreEqual(2, current.Data.Value2); } Assert.AreEqual(1, count); }
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); }
public void Setup() { Mock.Arrange(() => _metricNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => name); _connectionHandler = new ConnectionHandler(new JsonSerializer(), Mock.Create <ICollectorWireFactory>(), Mock.Create <IProcessStatic>(), Mock.Create <IDnsStatic>(), Mock.Create <ILabelsService>(), Mock.Create <Environment>(), Mock.Create <ISystemInfo>(), Mock.Create <IAgentHealthReporter>(), Mock.Create <IEnvironment>()); var validScopedMetric = MetricWireModel.BuildMetric(_metricNameService, "DotNet/name", "WebTransaction/DotNet/name", MetricDataWireModel.BuildTimingData(TimeSpan.FromSeconds(3.0), TimeSpan.FromSeconds(2.0))); var validUnscopedMetric = MetricWireModel.BuildMetric(_metricNameService, "Custom/name", string.Empty, MetricDataWireModel.BuildTimingData(TimeSpan.FromSeconds(4.0), TimeSpan.FromSeconds(3.0))); var validMetricWireModels = new List <MetricWireModel> { validScopedMetric, validUnscopedMetric }; _wellformedMetricData = new MetricWireModelCollection("440491846668652", 1450462672.0, 1450462710.0, validMetricWireModels); }
public void SetUp() { _metricNameService = Mock.Create <IMetricNameService>(); Mock.Arrange(() => _metricNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => name); _metricBuilder = new MetricWireModel.MetricBuilder(_metricNameService); }
public void SetUp() { Mock.Arrange(() => _metricNameService.RenameMetric(Arg.IsAny <string>())).Returns <string>(name => name); }