Exemplo n.º 1
0
        public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory inputProtocolFactory,
                                    ITProtocolFactory outputProtocolFactory, RequestDelegate next, ILoggerFactory loggerFactory)
        {
            if (processor == null)
            {
                throw new ArgumentNullException(nameof(processor));
            }

            if (inputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(inputProtocolFactory));
            }

            if (outputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(outputProtocolFactory));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            Processor             = processor;
            InputProtocolFactory  = inputProtocolFactory;
            OutputProtocolFactory = outputProtocolFactory;

            _next   = next;
            _logger = loggerFactory.CreateLogger <THttpServerTransport>();
        }
Exemplo n.º 2
0
        private bool disposedValue = false; // To detect redundant calls

        public JaegerUdpBatcher(JaegerExporterOptions options)
        {
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.MaxFlushInterval <= TimeSpan.Zero)
            {
                options.MaxFlushInterval = TimeSpan.FromSeconds(10);
            }

            this.maxPacketSize   = (!options.MaxPacketSize.HasValue || options.MaxPacketSize == 0) ? JaegerExporterOptions.DefaultMaxPacketSize : options.MaxPacketSize.Value;
            this.protocolFactory = new TCompactProtocol.Factory();
            this.clientTransport = new JaegerThriftClientTransport(options.AgentHost, options.AgentPort);
            this.thriftClient    = new JaegerThriftClient(this.protocolFactory.GetProtocol(this.clientTransport));
            this.Process         = new Process(options.ServiceName, options.ProcessTags);

            this.maxFlushInterval      = options.MaxFlushInterval;
            this.maxFlushIntervalTimer = new System.Timers.Timer
            {
                AutoReset = false,
                Enabled   = false,
                Interval  = this.maxFlushInterval.TotalMilliseconds,
            };

            this.maxFlushIntervalTimer.Elapsed += async(sender, args) =>
            {
                await this.FlushAsyncInternal(false, CancellationToken.None).ConfigureAwait(false);
            };
        }
Exemplo n.º 3
0
        public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory inputProtocolFactory,
            ITProtocolFactory outputProtocolFactory, RequestDelegate next, ILoggerFactory loggerFactory)
        {
            if (processor == null)
            {
                throw new ArgumentNullException(nameof(processor));
            }

            if (inputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(inputProtocolFactory));
            }

            if (outputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(outputProtocolFactory));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            Processor = processor;
            InputProtocolFactory = inputProtocolFactory;
            OutputProtocolFactory = outputProtocolFactory;

            _next = next;
            _logger = loggerFactory.CreateLogger<THttpServerTransport>();
        }
Exemplo n.º 4
0
        public JaegerThriftTransportTests()
        {
            _mockJaegerThriftSerialization = Substitute.For <ISerialization>();
            _mockProtocolFactory           = Substitute.For <ITProtocolFactory>();
            _mockSender = Substitute.For <ISender>();

            _testingTransport = Substitute.For <JaegerThriftTransport>(_mockProtocolFactory, _mockSender, _mockJaegerThriftSerialization, _bufferSize);
        }
Exemplo n.º 5
0
 public AsyncBaseServer(ITAsyncProcessor processor, TServerTransport serverTransport,
                        ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
                        ILoggerFactory loggerFactory, int clientWaitingDelay = 10)
     : this(new SingletonTProcessorFactory(processor), serverTransport,
            new TTransportFactory(), new TTransportFactory(),
            inputProtocolFactory, outputProtocolFactory,
            loggerFactory.CreateLogger(nameof(AsyncBaseServer)), clientWaitingDelay)
 {
 }
Exemplo n.º 6
0
 public AsyncBaseServer(ITProcessorFactory itProcessorFactory, TServerTransport serverTransport,
                        TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
                        ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
                        ILogger logger, int clientWaitingDelay = 10)
     : base(itProcessorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
            inputProtocolFactory, outputProtocolFactory, logger)
 {
     _clientWaitingDelay = clientWaitingDelay;
 }
