diff --git a/Publishing/Metrics.NET.nuspec b/Publishing/Metrics.NET.nuspec index 6dac4aad..1a0e9a55 100644 --- a/Publishing/Metrics.NET.nuspec +++ b/Publishing/Metrics.NET.nuspec @@ -1,8 +1,8 @@  - Metrics.NET - 0.3.3-pre + 0.3.3 + Metrics.NET_ntent Metrics.NET iulian.margarintescu Iulian Margarintescu diff --git a/Publishing/Nancy.Metrics.nuspec b/Publishing/Nancy.Metrics.nuspec index 1a093092..a13af3fd 100644 --- a/Publishing/Nancy.Metrics.nuspec +++ b/Publishing/Nancy.Metrics.nuspec @@ -1,8 +1,8 @@  - Nancy.Metrics - 0.3.3-pre + 0.3.3 + Nancy.Metrics_ntent Nancy.Metrics iulian.margarintescu Iulian Margarintescu @@ -15,7 +15,7 @@ http://www.erata.net/Metrics.NET/metrics_32.png nancy, nancyfx, metrics, measurements, charts, timer, histogram, duration, graphite, health checks - + diff --git a/Publishing/Owin.Metrics.nuspec b/Publishing/Owin.Metrics.nuspec index d29f86cb..4dc296c6 100644 --- a/Publishing/Owin.Metrics.nuspec +++ b/Publishing/Owin.Metrics.nuspec @@ -1,8 +1,8 @@ - Owin.Metrics - 0.3.3-pre + 0.3.3 + Owin.Metrics_ntent Owin.Metrics Allan Hardy Iulian Margarintescu @@ -15,7 +15,7 @@ http://www.erata.net/Metrics.NET/metrics_32.png webapi, owin, metrics, measurements, charts, timer, histogram, duration, graphite, health checks - + diff --git a/Src/Metrics/Graphite/GraphiteExtensions.cs b/Src/Metrics/Graphite/GraphiteExtensions.cs index f45d797d..8866149f 100644 --- a/Src/Metrics/Graphite/GraphiteExtensions.cs +++ b/Src/Metrics/Graphite/GraphiteExtensions.cs @@ -6,39 +6,39 @@ namespace Metrics { public static class GraphiteExtensions { - public static MetricsReports WithGraphite(this MetricsReports reports, Uri graphiteUri, TimeSpan interval) + public static MetricsReports WithGraphite(this MetricsReports reports, Uri graphiteUri, TimeSpan interval, bool keysToLowercase = false) { if (graphiteUri.Scheme.ToLowerInvariant() == "net.tcp") { - return reports.WithTCPGraphite(graphiteUri.Host, graphiteUri.Port, interval); + return reports.WithTCPGraphite(graphiteUri.Host, graphiteUri.Port, interval, keysToLowercase); } if (graphiteUri.Scheme.ToLowerInvariant() == "net.udp") { - return reports.WithUDPGraphite(graphiteUri.Host, graphiteUri.Port, interval); + return reports.WithUDPGraphite(graphiteUri.Host, graphiteUri.Port, interval, keysToLowercase); } if (graphiteUri.Scheme.ToLowerInvariant() == "net.pickled") { - return reports.WithPickledGraphite(graphiteUri.Host, graphiteUri.Port, interval); + return reports.WithPickledGraphite(graphiteUri.Host, graphiteUri.Port, interval, keysToLowercase: keysToLowercase); } throw new ArgumentException("Graphite uri scheme must be either net.tcp or net.udp or net.pickled (ex: net.udp://graphite.myhost.com:2003 )", nameof(graphiteUri)); } - public static MetricsReports WithPickledGraphite(this MetricsReports reports, string host, int port, TimeSpan interval, int batchSize = PickleGraphiteSender.DefaultPickleJarSize) + public static MetricsReports WithPickledGraphite(this MetricsReports reports, string host, int port, TimeSpan interval, int batchSize = PickleGraphiteSender.DefaultPickleJarSize, bool keysToLowercase = false) { - return reports.WithGraphite(new PickleGraphiteSender(host, port, batchSize), interval); + return reports.WithGraphite(new PickleGraphiteSender(host, port, batchSize, keysToLowercase), interval); } - public static MetricsReports WithTCPGraphite(this MetricsReports reports, string host, int port, TimeSpan interval) + public static MetricsReports WithTCPGraphite(this MetricsReports reports, string host, int port, TimeSpan interval, bool keysToLowercase = false) { - return reports.WithGraphite(new TcpGraphiteSender(host, port), interval); + return reports.WithGraphite(new TcpGraphiteSender(host, port, keysToLowercase), interval); } - public static MetricsReports WithUDPGraphite(this MetricsReports reports, string host, int port, TimeSpan interval) + public static MetricsReports WithUDPGraphite(this MetricsReports reports, string host, int port, TimeSpan interval, bool keysToLowercase = false) { - return reports.WithGraphite(new UdpGraphiteSender(host, port), interval); + return reports.WithGraphite(new UdpGraphiteSender(host, port, keysToLowercase), interval); } public static MetricsReports WithGraphite(this MetricsReports reports, GraphiteSender graphiteLink, TimeSpan interval) diff --git a/Src/Metrics/Graphite/PickleGraphiteSender.cs b/Src/Metrics/Graphite/PickleGraphiteSender.cs index e0f006b3..cb6c2d24 100644 --- a/Src/Metrics/Graphite/PickleGraphiteSender.cs +++ b/Src/Metrics/Graphite/PickleGraphiteSender.cs @@ -16,20 +16,24 @@ public sealed class PickleGraphiteSender : GraphiteSender private readonly int port; private readonly int pickleJarSize; + private readonly bool _keysToLowercase; private TcpClient client; private PickleJar jar = new PickleJar(); - public PickleGraphiteSender(string host, int port, int batchSize = DefaultPickleJarSize) + public PickleGraphiteSender(string host, int port, int batchSize = DefaultPickleJarSize, bool keysToLowercase = false) { this.host = host; this.port = port; this.pickleJarSize = batchSize; + _keysToLowercase = keysToLowercase; } public override void Send(string name, string value, string timestamp) { + if (_keysToLowercase) + name = name.ToLower(); this.jar.Append(name, value, timestamp); if (jar.Size >= this.pickleJarSize) diff --git a/Src/Metrics/Graphite/TcpGraphiteSender.cs b/Src/Metrics/Graphite/TcpGraphiteSender.cs index f6b07141..32435494 100644 --- a/Src/Metrics/Graphite/TcpGraphiteSender.cs +++ b/Src/Metrics/Graphite/TcpGraphiteSender.cs @@ -13,13 +13,15 @@ public sealed class TcpGraphiteSender : GraphiteSender private readonly string host; private readonly int port; + private readonly bool _keysToLowercase; private TcpClient client; - public TcpGraphiteSender(string host, int port) + public TcpGraphiteSender(string host, int port, bool keysToLowercase) { this.host = host; this.port = port; + _keysToLowercase = keysToLowercase; } protected override void SendData(string data) @@ -31,6 +33,9 @@ protected override void SendData(string data) this.client = InitClient(this.host, this.port); } + if (_keysToLowercase) + data = data.ToLower(); + var bytes = Encoding.UTF8.GetBytes(data); this.client.GetStream().Write(bytes, 0, bytes.Length); diff --git a/Src/Metrics/Graphite/UdpGraphiteSender.cs b/Src/Metrics/Graphite/UdpGraphiteSender.cs index 22cf8998..81340f67 100644 --- a/Src/Metrics/Graphite/UdpGraphiteSender.cs +++ b/Src/Metrics/Graphite/UdpGraphiteSender.cs @@ -13,13 +13,15 @@ public sealed class UdpGraphiteSender : GraphiteSender private readonly string host; private readonly int port; + private readonly bool _keysToLowercase; private UdpClient client; - public UdpGraphiteSender(string host, int port) + public UdpGraphiteSender(string host, int port, bool keysToLowercase) { this.host = host; this.port = port; + _keysToLowercase = keysToLowercase; } protected override void SendData(string data) @@ -31,6 +33,9 @@ protected override void SendData(string data) this.client = InitClient(this.host, this.port); } + if (_keysToLowercase) + data = data.ToLower(); + var bytes = Encoding.UTF8.GetBytes(data); this.client.Send(bytes, bytes.Length); }