상속: IRecorder
예제 #1
0
            public void WhenHasResolutionAllLikeTimesShouldBeGrouped()
            {
                var monitorInfo = BuildDefaultMonitorInfo(1000);
                var recordMocks = BuildRecordMocks(monitorInfo);

                var recorder = new Recorder(recordMocks.Cache.Object, recordMocks.Settings.Object);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 452), 1, MonitorReductionType.DefaultAccumulate);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 453), 1, MonitorReductionType.DefaultAccumulate);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 454), 1, MonitorReductionType.DefaultAccumulate);

                Assert.Equal(monitorInfo.MonitorRecords.Count, 1);
                Assert.Equal(monitorInfo.MonitorRecords[0].Number, 3);
            }
예제 #2
0
            public void ShouldThrowExceptionWhenNoSeedConfigIsFound()
            {
                var seeder = new Mock<IConfigSeed>();
                seeder.Setup(x => x.Seed("Test", MonitorReductionType.DefaultAccumulate)).Verifiable();

                var settings = BuildSettings();
                settings.SetupGet(x => x.Debug).Returns(true);
                settings.SetupGet(x => x.ConfigSeed).Returns(seeder.Object);

                var cache = new Mock<IDataCache>();

                var recorder = new Recorder(cache.Object, settings.Object);

                Assert.Throws<Exception>(() => recorder.Record("Test", DateTime.Now, 1, MonitorReductionType.DefaultAccumulate));

                seeder.VerifyAll();
            }
예제 #3
0
파일: Settings.cs 프로젝트: Zocdoc/ZocMon
        public void Initialize(SettingsExtensionOptions settingsExtensionOptions)
        {
            //Need to setup the logger first
            LoggerProvider = settingsExtensionOptions.LoggerProvider ?? new SystemLoggerProvider(this);

            var storageFactory = settingsExtensionOptions.StorageFactory;
            if (settingsExtensionOptions.StorageFactory == null)
            {
                var storageFactoryProvider = new StorageFactoryProvider();
                storageFactory = storageFactoryProvider.CreateProvider();
            }
            var storageCommands = settingsExtensionOptions.StorageCommands ?? new StorageCommands(storageFactory, this);
            var storageCommandsSetup = settingsExtensionOptions.StorageCommandsSetup ?? new StorageCommandsSetup();

            var cache = new DataCache();
            var flusherUpdate = new RecordFlushUpdate(cache, storageCommands);
            var reduceStatus = new RecordReduceStatus(new RecordReduceStatusSourceProviderFile(this));
            var reduceAggregate = new RecordReduceAggregate();
            var compare = new RecordCompare(storageCommands, this);

            var setupSystemTables = new SetupSystemTables(cache, storageCommandsSetup, this);
            var setupSystemData = new SetupSystemData(cache, storageCommandsSetup, this);
            var setupSystem = new SetupSystem(setupSystemTables, setupSystemData, storageFactory);
            var defineDefaults = new SetupMonitorConfig(storageCommands, setupSystemTables, cache, storageFactory, this);

            ConfigSeed = new ConfigSeed(cache, this);
            Recorder = new Recorder(cache, this);
            RecordFlush = new RecordFlush(defineDefaults, cache, storageCommands, flusherUpdate, storageFactory, this);
            RecordReduce = new RecordReduce(reduceStatus, reduceAggregate, cache, compare, storageCommands, storageFactory, this);

            ReduceMethodProvider = new ReduceMethodProvider();
            ReduceMethodProvider.Register(new ReduceMethodAccumulate());
            ReduceMethodProvider.Register(new ReduceMethodAverage());
            ProcessingInstructionProvider = new ProcessingInstructionProvider();
            ProcessingInstructionProvider.Register(new ProcessingInstructionAccumulate(storageCommands));
            ProcessingInstructionProvider.Register(new ProcessingInstructionAverage());

            //Run system setup
            setupSystem.Initialize();
        }
예제 #4
0
            public void WhenResolutionIsZeroShouldAddToUpdateList()
            {
                var monitorInfo = BuildDefaultMonitorInfo(0);
                var recordMocks = BuildRecordMocks(monitorInfo);

                var recorder = new Recorder(recordMocks.Cache.Object, recordMocks.Settings.Object);
                recorder.RecordEvent("Test");

                Assert.Equal(monitorInfo.MonitorRecords.Count, 1);
            }