Ejemplo n.º 1
0
 public void Write(MetricValue metric)
 {
     if (metric == null)
     {
         Logger.Debug("write() - Invalid null metric");
         return;
     }
     if (!_connected)
     {
         StartConnection();
     }
     if (_connected && _channel != null)
     {
         string routingKey = GetAmqpRoutingKey(metric);
         string message    = metric.GetMetricJsonStr();
         try
         {
             _channel.BasicPublish(_exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
         }
         catch
         {
             CloseConnection();
         }
     }
 }
Ejemplo n.º 2
0
        public void Write(MetricValue metric)
        {
            // Optional Regex replace of unsafe chars
            if (SafeCharsRegex != null)
            {
                metric.PluginInstanceName = SafeCharsRegex.Replace(metric.PluginInstanceName, ReplaceWith);
            }

            string message = metric.GetMetricJsonStr();

            if (_batchedMetricStr == null)
            {
                _batchedMetricStr = new StringBuilder("[").Append(message);
            }
            else
            {
                _batchedMetricStr.Append(",").Append(message);
            }
            _numMetrics++;

            if (_numMetrics < BatchSize)
            {
                return;
            }

            publish();
        }
Ejemplo n.º 3
0
 public void Write(MetricValue metric)
 {
     if (metric == null)
     {
         Logger.Debug("write() - Invalid null metric");
         return;
     }
     if (!_connected)
         StartConnection();
     if (_connected && _channel != null)
     {
         string routingKey = GetAmqpRoutingKey(metric);
         string message = metric.GetMetricJsonStr();
         try
         {
             _channel.BasicPublish(_exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
         }
         catch
         {
             CloseConnection();
         }
     }
 }
Ejemplo n.º 4
0
        public void Write(MetricValue metric)
        {
            string message = metric.GetMetricJsonStr();

            if (_batchedMetricStr == null)
            {
                _batchedMetricStr = new StringBuilder("[").Append(message);
            }
            else
            {
                _batchedMetricStr.Append(",").Append(message);
            }
            _numMetrics++;

            if (_numMetrics < BatchSize)
            {
                return;
            }

            _batchedMetricStr.Append("]");
            HttpPost(_batchedMetricStr.ToString());
            _batchedMetricStr = null;
            _numMetrics       = 0;
        }
Ejemplo n.º 5
0
 public void Write(MetricValue metric)
 {
     Console.WriteLine("ConsolePlugin: {0}", metric.GetMetricJsonStr());
 }
Ejemplo n.º 6
0
        public void Write(MetricValue metric)
        {
            // Optoinal Regex replace of unsafe chars
            if (SafeCharsRegex != null)
            {
                metric.PluginInstanceName = SafeCharsRegex.Replace(metric.PluginInstanceName, ReplaceWith);
            }

            string message = metric.GetMetricJsonStr();

            if (_batchedMetricStr == null)
            {
                _batchedMetricStr = new StringBuilder("[").Append(message);
            }
            else
            {
                _batchedMetricStr.Append(",").Append(message);
            }
            _numMetrics++;

            if (_numMetrics < BatchSize) return;

            publish();
        }
        public void Write(MetricValue metric)
        {
            string message = metric.GetMetricJsonStr();
            if (_batchedMetricStr == null)
            {
                _batchedMetricStr = new StringBuilder("[").Append(message);
            }
            else
            {
                _batchedMetricStr.Append(",").Append(message);
            }
            _numMetrics++;

            if (_numMetrics < BatchSize) return;

            _batchedMetricStr.Append("]");
            HttpPost(_batchedMetricStr.ToString());
            _batchedMetricStr = null;
            _numMetrics = 0;
        }