Exemplo n.º 7
0
 public AsyncBaseServer(ITProcessorFactory itProcessorFactory, TServerTransport serverTransport,
     TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
     ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
     ILogger logger, int clientWaitingDelay = 10)
     : base(itProcessorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
         inputProtocolFactory, outputProtocolFactory, logger)
 {
     _clientWaitingDelay = clientWaitingDelay;
 }
Exemplo n.º 8
0
 public AsyncBaseServer(ITAsyncProcessor processor, TServerTransport serverTransport,
     ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
     ILoggerFactory loggerFactory, int clientWaitingDelay = 10)
     : this(new SingletonTProcessorFactory(processor), serverTransport,
         new TTransportFactory(), new TTransportFactory(),
         inputProtocolFactory, outputProtocolFactory,
         loggerFactory.CreateLogger(nameof(AsyncBaseServer)), clientWaitingDelay)
 {
 }
Exemplo n.º 9
0
 public TThreadPoolAsyncServer(ITAsyncProcessor processor,
                               TServerTransport serverTransport,
                               TTransportFactory transportFactory,
                               ITProtocolFactory protocolFactory)
     : this(new TSingletonProcessorFactory(processor), serverTransport,
            transportFactory, transportFactory,
            protocolFactory, protocolFactory,
            new Configuration())
 {
 }
Exemplo n.º 10
0
 public TThreadPoolAsyncServer(ITProcessorFactory processorFactory,
                               TServerTransport serverTransport,
                               TTransportFactory transportFactory,
                               ITProtocolFactory protocolFactory)
     : this(processorFactory, serverTransport,
            transportFactory, transportFactory,
            protocolFactory, protocolFactory,
            new Configuration())
 {
 }
        private bool disposedValue = false; // To detect redundant calls

        public JaegerUdpBatcher(JaegerExporterOptions options)
        {
            this.maxPacketSize   = options.MaxPacketSize == 0 ? DefaultMaxPacketSize : options.MaxPacketSize;
            this.protocolFactory = new TCompactProtocol.Factory();
            this.clientTransport = new JaegerThriftClientTransport(options.AgentHost, options.AgentPort.Value);
            this.thriftClient    = new JaegerThriftClient(this.protocolFactory.GetProtocol(this.clientTransport));
            this.process         = new Process(options.ServiceName, options.ProcessTags);
            this.processByteSize = this.GetSize(this.process);
            this.batchByteSize   = this.processByteSize;
        }
Exemplo n.º 12
0
 protected TBaseServer(ITProcessorFactory itProcessorFactory, TServerTransport serverTransport,
                       TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
                       ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory)
 {
     ItProcessorFactory     = itProcessorFactory ?? throw new ArgumentNullException(nameof(itProcessorFactory));
     ServerTransport        = serverTransport;
     InputTransportFactory  = inputTransportFactory ?? throw new ArgumentNullException(nameof(inputTransportFactory));
     OutputTransportFactory = outputTransportFactory ?? throw new ArgumentNullException(nameof(outputTransportFactory));
     InputProtocolFactory   = inputProtocolFactory ?? throw new ArgumentNullException(nameof(inputProtocolFactory));
     OutputProtocolFactory  = outputProtocolFactory ?? throw new ArgumentNullException(nameof(outputProtocolFactory));
 }
Exemplo n.º 13
0
        public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory inputProtocolFactory,
                                    ITProtocolFactory outputProtocolFactory, RequestDelegate next = null, ILoggerFactory loggerFactory = null)
        {
            // loggerFactory == null is not illegal anymore

            Processor             = processor ?? throw new ArgumentNullException(nameof(processor));
            InputProtocolFactory  = inputProtocolFactory ?? throw new ArgumentNullException(nameof(inputProtocolFactory));
            OutputProtocolFactory = outputProtocolFactory ?? throw new ArgumentNullException(nameof(outputProtocolFactory));

            _next   = next;
            _logger = (loggerFactory != null) ? loggerFactory.CreateLogger <THttpServerTransport>() : new NullLogger <THttpServerTransport>();
        }
