public static void SocketTransportCanSendOverIPWithoutError() { using (var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.IP)) { transport.Send("teststat:1|c"); } }
public static void SocketTransportIsNoopForEmptyArray() { using (var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.IP)) { transport.Send(new ArraySegment <byte>(Array.Empty <byte>())); } }
public static void SocketTransportCanSendOverUdpWithoutError() { // using block not used here so the finalizer gets some code coverage var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp); transport.Send("teststat:1|c"); }
public static void ValidSocketTransportCanBeConstructed() { using (var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp)) { transport.ShouldNotBeNull(); } }
public static void SocketTransportIsNoopForNullEndpoint() { var endpointSource = Mock.Of <IEndPointSource>(); using var transport = new SocketTransport(endpointSource, SocketProtocol.IP); transport.Send("teststat:1|c"); }
public static void SocketTransportCanSendOverUdpWithoutError() { // Using block not used here so the finalizer gets some code coverage #pragma warning disable CA2000 var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp); #pragma warning restore CA2000 transport.Send("teststat:1|c"); }
public void AMetricCanBeSentWithoutAnExceptionBeingThrown() { // Arrange var endPointSource = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointA, null); using var target = new SocketTransport(endPointSource, SocketProtocol.Udp); // Act and Assert target.Send("mycustommetric"); }
public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownParallel() { // Arrange var endPointSource = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointA, null); using var target = new SocketTransport(endPointSource, SocketProtocol.Udp); Parallel.For(0, 10_000, _ => { // Act and Assert target.Send("mycustommetric:1|c"); }); }
public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownSerial() { // Arrange var endPointSource = EndpointParser.MakeEndPointSource( UdpListeners.EndpointA, null); using (var target = new SocketTransport(endPointSource, SocketProtocol.Udp)) { for (int i = 0; i < 10_000; i++) { // Act and Assert target.Send("mycustommetric:1|c"); } } }
public static void EndpointSwitchShouldNotCauseExceptionsParallel() { // Arrange var endPointSource1 = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointA, null); var endPointSource2 = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointB, null); using var target = new SocketTransport(new MillisecondSwitcher(endPointSource2, endPointSource1), SocketProtocol.Udp); Parallel.For(0, 10_000, _ => { // Act and Assert target.Send("mycustommetric"); }); }
public static void EndpointSwitchShouldNotCauseExceptionsSequential() { // Arrange var endPointSource1 = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointA, null); var endPointSource2 = EndPointFactory.MakeEndPointSource( UdpListeners.EndpointB, null); using var target = new SocketTransport(new MillisecondSwitcher(endPointSource2, endPointSource1), SocketProtocol.Udp); for (int i = 0; i < 10_000; i++) { // Act and Assert target.Send("mycustommetric:1|c"); } }
/// <summary> /// Initializes a new instance of the <see cref="StatsDPublisher"/> class using the default transport. /// </summary> /// <param name="configuration">The StatsD configuration to use.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="configuration"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="configuration"/> is invalid, such as an invalid hostname or IP address. /// </exception> public StatsDPublisher(StatsDConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(configuration.Host)) { throw new ArgumentException("No hostname or IP address is set.", nameof(configuration)); } var endpointSource = EndPointFactory.MakeEndPointSource( configuration.Host !, configuration.Port, configuration.DnsLookupInterval); var transport = new SocketTransport(endpointSource, configuration.SocketProtocol); _transport = transport; _disposeTransport = true; _inner = new BufferBasedStatsDPublisher(configuration, transport); }
public static void SocketTransportIsNoopForNullArray() { using var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.IP); transport.Send(new ArraySegment <byte>()); }
public static void SocketTransportCanSendOverUdpWithoutError() { var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp); transport.Send("teststat:1|c"); }