internal JaegerExporter(JaegerExporterOptions options, TTransport clientTransport = null) { Guard.Null(options, nameof(options)); this.maxPayloadSizeInBytes = (!options.MaxPayloadSizeInBytes.HasValue || options.MaxPayloadSizeInBytes <= 0) ? JaegerExporterOptions.DefaultMaxPayloadSizeInBytes : options.MaxPayloadSizeInBytes.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); string serviceName = (string)this.ParentProvider.GetDefaultResource().Attributes.Where( pair => pair.Key == ResourceSemanticConventions.AttributeServiceName).FirstOrDefault().Value; this.Process = new Process(serviceName); }
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 JaegerExporter(JaegerExporterOptions options) : this(options, null) { }