Skip to content

Commit e77d6e1

Browse files
committed
fix(): support new grpc client
1 parent a09e608 commit e77d6e1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ internal OtlpExporterOptions(
7676
this.DefaultHttpClientFactory = () =>
7777
{
7878
#if NET6_0_OR_GREATER
79-
// Create a new handler
8079
var handler = new HttpClientHandler();
81-
// Load certificates (including client & server certificates if configured)
8280
HttpClient client = this.AddCertificatesToHttpClient(handler);
8381
client.Timeout = TimeSpan.FromMilliseconds(this.TimeoutMilliseconds);
8482
return client;
@@ -257,6 +255,7 @@ internal OtlpExporterOptions ApplyDefaults(OtlpExporterOptions defaultExporterOp
257255
return this;
258256
}
259257

258+
#if NET6_0_OR_GREATER
260259
internal HttpClient AddCertificatesToHttpClient(HttpClientHandler handler)
261260
{
262261
// Configure server certificate validation if CertificateFile is provided
@@ -281,14 +280,14 @@ internal HttpClient AddCertificatesToHttpClient(HttpClientHandler handler)
281280
// Add client certificate if both files are provided
282281
if (!string.IsNullOrEmpty(this.ClientCertificateFile) && !string.IsNullOrEmpty(this.ClientKeyFile))
283282
{
284-
// Load the client certificate from PEM files
285283
var clientCertificate = X509Certificate2.CreateFromPemFile(this.ClientCertificateFile, this.ClientKeyFile);
286284
handler.ClientCertificates.Add(clientCertificate);
287285
}
288286

289287
// Create and return an HttpClient with the modified handler
290288
return new HttpClient(handler);
291289
}
290+
#endif
292291

293292
private static string GetUserAgentString()
294293
{

0 commit comments

Comments
 (0)