From de20d28d493357ca759d7dd882f558218f013880 Mon Sep 17 00:00:00 2001 From: Matthew Sainsbury Date: Tue, 21 Jan 2025 20:20:40 +0000 Subject: [PATCH 1/2] config: add support for Insecure --- CHANGELOG.md | 1 + config/testdata/v0.3.yaml | 6 +++--- config/v0.3.0/log.go | 2 +- config/v0.3.0/metric.go | 2 +- config/v0.3.0/trace.go | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78089b67694..fa45495db2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Add support for configuring `ClientCertificate` and `ClientKey` field for OTLP exporters in `go.opentelemetry.io/contrib/config`. (#6378) +- Add support for configuring `Insecure` field for OTLP exporters in `go.opentelemetry.io/contrib/config`. (TODO) ### Fixed diff --git a/config/testdata/v0.3.yaml b/config/testdata/v0.3.yaml index 04f2a314e4e..998e5c176a6 100644 --- a/config/testdata/v0.3.yaml +++ b/config/testdata/v0.3.yaml @@ -57,7 +57,7 @@ logger_provider: compression: gzip # Configure max time (in milliseconds) to wait for each export. timeout: 10000 - # Configure client transport security for the exporter's connection. + # Configure client transport security for the exporter's connection when http/https is not specified for gRPC connections. insecure: false - # Configure a simple log record processor. simple: @@ -141,7 +141,7 @@ meter_provider: compression: gzip # Configure max time (in milliseconds) to wait for each export. timeout: 10000 - # Configure client transport security for the exporter's connection. + # Configure client transport security for the exporter's connection when http/https is not specified for gRPC connections. insecure: false # Configure temporality preference. temporality_preference: delta @@ -258,7 +258,7 @@ tracer_provider: compression: gzip # Configure max time (in milliseconds) to wait for each export. timeout: 10000 - # Configure client transport security for the exporter's connection. + # Configure client transport security for the exporter's connection when http/https is not specified for gRPC connections. insecure: false - # Configure a batch span processor. batch: diff --git a/config/v0.3.0/log.go b/config/v0.3.0/log.go index bca5d235594..7bb527cc08b 100644 --- a/config/v0.3.0/log.go +++ b/config/v0.3.0/log.go @@ -183,7 +183,7 @@ func otlpGRPCLogExporter(ctx context.Context, otlpConfig *OTLP) (sdklog.Exporter } else { opts = append(opts, otlploggrpc.WithEndpoint(*otlpConfig.Endpoint)) } - if u.Scheme == "http" { + if u.Scheme == "http" || (u.Scheme != "https" && otlpConfig.Insecure != nil && *otlpConfig.Insecure) { opts = append(opts, otlploggrpc.WithInsecure()) } } diff --git a/config/v0.3.0/metric.go b/config/v0.3.0/metric.go index b7d68106b43..039eff232c3 100644 --- a/config/v0.3.0/metric.go +++ b/config/v0.3.0/metric.go @@ -209,7 +209,7 @@ func otlpGRPCMetricExporter(ctx context.Context, otlpConfig *OTLPMetric) (sdkmet } else { opts = append(opts, otlpmetricgrpc.WithEndpoint(*otlpConfig.Endpoint)) } - if u.Scheme == "http" { + if u.Scheme == "http" || (u.Scheme != "https" && otlpConfig.Insecure != nil && *otlpConfig.Insecure) { opts = append(opts, otlpmetricgrpc.WithInsecure()) } } diff --git a/config/v0.3.0/trace.go b/config/v0.3.0/trace.go index 498686e15f5..5c5bc0123bc 100644 --- a/config/v0.3.0/trace.go +++ b/config/v0.3.0/trace.go @@ -107,7 +107,7 @@ func otlpGRPCSpanExporter(ctx context.Context, otlpConfig *OTLP) (sdktrace.SpanE opts = append(opts, otlptracegrpc.WithEndpoint(*otlpConfig.Endpoint)) } - if u.Scheme == "http" { + if u.Scheme == "http" || (u.Scheme != "https" && otlpConfig.Insecure != nil && *otlpConfig.Insecure) { opts = append(opts, otlptracegrpc.WithInsecure()) } } From 72bd67e00c47f45e8f00c57c7e9e24ca3ce6e097 Mon Sep 17 00:00:00 2001 From: Matthew Sainsbury Date: Tue, 21 Jan 2025 20:24:42 +0000 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa45495db2c..0d6904b0b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Add support for configuring `ClientCertificate` and `ClientKey` field for OTLP exporters in `go.opentelemetry.io/contrib/config`. (#6378) -- Add support for configuring `Insecure` field for OTLP exporters in `go.opentelemetry.io/contrib/config`. (TODO) +- Add support for configuring `Insecure` field for OTLP exporters in `go.opentelemetry.io/contrib/config`. (#6658) ### Fixed