예제 #1
0
        public StatsDBackend(IStatsDConfiguration configuration)
        {
            this.factory = new ChannelFactory(null, configuration);

            this.channels = new Dictionary<string, IMonitoringChannel>
            {
                { MetricType.Counter, this.factory.CreateChannel("counter", "statsd") },
                { MetricType.Gauge, this.factory.CreateChannel("gauge", "statsd") },
                { MetricType.Timing, this.factory.CreateChannel("timing", "statsd") },
            };
        }
예제 #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();
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogAssertion" /> class.
        /// </summary>
        public LogAssertion()
        {
            this.factory = new ChannelFactory(
                GraphiteConfiguration.Instance.Graphite,
                GraphiteConfiguration.Instance.StatsD);

            var configuration = GraphiteElmahConfiguration.Instance;

            if (configuration == null)
                throw new InvalidOperationException("No configuration section 'graphite.elmah' found.");

            this.metricKey = configuration.Key ?? "admin.elmah_errors";

            this.channel = this.factory.CreateChannel(
                configuration.Type ?? "counter",
                configuration.Target ?? "statsd");
        }
예제 #4
0
        public override bool Execute()
        {
            using (var channelFactory = new ChannelFactory(null, this))
            {
                IMonitoringChannel channel = channelFactory.CreateChannel(
                    this.Type.ToString(),
                    "statsd");

                channel.Report(this.Key, this.Value);

                Console.Out.WriteLine(
                    "Reported value '{0}' of type '{1}' for key '{2}' to {3}:{4}.",
                    this.Value,
                    this.Type,
                    string.IsNullOrEmpty(this.PrefixKey) ? this.Key : (this.PrefixKey + "." + this.Key),
                    this.Address,
                    this.Port);
            }

            return true;
        }
예제 #5
0
        public GraphiteExport(string host, string metricFormat, string projectName, string baseKey)
        {
            this.baseKey = baseKey;
            this.projectName = projectName;
            this.metricFormat = metricFormat;
            string[] addressParts = host.Split(':');
            int port = 2003;

            if (addressParts.Length > 1)
            {
                port = int.Parse(addressParts[1]);
            }

            this.factory = new Graphite.ChannelFactory(new GraphiteConfiguration
                {
                    Address = addressParts.First(),
                    Port = port,
                    Transport = TransportType.Tcp,
                },
                null);

            this.channel = this.factory.CreateHistoryChannel("gauge", "graphite");
        }
예제 #6
0
        public GraphiteBackend(IGraphiteConfiguration configuration)
        {
            this.factory = new ChannelFactory(configuration, null);

            this.graphiteChannel = this.factory.CreateChannel("gauge", "graphite");
        }