public void Set() { using (var stats = new UdpStatsifyClient("127.0.0.1", Port, "Telemetry.tests.")) { AssertDatagram(Port, "Telemetry.tests.sample_timer:a|s", () => stats.Set("sample_timer", "a")); AssertDatagram(Port, "Telemetry.tests.sample_timer:b|s", () => stats.Set("sample_timer", "b")); } // using }
public void Timer() { using (var stats = new UdpStatsifyClient("127.0.0.1", Port, "Telemetry.tests.")) { AssertDatagram(Port, "Telemetry.tests.sample_timer:3.5|ms", () => stats.Time("sample_timer", 3.5)); AssertDatagram(Port, "Telemetry.tests.sample_timer:1|ms", () => stats.Time(".sample_timer.", 1)); } // using }
public void Gauge() { using (var stats = new UdpStatsifyClient("127.0.0.1", Port, "Telemetry.tests.")) { AssertDatagram(Port, "Telemetry.tests.sample_gauge:300.05|g", () => stats.Gauge("sample_gauge", 300.05)); AssertDatagram(Port, "Telemetry.tests.sample_gauge:1|g", () => stats.Gauge(".sample_gauge.", 1)); } // using }
public void Increment() { using (var stats = new UdpStatsifyClient(port: Port)) { stats.Increment("sample_counter"); AssertDatagram(Port, "sample_counter:1|c", () => stats.Increment("sample_counter")); } }
public void Annotation() { using (var stats = new UdpStatsifyClient(port: Port)) { AssertDatagram(Port, Encoding.UTF8.GetBytes("datagram:annotation-v1:\n\0\0\0Deployment" + (char)24 + "\0\0\0Statsify Core Deployment"), () => stats.Annotation("Deployment", "Statsify Core Deployment")); } }
public override int Execute(MetricCommandOptions options, Arguments args) { var server = Server; if (server.Port == 0) { server = new Endpoint(server.Address, UdpStatsifyClient.DefaultPort); } using (var statsifyClient = new UdpStatsifyClient(server.Address, server.Port)) { var value = TryParseFloat(Value); switch (options.Type) { case MetricType.Counter: if (!value.HasValue) { return(1); } statsifyClient.Counter(Name, value.Value); break; case MetricType.Timer: if (!value.HasValue) { return(1); } statsifyClient.Time(Name, value.Value); break; case MetricType.Gauge: if (!value.HasValue) { return(1); } statsifyClient.Gauge(Name, value.Value); break; case MetricType.Set: statsifyClient.Set(Name, Value); break; default: throw new ArgumentOutOfRangeException(); } // switch } // using return(0); }
public void GaugeDiff() { using (var stats = new UdpStatsifyClient("127.0.0.1", Port, "Telemetry.tests.")) { AssertDatagram(Port, "Telemetry.tests.sample_gauge:+3.0055|g", () => stats.GaugeDiff("sample_gauge", 3.0055)); AssertDatagram(Port, "Telemetry.tests.sample_gauge:-3.0055|g", () => stats.GaugeDiff("sample_gauge", -3.0055)); AssertDatagram(Port, "Telemetry.tests.sample_gauge:+1|g", () => stats.GaugeDiff(".sample_gauge.", 1)); AssertDatagram(Port, "Telemetry.tests.sample_gauge:-1|g", () => stats.GaugeDiff(".sample_gauge.", -1)); AssertDatagram(Port, "Telemetry.tests.sample_gauge:+0|g", () => stats.GaugeDiff(".sample_gauge.", 0)); } // using }