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("Authorization", builder.AuthenticationHeaderValue.ToString());
            }

            var customProperties = new Dictionary <string, object>
            {
                // Note: This ensures that internal requests from the tracer are not instrumented
                // by https://github.com/opentracing-contrib/csharp-netcore
                { "ot-ignore", true }
            };

            _transport = new THttpClientTransport(collectorUri, customHeaders, customProperties);
            _protocol  = ProtocolFactory.GetProtocol(_transport);
        }
示例#2
0
        internal JaegerThriftHttpSender(Uri uri) : base(new TBinaryProtocol.Factory())
        {
            var collectorUri = new UriBuilder(uri)
            {
                Query = TransportConstants.CollectorHttpJaegerThriftFormatParam
            }.Uri;
            var httpTransport = new THttpClientTransport(collectorUri, null);

            _protocol = ProtocolFactory.GetProtocol(httpTransport);
        }
        /// <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));
        }
        /// <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));
        }
示例#5
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));
        }
示例#7
0
 public int GetSize(TBase thriftBase)
 {
     _memoryTransport.Reset();
     thriftBase.WriteAsync(ProtocolFactory.GetProtocol(_memoryTransport), CancellationToken.None).GetAwaiter().GetResult();
     return(_memoryTransport.GetBuffer().Length);
 }