public void udp_listener_sanity_test() { var client = new StatsdUDP(_localhostAddress, _randomUnusedLocalPort); client.Send("iamnotinsane!"); Assert.That(LastPacketMessageReceived(), Is.EqualTo("iamnotinsane!")); }
public void SetUpUdpListenerAndStatsd() { udpListener = new UdpListener(serverName, serverPort); var metricsConfig = new MetricsConfig { StatsdServerName = serverName }; StatsdClient.Metrics.Configure(metricsConfig); udp = new StatsdUDP(serverName, serverPort); statsd = new Statsd(udp); }
/// <summary> /// Construct a sink that uses datadog with the specified details. /// </summary> /// <param name="datadogConfiguration">Connection information used to construct the Datadog client.</param> /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> /// <param name="textFormatter">Supplies culture-specific formatting information, or null.</param> public DatadogSink(DatadogConfiguration datadogConfiguration, int batchSizeLimit, TimeSpan period, ITextFormatter textFormatter) : base(batchSizeLimit, period) { if (datadogConfiguration == null) throw new ArgumentNullException("datadogConfiguration"); _datadogConfiguration = datadogConfiguration; _textFormatter = textFormatter; _statsdUdp = new StatsdUDP(datadogConfiguration.StatsdServer, datadogConfiguration.StatsdPort); _statsd = new Statsd(_statsdUdp); }
public void Sends_a_counter() { try { var client = new StatsdUDP(ServerName, ServerPort); client.Send("udp_integration_test:1|c"); } catch(SocketException) { Assert.Fail("Socket Exception, have you set up your Statsd name and port?"); } }
public void Sends_a_counter() { try { var client = new StatsdUDP(ServerName, ServerPort); client.Send("socket2:1|c"); } catch(SocketException ex) { Assert.Fail("Socket Exception, have you set up your Statsd name and port? Error: {0}", ex.Message); } }
public void Sends_a_counter() { try { var client = new StatsdUDP(_serverName, _serverPort); client.Send("socket2:1|c"); } catch(SocketException ex) { Assert.Fail("Socket Exception, have you setup your Statsd name and port? It's currently '{0}:{1}'. Error: {2}", _serverName, _serverPort, ex.Message); } }
private static void CreateStatsD(MetricsConfig config) { if (_statsdUdp != null) { _statsdUdp.Dispose(); } _statsdUdp = null; if (!string.IsNullOrEmpty(config.StatsdServerName)) { _statsdUdp = new StatsdUDP(config.StatsdServerName, config.StatsdServerPort, config.StatsdMaxUDPPacketSize); _statsD = new Statsd(_statsdUdp); } }
private static void CreateStatsD(MetricsConfig config) { if (_statsdUdp != null) { _statsdUdp.Dispose(); } _statsdUdp = null; if (!string.IsNullOrEmpty(config.StatsdServerName)) { _statsdUdp = new StatsdUDP(config.StatsdServerName, config.StatsdServerPort, config.StatsdMaxUDPPacketSize); _statsD = new Statsd(new Statsd.Configuration() { Udp = _statsdUdp, Sender = config.Sender, Prefix = _prefix, GlobalTags = config.GlobalTags, TagScopes = _tagScopes }); } }
public void Configure(StatsdConfig config) { if (config == null) { throw new ArgumentNullException("config"); } if (_config != null) { throw new InvalidOperationException("Configuration for DogStatsdService already performed"); } _config = config; _prefix = config.Prefix; var statsdServerName = !string.IsNullOrEmpty(config.StatsdServerName) ? config.StatsdServerName : Environment.GetEnvironmentVariable(StatsdConfig.DD_AGENT_HOST_ENV_VAR); if (!string.IsNullOrEmpty(statsdServerName)) { IStatsdUDP statsdSender; if (statsdServerName.StartsWith(StatsdUnixDomainSocket.UnixDomainSocketPrefix)) { var statsdUds = new StatsdUnixDomainSocket(statsdServerName, config.StatsdMaxUnixDomainSocketPacketSize); _disposable = statsdUds; statsdSender = statsdUds; } else { var statsUdp = new StatsdUDP(config.StatsdServerName, config.StatsdPort, config.StatsdMaxUDPPacketSize); _disposable = statsUdp; statsdSender = statsUdp; } _statsD = new Statsd(statsdSender, new RandomGenerator(), new StopWatchFactory(), "", config.ConstantTags); _statsD.TruncateIfTooLong = config.StatsdTruncateIfTooLong; } else { throw new ArgumentNullException("config.StatsdServername and DD_AGENT_HOST environment variable not set"); } }
public void Configure(dynamic configuration) { try { DisposeDependencies(); //IResolveCounterType resolver, Uri endpoint, int maxUdpPacket = 512 _connection = new StatsdUDP(configuration.Host.ToString(), (int)configuration.Port, (int)configuration.MaxUdpPacket); _sender = new Statsd(_connection); _resolver = new RegexResolver(); foreach (var map in configuration.CounterTypeMaps) { _resolver.Add(map.Regex.ToString(), Enum.Parse(typeof(StatsDTypes),map.Type.ToString())); } } catch (Exception ex) { Logger.ErrorFormat("Error configuring StatsDSink, check your configuration file! Exception:{@exception}",ex); throw; } }
public void Configure(StatsdConfig config) { if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(config.StatsdServerName)) { throw new ArgumentNullException("config.StatsdServername"); } _prefix = config.Prefix; Dispose(); if (!string.IsNullOrEmpty(config.StatsdServerName)) { var statsdUdp = new StatsdUDP(config.StatsdServerName, config.StatsdPort, config.StatsdMaxUDPPacketSize); _statsD = new Statsd(statsdUdp); _disposable = statsdUdp; } }
public void _udp_listener_sanity_test() { var client = new StatsdUDP(ConfigurationManager.AppSettings["StatsdServerName"], Convert.ToInt32(ConfigurationManager.AppSettings["StatsdServerPort"])); client.Send("iamnotinsane!"); AssertWasReceived("iamnotinsane!"); }
public void set_max_udp_packet_size() { // Make sure that we can set the max UDP packet size udp = new StatsdUDP(serverName, serverPort, 10); statsd = new Statsd(udp); var msg = new String('f', 5); listenThread.Start(2); statsd.Add<Statsd.Counting>(msg, 1); statsd.Add<Statsd.Timing>(msg, 2); statsd.Send(); // Since our packet size limit is now 10, this (short) message should still be split AssertWasReceived(String.Format("{0}:1|c", msg), 0); AssertWasReceived(String.Format("{0}:2|ms", msg), 1); }
public void ipv4_parsing_works_with_ip() { var statsdUdp = new StatsdUDP("127.0.0.1", RandomUnusedLocalPort); Assert.That(statsdUdp.IPEndpoint.Address.ToString(), Is.StringContaining("127.0.0.1")); }
public void ipv4_parsing_works_with_hostname() { StatsdUDP statsdUDP = new StatsdUDP("localhost", RandomUnusedLocalPort); Assert.That(statsdUDP.IPEndpoint.Address.ToString(),Is.StringContaining("127.0.0.1")); }
public StatsDSink(RegexResolver resolver, Uri uri,int maxUdpPacketSize=512) { _resolver = resolver; _connection = new StatsdUDP(uri.Host, uri.Port, maxUdpPacketSize); }
public void SetUpUdpListenerAndStatsd() { udpListener = new UdpListener(serverName, serverPort); udp = new StatsdUDP(serverName, serverPort); }