Esempio n. 1
0
        public Kernel(GraphiteConfiguration configuration, GraphiteSystemConfiguration systemConfiguration)
        {
            this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD);

            foreach (var listener in systemConfiguration.EventlogListeners.Cast<EventlogListenerElement>())
            {
                this.CreateEventlogListener(listener);
            }

            this.scheduler = new Scheduler();

            foreach (var listener in systemConfiguration.CounterListeners.Cast<CounterListenerElement>())
            {
                Action action;

                try
                {
                    action = this.CreateReportingAction(listener);

                    this.scheduler.Add(action, listener.Interval);
                }
                catch (InvalidOperationException)
                {
                    if (!listener.Retry)
                        throw;

                    this.retryCreation.Add(listener);
                }
            }

            if (this.retryCreation.Any())
            {
                this.scheduler.Add(this.RetryCounterCreation, RetryInterval);
            }

            foreach (var appPool in systemConfiguration.AppPool.Cast<AppPoolElement>())
            {
                AppPoolListener element;

                var action = this.CreateReportingAction(appPool, out element);

                this.scheduler.Add(action, appPool.Interval);

                // Reread counter instance name every 90 seconds
                this.scheduler.Add(() => element.LoadCounterName(), 90);
            }

            this.scheduler.Start();
        }
Esempio n. 2
0
        internal MetricsPipe(GraphiteConfiguration configuration, IMetricsPipeProvider provider, Func<IStopwatch> watch)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            if (provider == null)
                throw new ArgumentNullException("provider");

            if (watch == null)
                throw new ArgumentNullException("watch");

            this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD);

            MetricsPipe.provider = provider;

            this.watch = watch();
        }