public void add_one_counter_and_one_timer_sends_and_removes_commands() { var s = new Statsd(_udp, SampleEverything); s.AddInteger(IntegralMetric.Counter, "counter", 1, 0.1); s.AddInteger(IntegralMetric.Timer, "timer", 1); s.Send(); Assert.That(s.Commands.Count, Is.EqualTo(0)); }
public void add_counter_sets_prefix_on_name() { var s = new Statsd(_udp, SampleEverything, MeasureHalfASecond, "another.prefix."); s.AddInteger(IntegralMetric.Counter, "counter", 1, 0.1); s.AddInteger(IntegralMetric.Timer, "timer", 1); s.Send(); _udp.AssertWasCalled(x => x.Send("another.prefix.counter:1|c|@0.1\nanother.prefix.timer:1|ms")); }
public void add_one_counter_and_one_timer_sends_in_one_go() { var s = new Statsd(_udp, SampleEverything); s.AddInteger(IntegralMetric.Counter, "counter", 1, 0.1); s.AddInteger(IntegralMetric.Timer, "timer", 1); s.Send(); _udp.AssertWasCalled(x => x.Send("counter:1|c|@0.1\ntimer:1|ms")); }
public void add_one_counter_and_one_gauge_with_no_sample_rate_shows_in_commands() { var s = new Statsd(_udp, SampleEverything); s.AddInteger(IntegralMetric.Counter, "counter", 1); s.AddInteger(IntegralMetric.Timer, "timer", 1); Assert.That(s.Commands.Count, Is.EqualTo(2)); Assert.That(s.Commands[0], Is.EqualTo("counter:1|c")); Assert.That(s.Commands[1], Is.EqualTo("timer:1|ms")); }
public void set_max_udp_packet_size() { // Make sure that we can set the max UDP packet size udp = new StatsdUDP(serverName, serverPort, 10); statsd = new Statsd(udp); var msg = new String('f', 5); listenThread.Start(2); statsd.AddInteger(IntegralMetric.Counter, msg, 1); statsd.AddInteger(IntegralMetric.Timer, msg, 2); statsd.Send(); // Since our packet size limit is now 10, this (short) message should still be split AssertWasReceived(String.Format("{0}:1|c", msg), 0); AssertWasReceived(String.Format("{0}:2|ms", msg), 1); }
public void can_concurrently_add_integer_metrics() { var s = new Statsd(_udp, SampleEverything); Parallel.For(0, 1000000, x => Assert.DoesNotThrow(() => s.AddInteger(IntegralMetric.Counter, "name", 5))); }
public void add_one_counter_and_send_one_timer_sends_only_sends_the_last() { var s = new Statsd(_udp, SampleEverything); s.AddInteger(IntegralMetric.Counter, "counter", 1); s.SendInteger(IntegralMetric.Timer, "timer", 1); _udp.AssertWasCalled(x => x.Send("timer:1|ms")); }
send_unsplittable_oversized_udp_packets_are_not_split_or_sent_and_no_exception_is_raised() { // This message will be one byte longer than the theoretical limit of a UDP packet var msg = new String('f', 65508); listenThread.Start(); statsd.AddInteger(IntegralMetric.Counter, msg, 1); statsd.Send(); // It shouldn't be split or sent, and no exceptions should be raised. AssertWasReceived(null); }