/// <param name="host">If empty it will use <see cref="DefaultAgentUdpHost"/>.</param>
        /// <param name="port">If 0 it will use <see cref="DefaultAgentUdpCompactPort"/>.</param>
        /// <param name="maxPacketSize">If 0 it will use <see cref="ThriftUdpClientTransport.MaxPacketSize"/>.</param>
        public UdpSender(string host, int port, int maxPacketSize)
            : base(ProtocolType.Compact, maxPacketSize)
        {
            if (string.IsNullOrEmpty(host))
            {
                host = DefaultAgentUdpHost;
            }

            if (port == 0)
            {
                port = DefaultAgentUdpCompactPort;
            }

            _udpTransport = new ThriftUdpClientTransport(host, port);
            _agentClient  = new Agent.Client(ProtocolFactory.GetProtocol(_udpTransport));
        }
示例#2
0
        /// <param name="host">Host</param>
        /// <param name="port">Port</param>
        public JaegerThriftUdpSender(string host, int port) : base(new TCompactProtocol.Factory())
        {
            if (string.IsNullOrEmpty(host))
            {
                host = TransportConstants.DefaultAgentHost;
            }

            if (port == 0)
            {
                port = TransportConstants.DefaultAgentUdpJaegerCompactThriftPort;
            }

            var udpThriftTransport = new ThriftUdpClientTransport(host, port);

            _agentClient = new Agent.Client(_protocolFactory.GetProtocol(udpThriftTransport));
        }
示例#3
0
        private HttpSender(Builder builder)
            : base(ProtocolType.Binary, builder.MaxPacketSize)
        {
            Uri collectorUri = new UriBuilder(builder.Endpoint)
            {
                Query = HttpCollectorJaegerThriftFormatParam
            }.Uri;

            var customHeaders = new Dictionary <string, string>();

            if (builder.AuthenticationHeaderValue != null)
            {
                customHeaders.Add("Authorize", builder.AuthenticationHeaderValue.ToString());
            }

            _transport   = new THttpClientTransport(collectorUri, customHeaders);
            _agentClient = new Agent.Client(ProtocolFactory.GetProtocol(_transport));
        }
        /// <param name="host">If empty it will use <see cref="DefaultAgentUdpHost"/>.</param>
        /// <param name="port">If 0 it will use <see cref="DefaultAgentUdpCompactPort"/>.</param>
        /// <param name="maxPacketSize">If 0 it will use <see cref="ThriftUdpClientTransport.MaxPacketSize"/>. Must not exceed <see cref="ThriftUdpClientTransport.MaxPacketSize"/>.</param>
        public UdpSender(string host, int port, int maxPacketSize)
            : base(ProtocolType.Compact, maxPacketSize)
        {
            if (string.IsNullOrEmpty(host))
            {
                host = DefaultAgentUdpHost;
            }

            if (port == 0)
            {
                port = DefaultAgentUdpCompactPort;
            }

            if (maxPacketSize > ThriftUdpClientTransport.MaxPacketSize)
            {
                throw new NotSupportedException($"Using a packet size bigger than {ThriftUdpClientTransport.MaxPacketSize} "
                                                + "can lead to lost traces and is therefore not supported.");
            }

            _udpTransport = new ThriftUdpClientTransport(host, port);
            _agentClient  = new Agent.Client(ProtocolFactory.GetProtocol(_udpTransport));
        }
示例#5
0
        public async void EmitBatchOverhead_ShouldNotGoOverOverheadConstant()
        {
            var transport       = new TMemoryBuffer();
            var protocolFactory = new TCompactProtocol.Factory();
            var client          = new Agent.Client(protocolFactory.GetProtocol(transport));

            var jSpan     = new JaegerSpan(10, 11, 12, 13, "opName", 0, 1234, 1235);
            var jSpanSize = CalcSizeOfSerializedThrift(jSpan);

            var tests = new[] { 1, 2, 14, 15, 377, 500, 65000, 0xFFFF };

            foreach (var test in tests)
            {
                transport.Reset();
                var batch       = new List <JaegerSpan>();
                var processTags = new List <JaegerTag>();
                for (var j = 0; j < test; j++)
                {
                    batch.Add(jSpan);
                    processTags.Add(new JaegerTag("testingTag", TagType.BINARY)
                    {
                        VBinary = new byte[] { 0x20 }
                    });
                }

                var jProcess = new JaegerProcess("testing")
                {
                    Tags = processTags
                };
                await client.emitBatchAsync(new JaegerBatch(jProcess, batch), CancellationToken.None);

                var jProcessSize = CalcSizeOfSerializedThrift(jProcess);

                var overhead = transport.GetBuffer().Length - test * jSpanSize - jProcessSize;
                Assert.True(overhead <= TransportConstants.UdpEmitBatchOverhead);
            }
        }
示例#6
0
 public UdpSender(string processName, AgentJaegerTraceTransportOptions options)
     : base(processName, ProtocolType.Compact, options.MaxPacketSizeBytes)
 {
     this.udpTransport = new ThriftUdpClientTransport(options.Host, options.Port);
     this.agentClient  = new Agent.Client(this.ProtocolFactory.GetProtocol(this.udpTransport));
 }