protected BaseOtlpHttpExportClient(OtlpExporterOptions options, HttpClient httpClient) { Guard.ThrowIfNull(options, nameof(options)); Guard.ThrowIfNull(httpClient, nameof(httpClient)); Guard.ThrowIfInvalidTimeout(options.TimeoutMilliseconds, $"{nameof(options)}.{nameof(options.TimeoutMilliseconds)}"); this.Options = options; this.Headers = options.GetHeaders <Dictionary <string, string> >((d, k, v) => d.Add(k, v)); this.HttpClient = httpClient; }
public void GetHeaders_NoOptionHeaders_ReturnsEmptyHeadres(string optionHeaders) { var options = new OtlpExporterOptions { Headers = optionHeaders, }; var headers = options.GetHeaders <Dictionary <string, string> >((d, k, v) => d.Add(k, v)); Assert.Empty(headers); }
protected BaseOtlpHttpExportClient(OtlpExporterOptions options, HttpClient httpClient = null) { Guard.Null(options, nameof(options)); Guard.InvalidTimeout(options.TimeoutMilliseconds, $"{nameof(options)}.{nameof(options.TimeoutMilliseconds)}"); this.Options = options; this.Headers = options.GetHeaders <Dictionary <string, string> >((d, k, v) => d.Add(k, v)); this.HttpClient = httpClient ?? new HttpClient { Timeout = TimeSpan.FromMilliseconds(this.Options.TimeoutMilliseconds) }; }
protected BaseOtlpHttpExportClient(OtlpExporterOptions options, HttpClient httpClient = null) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); if (this.Options.TimeoutMilliseconds <= 0) { throw new ArgumentException("Timeout value provided is not a positive number.", nameof(this.Options.TimeoutMilliseconds)); } this.Headers = options.GetHeaders <Dictionary <string, string> >((d, k, v) => d.Add(k, v)); this.HttpClient = httpClient ?? new HttpClient { Timeout = TimeSpan.FromMilliseconds(this.Options.TimeoutMilliseconds) }; }
protected BaseOtlpHttpExportClient(OtlpExporterOptions options, HttpClient httpClient, string signalPath) { Guard.ThrowIfNull(options); Guard.ThrowIfNull(httpClient); Guard.ThrowIfNull(signalPath); Guard.ThrowIfInvalidTimeout(options.TimeoutMilliseconds); Uri exporterEndpoint = !options.ProgrammaticallyModifiedEndpoint ? options.Endpoint.AppendPathIfNotPresent(signalPath) : options.Endpoint; this.Endpoint = new UriBuilder(exporterEndpoint).Uri; this.Headers = options.GetHeaders <Dictionary <string, string> >((d, k, v) => d.Add(k, v)); this.HttpClient = httpClient; }