private static void Main(string[] args)
 {
     var client = new Client("10.211.55.2");
     Stats.MethodExecuted += (sender, info) => client.SendEvent(info.MethodBase.ToString(), String.Empty, String.Empty, (float)info.TimeSpan.Ticks / 10);
     WireUpHistograms();
     var benchmarks = new IBenchmark[] {new SagaPersisterBenchmark(), new OutboxPersisterBenchmark(), new TimeoutPersisterBenchmark() };
     const int iterations = 1000;
     Console.WriteLine("Executing benchmarks. Please wait...");
     const string outfile = "log.csv";
     var writeheaders = !File.Exists(outfile);
     if (!File.Exists(outfile))
     {
     }
     new Timer(o => PrintHistograms(), null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(30));
     for(var runIdx = 0; runIdx < 10; runIdx++)
     {
         using (var stream = File.AppendText(outfile)) {
             if (writeheaders) {
                 stream.WriteLine("Header,StartTime,Minimum,Maximum,Mean,95th Percentile,99th Percentile");
             }
             foreach (var benchmark in benchmarks) {
                 Console.WriteLine("Executing benchmarks in {0}...", benchmark.GetType().Name);
                 foreach (var timingInfo in benchmark.Execute(iterations)) {
                     Console.WriteLine("{0} Min: {1}us, Max: {2}us, 95%: {3}us, 99%: {4}us", timingInfo.Name,
                         timingInfo.Histogram.getMinValue(),
                         timingInfo.Histogram.getMaxValue(), timingInfo.Histogram.getValueAtPercentile(95),
                         timingInfo.Histogram.getValueAtPercentile(99));
                     stream.WriteLine("{0},{1},{2},{3},{4},{5},{6}", timingInfo.Name, timingInfo.StartTime.ToString("o"), timingInfo.Histogram.getMinValue(), timingInfo.Histogram.getMaxValue(), timingInfo.Histogram.getMean(), timingInfo.Histogram.getValueAtPercentile(95), timingInfo.Histogram.getValueAtPercentile(99));
                 }
             }
         }
     }
 }
        public BackgroundBatchClient(Client client, int? bufferSize = null, int? flushInterval = null)
            : base(client, bufferSize ?? DefaultBatchSize)
        {
            FlushInterval = flushInterval ?? DefaultFlushInterval;

            TokenSource = new CancellationTokenSource();

            Start();
        }
        public static void Main(string[] args)
        {
            string hostname;
            ushort port;
            switch (args.Length) {
                case 0:
                    hostname = "localhost";
                    port = 5555;
                    break;
                case 1:
                    hostname = args[0];
                    port = 5555;
                    break;
                case 2:
                    hostname = args[0];
                    if (!ushort.TryParse(args[1], out port)) {
                        Usage();
                        Environment.Exit(-1);
                    }
                    break;
                default:
                    Usage();
                    Environment.Exit(-1);
                    return;
            }
            var client = new Client(hostname, port);

            var reporters = Health.Reporters()
                .ToList();
            while (true) {
                foreach (var reporter in reporters) {
                    string description;
                    float value;

                    if (reporter.TryGetValue(out description, out value)) {
                        string state;
                        if (value < reporter.WarnThreshold) {
                            state = "ok";
                        } else if (value < reporter.CriticalThreshold) {
                            state = "warning";
                        } else {
                            state = "critical";
                        }
                        client.SendEvent(reporter.Name, state, description, value, 1);
                    }
                }
                Thread.Sleep(TimeSpan.FromSeconds(1.0));
            }
        }
Example #4
0
 public RiemannTags(Client owner, RiemannTags underlying, string tag)
 {
     _owner = owner;
     _underlying = underlying;
     _tag = tag;
 }
Example #5
0
 public BatchClient(Client client, int bufferSize)
 {
     Client = client;
     BufferSize = bufferSize;
     EventQueue = new ConcurrentQueue<Event>();
 }
Example #6
0
 public BatchClient(Client client)
     : this(client, DefaultBatchSize)
 {
 }
 public void Setup()
 {
     _server = new MockServer();
     _client = new Client("localhost", 5558, false, true);
     _client.SuppressSendErrors = false;
 }
        public static void Main(string[] args)
        {
            string hostname;
            ushort port;
            double interval = 1.0;
            ushort ttl = 5;
            bool includeGCStats;
            switch (args.Length) {
                case 0:
                    var appSettings = ConfigurationManager.AppSettings;
                    hostname = appSettings["RiemannHost"];
                    port = UInt16.Parse(appSettings["RiemannPort"]);
                    interval = (float)UInt16.Parse(appSettings["Interval"]);
                    ttl = UInt16.Parse(appSettings["TTL"]);
                    includeGCStats = Boolean.Parse(appSettings["IncludeGCstats"]);
                    break;
                case 1:
                    hostname = args[0];
                    port = 5555;
                    includeGCStats = true;
                    break;
                case 2:
                    hostname = args[0];
                    if (!ushort.TryParse(args[1], out port)) {
                        Usage();
                        Environment.Exit(-1);
                    }
                    includeGCStats = true;
                    break;
                default:
                    Usage();
                    Environment.Exit(-1);
                    return;
            }

            var serviceConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.PerUserRoamingAndLocal);
            var serviceSection = serviceConfig.GetSection("services") as ServiceInfoSection;

            var client = new Client(hostname, port);
            var reporters = Health.Reporters(includeGCStats, serviceSection.Services)
                .ToList();
            while (true) {
                foreach (var reporter in reporters) {
                    string description;
                    float value;

                    if (reporter.TryGetValue(out description, out value)) {
                        string state;
                        if (value >= reporter.CriticalThreshold) {
                            state = "critical";
                        } else if (value >= reporter.WarnThreshold) {
                            state = "warning";
                        } else {
                            state = "ok";
                        }
                        client.SendEvent(reporter.Name, state, description, value, ttl);
                    }
                }
                Thread.Sleep(TimeSpan.FromSeconds(interval));
            }
        }