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(); } } }