Exemplo n.º 14
0
        protected internal JaegerThriftTransport(ITProtocolFactory protocolFactory, ISender sender, ISerialization serialization = null, int bufferSize = 0)
        {
            if (bufferSize <= 0)
            {
                bufferSize = DefaultBufferSize;
            }

            _protocolFactory           = protocolFactory;
            _sender                    = sender;
            BufferSize                 = bufferSize;
            _jaegerThriftSerialization = serialization ?? new JaegerThriftSerialization();
        }
Exemplo n.º 15
0
 protected TServer(ITProcessorFactory processorFactory, TServerTransport serverTransport,
                   TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
                   ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
                   ILogger logger = null)
 {
     ProcessorFactory       = processorFactory ?? throw new ArgumentNullException(nameof(processorFactory));
     ServerTransport        = serverTransport;
     InputTransportFactory  = inputTransportFactory ?? throw new ArgumentNullException(nameof(inputTransportFactory));
     OutputTransportFactory = outputTransportFactory ?? throw new ArgumentNullException(nameof(outputTransportFactory));
     InputProtocolFactory   = inputProtocolFactory ?? throw new ArgumentNullException(nameof(inputProtocolFactory));
     OutputProtocolFactory  = outputProtocolFactory ?? throw new ArgumentNullException(nameof(outputProtocolFactory));
     Logger = logger; // null is absolutely legal
 }
Exemplo n.º 16
0
 public TThreadPoolAsyncServer(ITProcessorFactory processorFactory,
                               TServerTransport serverTransport,
                               TTransportFactory inputTransportFactory,
                               TTransportFactory outputTransportFactory,
                               ITProtocolFactory inputProtocolFactory,
                               ITProtocolFactory outputProtocolFactory,
                               int minThreadPoolThreads, int maxThreadPoolThreads, ILogger logger = null)
     : this(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
            inputProtocolFactory, outputProtocolFactory,
            new Configuration(minThreadPoolThreads, maxThreadPoolThreads),
            logger)
 {
 }
Exemplo n.º 17
0
        public TThreadPoolAsyncServer(ITProcessorFactory processorFactory,
                                      TServerTransport serverTransport,
                                      TTransportFactory inputTransportFactory,
                                      TTransportFactory outputTransportFactory,
                                      ITProtocolFactory inputProtocolFactory,
                                      ITProtocolFactory outputProtocolFactory,
                                      Configuration threadConfig,
                                      ILogger logger = null)
            : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
                   inputProtocolFactory, outputProtocolFactory, logger)
        {
            lock (typeof(TThreadPoolAsyncServer))
            {
                if ((threadConfig.MaxWorkerThreads > 0) || (threadConfig.MaxIOThreads > 0))
                {
                    int work, comm;
                    ThreadPool.GetMaxThreads(out work, out comm);
                    if (threadConfig.MaxWorkerThreads > 0)
                    {
                        work = threadConfig.MaxWorkerThreads;
                    }
                    if (threadConfig.MaxIOThreads > 0)
                    {
                        comm = threadConfig.MaxIOThreads;
                    }
                    if (!ThreadPool.SetMaxThreads(work, comm))
                    {
                        throw new Exception("Error: could not SetMaxThreads in ThreadPool");
                    }
                }

                if ((threadConfig.MinWorkerThreads > 0) || (threadConfig.MinIOThreads > 0))
                {
                    int work, comm;
                    ThreadPool.GetMinThreads(out work, out comm);
                    if (threadConfig.MinWorkerThreads > 0)
                    {
                        work = threadConfig.MinWorkerThreads;
                    }
                    if (threadConfig.MinIOThreads > 0)
                    {
                        comm = threadConfig.MinIOThreads;
                    }
                    if (!ThreadPool.SetMinThreads(work, comm))
                    {
                        throw new Exception("Error: could not SetMinThreads in ThreadPool");
                    }
                }
            }
        }
