Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceCheck metric does not respect configured prefix #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/StatsdClient/DogStatsdService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 20 additions & 1 deletion tests/StatsdClient.Tests/DogStatsdServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> { "_sc|prefix.test|0" }, receivedData);
}
}

[Test]
Expand Down