Esempio n. 1
0
        public void Write(CollectableValue value)
        {
            // This Write Plugin only knows about metrics
            if (!(value is MetricValue))
            {
                return;
            }

            if (value == null)
            {
                Logger.Debug("write() - Invalid null metric");
                return;
            }
            MetricValue metric = (MetricValue)value;

            if (!_connected)
            {
                StartConnection();
            }
            if (_connected && _channel != null)
            {
                string routingKey = GetAmqpRoutingKey(metric);
                string message    = metric.getJSON();
                try
                {
                    _channel.BasicPublish(_exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
                }
                catch
                {
                    CloseConnection();
                }
            }
        }
Esempio n. 2
0
        public void Write(CollectableValue value)
        {
            // This Write Plugin only knows about metrics
            if (!(value is MetricValue))
                return;

            string payload = "[" + value.getJSON() + "]";
            Logger.Debug("WriteHTTPPlugin: {0}", payload);

            string result = "";
            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";
                result = client.UploadString(_url, "POST", payload);
            }
            Logger.Debug("response: {0}", result);
        }
Esempio n. 3
0
        public void Write(CollectableValue value)
        {
            // This Write Plugin only knows about metrics
            if (!(value is MetricValue))
            {
                return;
            }

            string payload = "[" + value.getJSON() + "]";

            Logger.Debug("WriteHTTPPlugin: {0}", payload);

            string result = "";

            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";
                result = client.UploadString(_url, "POST", payload);
            }
            Logger.Debug("response: {0}", result);
        }
Esempio n. 4
0
        public void Write(CollectableValue value)
        {
            // This Write Plugin only knows about metrics
            if (!(value is MetricValue))
                return;

            MetricValue metric = (MetricValue)value;
            //Rough first pass
            //TODO - handle multiple metrics
            //TODO - check type
            string bucket = "";
            if (_prefix.Trim().Length > 0)
                bucket += _prefix.Trim() + ".";

            bucket += metric.HostName + "." + metric.PluginName;
            if (metric.PluginInstanceName.Length > 0)
                bucket += "." + metric.PluginInstanceName;

            bucket += "." + metric.TypeInstanceName;

            // Remove : and | from bucket names
            bucket = bucket.Replace(":", "_").Replace("|", "_").Replace(" ", "_");
            string payload = bucket + ":" + metric.Values[0] + "|g";

            if (metric.Values.Length > 1)
            {
                Logger.Warn("Multiple counters not handled yet - only posting first");
            }
            Logger.Debug("WriteStatsdPlugin: {0}", payload);

            using (var client = new UdpClient())
            {
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(_host), _port);
                client.Connect(ep);

                byte[] data = System.Text.Encoding.UTF8.GetBytes (payload);
                // Fire and forget
                client.Send(data, data.Length);
            }
        }
 public void Write(CollectableValue value)
 {
     Console.WriteLine("ConsolePlugin: {0}", value.getJSON());
 }
 public void Write(CollectableValue value)
 {
     Console.WriteLine("ConsolePlugin: {0}", value.getJSON());
 }
Esempio n. 7
0
        public void Write(CollectableValue value)
        {
            // This Write Plugin only knows about metrics
            if (!(value is MetricValue))
                return;

            if (value == null)
            {
                Logger.Debug("write() - Invalid null metric");
                return;
            }
            MetricValue metric = (MetricValue)value;
            if (!_connected)
                StartConnection();
            if (_connected && _channel != null)
            {
                string routingKey = GetAmqpRoutingKey(metric);
                string message = metric.getJSON();
                try
                {
                    _channel.BasicPublish(_exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
                }
                catch
                {
                    CloseConnection();
                }
            }
        }
        public void Write(CollectableValue value)
        {
            if (!_enabled)
                return;

            Queue<CollectableValue> entry = new Queue<CollectableValue>();
            entry.Enqueue(value);
            Write(entry);
        }