Ejemplo n.º 1
0
        public ConfigurationDifferenceSummary(ISpectatorConfiguration first, ISpectatorConfiguration second)
        {
            _first  = first;
            _second = second;

            CreateSummary();
        }
Ejemplo n.º 2
0
        private T Get <T>(Func <ISpectatorConfiguration, T> configValue)
        {
            var now = DateTimeOffset.UtcNow;

            if (now <= _expiration)
            {
                return(configValue(_configurationInstance));
            }

            Log.Info("Configuration has expired, refreshing from source");

            var newConfig = _spectatorConfigurationFactory();

            _expiration = now + _expirationInterval;

            Log.Info("Configuration loaded.");

            if (_configurationInstance != null)
            {
                var diff = new ConfigurationDifferenceSummary(_configurationInstance, newConfig);

                if (!diff.IsEmpty())
                {
                    Log.Info("Configuration changed: \n" + diff);
                }
            }

            _configurationInstance = newConfig;
            Log.InfoFormat("Expires next at: {0}", _expiration.ToString("o"));

            return(configValue(_configurationInstance));
        }
        public CombinedSpectatorConfiguration(ISpectatorConfiguration baseConfiguration, ISpectatorOverrideConfiguration overrideConfiguration)
        {
            _baseConfiguration = baseConfiguration;
            _overrideConfiguration = overrideConfiguration;

            Metrics = CombineMetricConfigurations(_baseConfiguration.Metrics, _overrideConfiguration.Metrics);
        }
        public CombinedSpectatorConfiguration(ISpectatorConfiguration baseConfiguration, ISpectatorOverrideConfiguration overrideConfiguration)
        {
            _baseConfiguration     = baseConfiguration;
            _overrideConfiguration = overrideConfiguration;

            Metrics = CombineMetricConfigurations(_baseConfiguration.Metrics, _overrideConfiguration.Metrics);
        }
        public ConfigurationDifferenceSummary(ISpectatorConfiguration first, ISpectatorConfiguration second)
        {
            _first = first;
            _second = second;

            CreateSummary();
        }
Ejemplo n.º 6
0
        public SpectatorService(ISpectatorConfiguration configuration, IQueryableSourceFactory queryableSourceFactory, IMetricPublisher publisher, IMetricFormatter metricFormatter)
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _eventLoopTask           = new Task(BeginSpectating, _cancellationTokenSource.Token);

            _configuration          = configuration;
            _queryableSourceFactory = queryableSourceFactory;
            _publisher       = publisher;
            _metricFormatter = metricFormatter;
        }
Ejemplo n.º 7
0
        public SpectatorService(ISpectatorConfiguration configuration, IQueryableSourceFactory queryableSourceFactory, IMetricPublisher publisher, IMetricFormatter metricFormatter)
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _eventLoopTask = new Task(BeginSpectating, _cancellationTokenSource.Token);

            _configuration = configuration;
            _queryableSourceFactory = queryableSourceFactory;
            _publisher = publisher;
            _metricFormatter = metricFormatter;
        }
        public ConsulSpectatorOverrideConfiguration(string host, string key)
        {
            var client = string.IsNullOrEmpty(host) ? new Client() : new Client(new ConsulClientConfiguration { Address = host });

            var getPair = client.KV.Get(key);
            _configContents = Encoding.UTF8.GetString(getPair.Response.Value, 0, getPair.Response.Value.Length);

            Log.InfoFormat("Using configuration read from consul host '{0}', in key '{1}'", host, key);

            _innerConfiguration = JsonSpectatorConfiguration.LoadConfigFromString(_configContents);
        }
        public ConsulSpectatorOverrideConfiguration(string host, string key)
        {
            var client = string.IsNullOrEmpty(host) ? new Client() : new Client(new ConsulClientConfiguration {
                Address = host
            });

            var getPair = client.KV.Get(key);

            _configContents = Encoding.UTF8.GetString(getPair.Response.Value, 0, getPair.Response.Value.Length);

            Log.InfoFormat("Using configuration read from consul host '{0}', in key '{1}'", host, key);

            _innerConfiguration = JsonSpectatorConfiguration.LoadConfigFromString(_configContents);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            _baseConfig = JsonSpectatorConfiguration.LoadConfigFromString(@"{
                      ""statsdHost"": ""basehost"",
                      ""statsdPort"": 8125,
                      ""metricPrefix"": ""base.prefix"",
                      ""interval"":  ""00:00:01"",
                      ""metrics"": [
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""base.performance.counter""
                        },
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""overriden.performance.counter""
                        }
                      ]
                    }");

            _overrideConfig = JsonSpectatorConfiguration.LoadConfigFromString(@"{
                      ""statsdHost"": ""overridehost"",
                      ""statsdPort"": 8126,
                      ""metricPrefix"": ""override.prefix"",
                      ""interval"":  ""00:00:02"",
                      ""metrics"": [
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""override.performance.counter""
                        },
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\% Processor Time"",
                          ""type"": ""gauge"",
                          ""template"": ""overriden.performance.counter""
                        }
                      ]
                    }");

            _combinedConfig = new CombinedSpectatorConfiguration(_baseConfig, _overrideConfig);
        }
Ejemplo n.º 11
0
        public void SetUp()
        {
            _baseConfig = JsonSpectatorConfiguration.LoadConfigFromString(@"{
                      ""statsdHost"": ""basehost"",
                      ""statsdPort"": 8125,
                      ""metricPrefix"": ""base.prefix"",
                      ""interval"":  ""00:00:01"",
                      ""metrics"": [
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""base.performance.counter""
                        },
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""overriden.performance.counter""
                        }
                      ]
                    }");

            _overrideConfig = JsonSpectatorConfiguration.LoadConfigFromString(@"{
                      ""statsdHost"": ""overridehost"",
                      ""statsdPort"": 8126,
                      ""metricPrefix"": ""override.prefix"",
                      ""interval"":  ""00:00:02"",
                      ""metrics"": [
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\Interrupts/sec"",
                          ""type"": ""gauge"",
                          ""template"": ""override.performance.counter""
                        },
                        {
                          ""source"": ""performanceCounter"",
                          ""path"": ""\\Processor(_Total)\\% Processor Time"",
                          ""type"": ""gauge"",
                          ""template"": ""overriden.performance.counter""
                        }
                      ]
                    }");

            _combinedConfig = new CombinedSpectatorConfiguration(_baseConfig, _overrideConfig);
        }
 public SpectatorServiceTestHarness(ISpectatorConfiguration configuration, IQueryableSourceFactory queryableSourceFactory,
     IMetricPublisher publisher, IMetricFormatter metricFormatter) : base(configuration, queryableSourceFactory, publisher, metricFormatter)
 {
 }
Ejemplo n.º 13
0
 public SpectatorServiceTestHarness(ISpectatorConfiguration configuration, IQueryableSourceFactory queryableSourceFactory,
                                    IMetricPublisher publisher, IMetricFormatter metricFormatter) : base(configuration, queryableSourceFactory, publisher, metricFormatter)
 {
 }