public void timer_method_sets_return_value() { var returnValue = CloudInsightStatsd.Time(() => pauseAndReturnInt(), "lifetheuniverseandeverything"); AssertWasReceivedMatches(@"lifetheuniverseandeverything:\d{3}\|ms"); Assert.AreEqual(42, returnValue); }
public void timer_method_sample_rate_tags() { CloudInsightStatsd.Time(() => Thread.Sleep(500), "timer", sampleRate: 1.1, tags: new[] { "tag1:true", "tag2" }); // Make sure that the received timer is of the right order of magnitude. // The measured value will probably be a few ms longer than the sleep value. AssertWasReceivedMatches(@"timer:\d{3}\|ms\|@1\.1\|#tag1:true,tag2"); }
public void timer_method_sets_return_value_sample_rate_and_tag() { var returnValue = CloudInsightStatsd.Time(() => pauseAndReturnInt(), "lifetheuniverseandeverything", sampleRate: 4.2, tags: new[] { "fjords" }); AssertWasReceivedMatches(@"lifetheuniverseandeverything:\d{3}\|ms\|@4\.2\|#fjords"); Assert.AreEqual(42, returnValue); }
public void timer_method_sets_return_value_tags() { var returnValue = CloudInsightStatsd.Time(() => pauseAndReturnInt(), "lifetheuniverseandeverything", tags: new[] { "towel:present" }); AssertWasReceivedMatches(@"lifetheuniverseandeverything:\d{3}\|ms\|#towel:present"); Assert.AreEqual(42, returnValue); }
public void timer_method() { CloudInsightStatsd.Time(() => Thread.Sleep(500), "timer"); // Make sure that the received timer is of the right order of magnitude. // The measured value will probably be a few ms longer than the sleep value. AssertWasReceivedMatches(@"timer:\d{3}\|ms"); }
public void counter_sample_rate() { // A sample rate over 1 doesn't really make sense, but it allows // the test to pass every time CloudInsightStatsd.Counter("counter", 1, sampleRate: 1.1); AssertWasReceived("counter:1|c|@1.1"); }
public void timer_block() { using (CloudInsightStatsd.StartTimer("timer")) { Thread.Sleep(200); Thread.Sleep(300); } AssertWasReceivedMatches(@"timer:\d{3}\|ms"); }
public void timer_block_sampleRate() { using (CloudInsightStatsd.StartTimer("timer", sampleRate: 1.1)) { Thread.Sleep(200); Thread.Sleep(300); } AssertWasReceivedMatches(@"timer:\d{3}\|ms\|@1\.1"); }
public void timer_block_sampleRate_and_tag() { using (CloudInsightStatsd.StartTimer("timer", sampleRate: 1.1, tags: new[] { "tag1:true", "tag2" })) { Thread.Sleep(200); Thread.Sleep(300); } AssertWasReceivedMatches(@"timer:\d{3}\|ms\|@1\.1\|#tag1:true,tag2"); }
private void testReceive(string testServerName, int testPort, string testCounterName, string expectedOutput) { UdpListener udpListener = new UdpListener(testServerName, testPort); Thread listenThread = new Thread(new ParameterizedThreadStart(udpListener.Listen)); listenThread.Start(); CloudInsightStatsd.Increment(testCounterName); while (listenThread.IsAlive) { ; } Assert.AreEqual(expectedOutput, udpListener.GetAndClearLastMessages()[0]); udpListener.Dispose(); }
public void timer_block_doesnt_swallow_exception_and_submits_metric() { // (Wasn't able to get this working with Assert.Throws) try { using (CloudInsightStatsd.StartTimer("timer")) { throwException(); } Assert.Fail(); } catch (Exception) { AssertWasReceivedMatches(@"timer:\d{3}\|ms"); Assert.Pass(); } }
public void histogram_sample_rate() { CloudInsightStatsd.Histogram("histogram", 42, sampleRate: 1.1); AssertWasReceived("histogram:42|h|@1.1"); }
public void histogram_double() { CloudInsightStatsd.Histogram("histogram", 42.1); AssertWasReceived("histogram:42.1|h"); }
public void histogram_double_sample_rate() { CloudInsightStatsd.Histogram("histogram", 42.1, 1.1); AssertWasReceived("histogram:42.1|h|@1.1"); }
public void timer_method_doesnt_swallow_exception_and_submits_metric() { Assert.Throws <Exception>(() => CloudInsightStatsd.Time(() => throwException(), "somebadcode")); AssertWasReceivedMatches(@"somebadcode:\d{3}\|ms"); }
public void histogram_double_sample_rate_tags() { CloudInsightStatsd.Histogram("histogram", 42.1, sampleRate: 1.1, tags: new[] { "tag1:true,tag2" }); AssertWasReceived("histogram:42.1|h|@1.1|#tag1:true,tag2"); }
public void set_string_sample_rate() { CloudInsightStatsd.Set("set", "string", sampleRate: 1.1); AssertWasReceived("set:string|s|@1.1"); }
public void counter_tags() { CloudInsightStatsd.Counter("counter", 1, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("counter:1|c|#tag1:true,tag2"); }
public void set_double_sample_rate() { CloudInsightStatsd.Set("set", 42.2, sampleRate: 1.1); AssertWasReceived("set:42.2|s|@1.1"); }
public void set_string() { CloudInsightStatsd.Set("set", "string"); AssertWasReceived("set:string|s"); }
public void timer_double_sample_rate_tags() { CloudInsightStatsd.Timer("someevent", 999.99, sampleRate: 1.1, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("someevent:999.99|ms|@1.1|#tag1:true,tag2"); }
public void histogram_tags() { CloudInsightStatsd.Histogram("histogram", 42, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("histogram:42|h|#tag1:true,tag2"); }
public void timer_double() { CloudInsightStatsd.Timer("someevent", 999.99); AssertWasReceived("someevent:999.99|ms"); }
public void timer_tags() { CloudInsightStatsd.Timer("someevent", 999, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("someevent:999|ms|#tag1:true,tag2"); }
public void set_string_sample_rate_tags() { CloudInsightStatsd.Set("set", "string", sampleRate: 12.2, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("set:string|s|@12.2|#tag1:true,tag2"); }
public void set_double_tags() { CloudInsightStatsd.Set("set", 42.2, tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("set:42.2|s|#tag1:true,tag2"); }
public void counter() { CloudInsightStatsd.Counter("counter", 1337); AssertWasReceived("counter:1337|c"); }
public void set_double() { CloudInsightStatsd.Set("set", 42.2); AssertWasReceived("set:42.2|s"); }
public void timer_double_sample_rate() { CloudInsightStatsd.Timer("someevent", 999.99, sampleRate: 1.1); AssertWasReceived("someevent:999.99|ms|@1.1"); }
public void set_string_tags() { CloudInsightStatsd.Set("set", "string", tags: new[] { "tag1:true", "tag2" }); AssertWasReceived("set:string|s|#tag1:true,tag2"); }