public async Task PacketsDropped()
        {
            using (var temporaryPath = new TemporaryPath())
            {
                using (var server = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.IP))
                {
                    var endPoint = new UnixEndPoint(temporaryPath.Path);
                    server.Bind(endPoint);

                    var serverName = StatsdBuilder.UnixDomainSocketPrefix + temporaryPath.Path;
                    _service.Configure(new StatsdConfig {
                        StatsdServerName = serverName
                    });

                    for (int i = 0; i < 10000; ++i)
                    {
                        _service.Increment("test");
                    }

                    await Task.Delay(TimeSpan.FromMilliseconds(500));

                    Assert.Greater(_service.TelemetryCounters.PacketsDropped, 1);
                    Assert.Greater(_service.TelemetryCounters.BytesDropped, 8);
                    _service.Dispose();
                }
            }
        }
        private static DogStatsdService CreateService(
            TemporaryPath temporaryPath,
            HostnameProvider hostnameProvider = HostnameProvider.Property)
        {
            var serverName      = StatsdBuilder.UnixDomainSocketPrefix + temporaryPath.Path;
            var dogstatsdConfig = new StatsdConfig {
                StatsdMaxUnixDomainSocketPacketSize = 1000
            };

            switch (hostnameProvider)
            {
            case HostnameProvider.Property: dogstatsdConfig.StatsdServerName = serverName; break;

            case HostnameProvider.Environment:
            {
                Environment.SetEnvironmentVariable(StatsdConfig.AgentHostEnvVar, serverName);
                break;
            }
            }

            var dogStatsdService = new DogStatsdService();

            dogStatsdService.Configure(dogstatsdConfig);

            return(dogStatsdService);
        }
        private static Socket CreateSocketServer(TemporaryPath temporaryPath)
        {
            var endPoint = new UnixEndPoint(temporaryPath.Path);
            var server   = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified);

            server.Bind(endPoint);

            return(server);
        }
 public void UDSReconnection()
 {
     using (var temporaryPath = new TemporaryPath())
     {
         CheckReconnection(new StatsdConfig
         {
             StatsdServerName = StatsdBuilder.UnixDomainSocketPrefix + temporaryPath.Path,
         });
     }
 }
Esempio n. 5
0
        public string TPath()
        {
            string TemporaryPath;

            TemporaryPath  = Application.StartupPath.ToString();
            TemporaryPath  = TemporaryPath.Substring(0, TemporaryPath.LastIndexOf("\\"));
            TemporaryPath  = TemporaryPath.Substring(0, TemporaryPath.LastIndexOf("\\"));
            TemporaryPath += @"\TemporaryFolder";
            return(TemporaryPath);
        }
Esempio n. 6
0
        public void UnixDomainSocketBlockingQueue()
        {
            var metricToSendCount = 100 * 1000;

            using (var temporaryPath = new TemporaryPath())
            {
                var config = new StatsdConfig
                {
                    StatsdServerName = StatsdBuilder.UnixDomainSocketPrefix + temporaryPath.Path,
                };
                config.Advanced.MaxBlockDuration           = TimeSpan.FromSeconds(3);
                config.Advanced.UDSBufferFullBlockDuration = TimeSpan.FromSeconds(3);
                config.Advanced.MaxMetricsInAsyncQueue     = metricToSendCount / 10;

                SendAndCheckMetricsAreReceived(config, metricToSendCount);
            }
        }
 public void Setup()
 {
     _temporaryPath = new TemporaryPath();
 }