internal JaegerExporter(JaegerExporterOptions options, TProtocolFactory protocolFactory = null, IJaegerClient client = null) { Guard.ThrowIfNull(options, nameof(options)); this.maxPayloadSizeInBytes = (!options.MaxPayloadSizeInBytes.HasValue || options.MaxPayloadSizeInBytes <= 0) ? JaegerExporterOptions.DefaultMaxPayloadSizeInBytes : options.MaxPayloadSizeInBytes.Value; if (options.Protocol == JaegerExportProtocol.UdpCompactThrift) { protocolFactory ??= new TCompactProtocol.Factory(); client ??= new JaegerUdpClient(options.AgentHost, options.AgentPort); this.sendUsingEmitBatchArgs = true; } else if (options.Protocol == JaegerExportProtocol.HttpBinaryThrift) { protocolFactory ??= new TBinaryProtocol.Factory(); client ??= new JaegerHttpClient( options.Endpoint, options.HttpClientFactory?.Invoke() ?? throw new InvalidOperationException("JaegerExporterOptions was missing HttpClientFactory or it returned null.")); } else { throw new NotSupportedException(); } this.client = client; this.batchWriter = protocolFactory.GetProtocol(this.maxPayloadSizeInBytes * 2); this.spanWriter = protocolFactory.GetProtocol(this.maxPayloadSizeInBytes); string serviceName = (string)this.ParentProvider.GetDefaultResource().Attributes.FirstOrDefault( pair => pair.Key == ResourceSemanticConventions.AttributeServiceName).Value; this.Process = new Process(serviceName); client.Connect(); }
public JaegerThriftClientTransport(string host, int port, MemoryStream stream, IJaegerClient client) { this.byteStream = stream; this.client = client; this.client.Connect(host, port); }