private bool disposedValue = false; // To detect redundant calls public JaegerUdpBatcher(JaegerExporterOptions options, TTransport clientTransport = null) { 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 = clientTransport ?? new JaegerThriftClientTransport(options.AgentHost, options.AgentPort); this.thriftClient = new JaegerThriftClient(this.protocolFactory.GetProtocol(this.clientTransport)); this.memoryTransport = new InMemoryTransport(16000); this.memoryProtocol = this.protocolFactory.GetProtocol(this.memoryTransport); 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); }; }
private int GetSize(TAbstractBase thriftBase) { using (var memoryTransport = new InMemoryTransport()) { thriftBase.WriteAsync(this.protocolFactory.GetProtocol(memoryTransport), CancellationToken.None).GetAwaiter().GetResult(); return(memoryTransport.GetBuffer().Length); } }
private async Task <int> GetSize(TAbstractBase thriftBase) { using (var memoryTransport = new InMemoryTransport()) { await thriftBase.WriteAsync(this.protocolFactory.GetProtocol(memoryTransport), CancellationToken.None).ConfigureAwait(false); return(memoryTransport.GetBuffer().Length); } }