Inheritance: IGraphiteClient, IDisposable
 /// <summary>
 /// Sends a quick metric to graphite
 /// </summary>
 public void SendQuickMetric(string key, int value, DateTime timestamp)
 {
     using (var graphiteClient = new GraphiteTcpClient(host, port, prefix))
     {
         graphiteClient.Send(key, value, timestamp);
     }
 }
 private void SendRecordToGraphite(string path, IDataReader myReader)
 {
     using (var client = new Graphite.GraphiteTcpClient(this.hostname, this.port, string.Empty))
     {
         while (myReader.Read())
         {
             var value = myReader.GetInt32(1);
             var datetime = myReader.GetDateTime(0);
             this.log.Debug(string.Format("Sending {2} [{0}] {1}", value, datetime, path));
             client.Send(path, myReader.GetInt32(1), myReader.GetDateTime(0));
         }
     }
 }
 /// <summary>
 /// Sends the gathered stats to Graphite
 /// </summary>
 public void SendMetrics(IEnumerable<Metric> metrics)
 {
     //Make sure there are metrics to send before we waste a connection
     if ((metrics != null) && (metrics.Any()))
     {
         using (var graphiteClient = new GraphiteTcpClient(host, port, prefix))
         {
             foreach (var metric in metrics)
             {
                 graphiteClient.Send(metric.Key, metric.Value, metric.Timestamp);
             }
         }
     }
 }
        public ActionResult Checkout(Attempts sample)
        {
            using (var client = new GraphiteTcpClient("54.78.137.100", 2003, "checkoutservice"))
            {
                int i = 0;
                while (i < sample.CheckoutAttempt)
                {
                    client.Send("attempts", i);

                    Random random = new Random();
                    if ((sample.SuccessfulCheckout > i) && random.Next(1,15) >= 3)
                        client.Send("successful", i);

                    i++;
                    Thread.Sleep(250);
                }
            }



            using (var client = new GraphiteTcpClient("54.78.137.100", 2003, "checkoutservice"))
            {
                int i = 0;
                while (i < sample.PaymentAttempt)
                {
                    client.Send("attempts", i);

                    Random random = new Random();
                    if ((sample.SuccessfulPayment > i) && random.Next(1, 15) >= 3)
                        client.Send("successful", i);

                    i++;
                    Thread.Sleep(250);
                }
            }

            return View("Index");
        }
        private static bool pushMetrictonewGraphite(string metric, string oldmainurl, string newgraphite, int newport)
        {
            string            url  = oldmainurl + "render?target=" + metric + "&format=json&from=" + Properties.Settings.Default.ImportDataFromDateon + "&until=now";
            List <MetricData> back = JsonConvert.DeserializeObject <List <MetricData> >(getContent(url));

            string prefix     = metric.Remove(metric.LastIndexOf("."));
            string metricname = metric.Remove(0, metric.LastIndexOf(".") + 1);

            var graphiteclient = new Graphite.GraphiteTcpClient(newgraphite, newport, prefix);

            foreach (MetricData m in back)
            {
                foreach (dynamic e in m.datapoints)
                {
                    string value = Convert.ToString(e[0]);
                    double time  = Convert.ToDouble(e[1]);

                    if (!String.IsNullOrEmpty(value))
                    {
                        try
                        {
                            graphiteclient.Send(metricname, Convert.ToDouble(value), UnixTimeStampToDateTime(time));
                        }
                        catch (Exception err)
                        {
                            Console.WriteLine("Error sending metric to Graphite: " + metricname + "; Exception: " + err.Message);
                        }
                    }
                }
            }

            if (String.IsNullOrEmpty(metric))
            {
                Console.WriteLine("Error: Metric is empty!");
            }

            return(true);
        }
 public override void Send(IList<IResult> result)
 {
     var client = new Graphite.GraphiteTcpClient(Hostname, Port);
     var gs = new GraphiteMetrics(result);
     client.Send(gs);
 }
 public override void Send(IResult result)
 {
     var client = new Graphite.GraphiteTcpClient(Hostname, Port);
     client.Send(result.FullPath, result.Value, result.TimeStamp);
 }