Exemplo n.º 18
0
        //private readonly JaegerThriftTransport _testingTransport;

        public JaegerUdpTransportTests()
        {
            _mockJaegerThriftSerialization = Substitute.For <ISerialization>();
            _protocolFactory = new TCompactProtocol.Factory();
            _mockSender      = Substitute.For <ISender>();
            _mockSender.ProtocolFactory.Returns(_protocolFactory);

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

            _jSpanSize = CalcSizeOfSerializedThrift(jSpan);

            var jProcess = new JaegerProcess("testing");

            _jProcessSize = CalcSizeOfSerializedThrift(jProcess);

            _mockJaegerThriftSerialization.BuildJaegerProcessThrift(Arg.Any <IJaegerCoreTracer>()).Returns(jProcess);
            _mockJaegerThriftSerialization.BuildJaegerThriftSpan(Arg.Any <IJaegerCoreSpan>()).Returns(jSpan);
        }
Exemplo n.º 19
0
        protected TBaseServer(ITProcessorFactory itProcessorFactory, TServerTransport serverTransport,
            TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
            ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
            ILogger logger)
        {
            if (itProcessorFactory == null) throw new ArgumentNullException(nameof(itProcessorFactory));
            if (inputTransportFactory == null) throw new ArgumentNullException(nameof(inputTransportFactory));
            if (outputTransportFactory == null) throw new ArgumentNullException(nameof(outputTransportFactory));
            if (inputProtocolFactory == null) throw new ArgumentNullException(nameof(inputProtocolFactory));
            if (outputProtocolFactory == null) throw new ArgumentNullException(nameof(outputProtocolFactory));
            if (logger == null) throw new ArgumentNullException(nameof(logger));

            ItProcessorFactory = itProcessorFactory;
            ServerTransport = serverTransport;
            InputTransportFactory = inputTransportFactory;
            OutputTransportFactory = outputTransportFactory;
            InputProtocolFactory = inputProtocolFactory;
            OutputProtocolFactory = outputProtocolFactory;
            Logger = logger;
        }
Exemplo n.º 20
0
        protected TBaseServer(ITProcessorFactory itProcessorFactory, TServerTransport serverTransport,
                              TTransportFactory inputTransportFactory, TTransportFactory outputTransportFactory,
                              ITProtocolFactory inputProtocolFactory, ITProtocolFactory outputProtocolFactory,
                              ILogger logger)
        {
            if (itProcessorFactory == null)
            {
                throw new ArgumentNullException(nameof(itProcessorFactory));
            }
            if (inputTransportFactory == null)
            {
                throw new ArgumentNullException(nameof(inputTransportFactory));
            }
            if (outputTransportFactory == null)
            {
                throw new ArgumentNullException(nameof(outputTransportFactory));
            }
            if (inputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(inputProtocolFactory));
            }
            if (outputProtocolFactory == null)
            {
                throw new ArgumentNullException(nameof(outputProtocolFactory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            ItProcessorFactory     = itProcessorFactory;
            ServerTransport        = serverTransport;
            InputTransportFactory  = inputTransportFactory;
            OutputTransportFactory = outputTransportFactory;
            InputProtocolFactory   = inputProtocolFactory;
            OutputProtocolFactory  = outputProtocolFactory;
            Logger = logger;
        }
Exemplo n.º 21
0
 protected internal JaegerSender(ITProtocolFactory protocolFactory)
 {
     _protocolFactory = protocolFactory;
 }
Exemplo n.º 22
0
 public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory protocolFactory, RequestDelegate next,
                             ILoggerFactory loggerFactory)
     : this(processor, protocolFactory, protocolFactory, next, loggerFactory)
 {
 }
Exemplo n.º 23
0
 public THttpServerTransport(ITAsyncProcessor processor, ITProtocolFactory protocolFactory, RequestDelegate next,
     ILoggerFactory loggerFactory)
     : this(processor, protocolFactory, protocolFactory, next, loggerFactory)
 {
 }