private void SendLine(GraphiteLine line)
 {
   byte[] data = Encoding.ASCII.GetBytes(line.ToString());
   try
   {
     _client.Send(data, data.Length);
     _systemMetrics.LogCount("backends.graphite.lines");
     _systemMetrics.LogCount("backends.graphite.bytes", data.Length);
   }
   catch (SocketException ex)
   {
     _log.Error("Failed to send packet to Graphite: " + ex.SocketErrorCode.ToString());
   }
 }
Beispiel #2
0
 private void PostMetrics(GraphiteLine[][] lineArrays)
 {
   var lines = new List<GraphiteLine>();
   foreach(var graphiteLineArray in lineArrays)
   {
     foreach (var line in graphiteLineArray)
     {
       lines.Add(line);
     }
   }
   var rawText = String.Join(Environment.NewLine,
     lines.Select(line => line.ToString()).ToArray());
   var bytes = Encoding.UTF8.GetBytes(rawText);
   if (_client.Send(bytes))
   {
     _systemMetrics.LogCount("backends.statsdnet.lines", lines.Count);
     _systemMetrics.LogGauge("backends.statsdnet.bytes", bytes.Length);
   }
 }
 public bool Equals(GraphiteLine line)
 {
     return(line.Name == this.Name &&
            line._quantity == this._quantity &&
            line._epoc == this._epoc);
 }
 public static GraphiteLine[] CloneMany(GraphiteLine[] line)
 {
     return(line.Select(p => GraphiteLine.Clone(p)).ToArray());
 }
 public static GraphiteLine Clone(GraphiteLine line)
 {
     return(new GraphiteLine(line.Name, line._quantity, line._epoc));
 }
Beispiel #6
0
 public bool Equals(GraphiteLine line)
 {
   return line.Name == this.Name &&
     line._quantity == this._quantity &&
     line._epoc == this._epoc;
 }
Beispiel #7
0
 public static GraphiteLine[] CloneMany(GraphiteLine[] line)
 {
   return line.Select(p => GraphiteLine.Clone(p)).ToArray();
 }
Beispiel #8
0
 public static GraphiteLine Clone(GraphiteLine line)
 {
   return new GraphiteLine(line.Name, line._quantity, line._epoc);
 }
Beispiel #9
0
    private void SendToDB(GraphiteLine[] lines)
    {
      try
      {
        DataRow row;
        DataTable tableData = CreateEmptyTable();
        foreach (var line in lines)
        {
          row = tableData.NewRow();
          row["rowid"] = System.DBNull.Value;
          row["source"] = this._collectorName;
          row["metric"] = line.ToString();
          tableData.Rows.Add(row);
        }
        _log.DebugFormat("Attempting to send {0} lines to tb_Metrics.", tableData.Rows.Count);

        _retryPolicy.ExecuteAction(() =>
          {
            using (var bulk = new SqlBulkCopy(_connectionString))
            {
              bulk.DestinationTableName = "tb_Metrics";
              bulk.WriteToServer(tableData);
            }
            _systemMetrics.LogCount("backends.sqlserver.lines", tableData.Rows.Count);
            _log.DebugFormat("Wrote {0} lines to tb_Metrics.", tableData.Rows.Count);
          });
      }
      catch (Exception ex)
      {
        _log.Error("SqlServerBackend: All retries failed.", ex);
        _systemMetrics.LogCount("backends.sqlserver.droppedData");
      }
    }