diff --git a/src/StatsdClient/DogStatsdService.cs b/src/StatsdClient/DogStatsdService.cs index d8c523c..b8bbe25 100644 --- a/src/StatsdClient/DogStatsdService.cs +++ b/src/StatsdClient/DogStatsdService.cs @@ -154,7 +154,7 @@ public void ServiceCheck(string name, Status status, int? timestamp = null, stri return; } - _statsD.Send(name, (int)status, timestamp, hostname, tags, message); + _statsD.Send(BuildNamespacedStatName(name), (int)status, timestamp, hostname, tags, message); } private string BuildNamespacedStatName(string statName) diff --git a/tests/StatsdClient.Tests/DogStatsdServiceTests.cs b/tests/StatsdClient.Tests/DogStatsdServiceTests.cs index 778ca87..79daf06 100644 --- a/tests/StatsdClient.Tests/DogStatsdServiceTests.cs +++ b/tests/StatsdClient.Tests/DogStatsdServiceTests.cs @@ -140,7 +140,26 @@ public void setting_prefix_starttimer() var metricTimeInMs = Convert.ToInt32(metricTimeInMsSplit[0]); Assert.IsTrue((metricTimeInMs >= 1000), "Processing should have taken at least 1000ms"); Assert.IsTrue((metricTimeInMs < 1100), "Timer reported 10% higher than time taken in action"); - } + } + } + + [Test] + public void setting_prefix_servicecheck() + { + using (var nonStaticServiceInstance = new DogStatsdService()) + { + var metricsConfig = new StatsdConfig + { + StatsdServerName = "127.0.0.1", + StatsdPort = 8129, + Prefix = "prefix" + }; + nonStaticServiceInstance.Configure(metricsConfig); + var receivedData = ReceiveData(nonStaticServiceInstance, "127.0.0.1", 8129, + () => { nonStaticServiceInstance.ServiceCheck("test", Status.OK); }); + + Assert.AreEqual(new List { "_sc|prefix.test|0" }, receivedData); + } } [Test]