public OtlpGrpcLogExportClient(OtlpExporterOptions options, OtlpCollector.LogsService.ILogsServiceClient logsServiceClient = null) : base(options) { if (logsServiceClient != null) { this.logsClient = logsServiceClient; } else { this.Channel = options.CreateChannel(); this.logsClient = new OtlpCollector.LogsService.LogsServiceClient(this.Channel); } }
/// <summary> /// Initializes a new instance of the <see cref="OtlpLogExporter"/> class. /// </summary> /// <param name="options">Configuration options for the exporter.</param> /// <param name="traceServiceClient"><see cref="OtlpCollector.LogsService.LogsServiceClient"/>.</param> internal OtlpLogExporter(OtlpExporterOptions options, OtlpCollector.LogsService.ILogsServiceClient traceServiceClient = null) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.headers = GetMetadataFromHeaders(options.Headers); if (this.options.TimeoutMilliseconds <= 0) { throw new ArgumentException("Timeout value provided is not a positive number.", nameof(this.options.TimeoutMilliseconds)); } if (traceServiceClient != null) { this.logsClient = traceServiceClient; } else { if (options.Endpoint.Scheme != Uri.UriSchemeHttp && options.Endpoint.Scheme != Uri.UriSchemeHttps) { throw new NotSupportedException($"Endpoint URI scheme ({options.Endpoint.Scheme}) is not supported. Currently only \"http\" and \"https\" are supported."); } // #if NETSTANDARD2_1 this.channel = GrpcChannel.ForAddress(options.Endpoint); // #else // ChannelCredentials channelCredentials; // if (options.Endpoint.Scheme == Uri.UriSchemeHttps) // { // channelCredentials = new SslCredentials(); // } // else // { // channelCredentials = ChannelCredentials.Insecure; // } // this.channel = new Channel(options.Endpoint.Authority, channelCredentials); // #endif this.logsClient = new OtlpCollector.LogsService.LogsServiceClient(this.channel); } }