private ITransport CreateTransport(DogStatsdEndPoint endPoint, StatsdConfig config) { var serverName = endPoint.ServerName; if (!string.IsNullOrEmpty(serverName)) { if (serverName.StartsWith(UnixDomainSocketPrefix)) { serverName = serverName.Substring(UnixDomainSocketPrefix.Length); var unixEndPoint = new UnixEndPoint(serverName); return(_factory.CreateUnixDomainSocketTransport( unixEndPoint, config.Advanced.UDSBufferFullBlockDuration)); } return(CreateUDPTransport(endPoint)); } var pipeName = endPoint.PipeName; if (string.IsNullOrEmpty(pipeName)) { throw new ArgumentException($"Error: empty {nameof(DogStatsdEndPoint)}"); } return(_factory.CreateNamedPipeTransport(pipeName)); }
private Telemetry CreateTelemetry( StatsdConfig config, string[] globalTags, DogStatsdEndPoint dogStatsdEndPoint, ITransport transport) { var telemetryFlush = config.Advanced.TelemetryFlushInterval; if (telemetryFlush.HasValue) { var assembly = typeof(StatsdBuilder).GetTypeInfo().Assembly; var version = assembly.GetName().Version.ToString(); var optionalTelemetryEndPoint = config.Advanced.OptionalTelemetryEndPoint; ITransport telemetryTransport = transport; if (optionalTelemetryEndPoint != null && !dogStatsdEndPoint.AreEquals(optionalTelemetryEndPoint)) { telemetryTransport = CreateTransport(optionalTelemetryEndPoint, config); } return(_factory.CreateTelemetry(version, telemetryFlush.Value, telemetryTransport, globalTags)); } // Telemetry is not enabled return(new Telemetry()); }
private ITransport CreateUDPTransport(DogStatsdEndPoint endPoint) { var address = StatsdUDP.GetIpv4Address(endPoint.ServerName); var port = endPoint.Port; var ipEndPoint = new System.Net.IPEndPoint(address, port); return _factory.CreateUDPTransport(ipEndPoint); }
private TransportData CreateTransportData(DogStatsdEndPoint endPoint, StatsdConfig config) { var transportData = new TransportData(); transportData.Transport = CreateTransport(endPoint, config); switch (transportData.Transport.TransportType) { case TransportType.UDP: transportData.BufferCapacity = config.StatsdMaxUDPPacketSize; break; case TransportType.UDS: transportData.BufferCapacity = config.StatsdMaxUnixDomainSocketPacketSize; break; // use StatsdMaxUDPPacketSize for named pipe case TransportType.NamedPipe: transportData.BufferCapacity = config.StatsdMaxUDPPacketSize; break; default: throw new NotSupportedException(); } return transportData; }