Beispiel #1
0
        private Telemetry CreateTelemetry(
            MetricSerializer metricSerializer,
            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(metricSerializer, version, telemetryFlush.Value, telemetryTransport, globalTags));
            }

            // Telemetry is not enabled
            return(new Telemetry());
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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 ITransport CreateUDPTransport(DogStatsdEndPoint endPoint)
        {
#pragma warning disable 618
            // MANUAL CHANGE: Obsolete ignore because this is internal code
            var address = StatsdUDP.GetIpv4Address(endPoint.ServerName);
#pragma warning restore 618
            var port = endPoint.Port;

            var ipEndPoint = new System.Net.IPEndPoint(address, port);
            return(_factory.CreateUDPTransport(ipEndPoint));
        }
Beispiel #5
0
        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);
        }