From 22f973abfebd27a68f78b787107075ef375580f0 Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:58:49 -0400 Subject: [PATCH] Otlp http (#3022) * chore: mod tidy * chore: mod tidy * chore: set insecure on otlp tracing/metrics for http protocol --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- internal/metrics/metrics.go | 12 +++++++++++- internal/tracing/tracing.go | 8 +++++++- internal/tracing/tracing_test.go | 1 - 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index edd7acfb06..42e60bfe65 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -166,7 +166,7 @@ func GetExporter(ctx context.Context, cfg *config.MetricsConfig) (sdkmetric.Read var exporter sdkmetric.Exporter switch u.Scheme { - case "http", "https": + case "https": exporter, err = otlpmetrichttp.New(ctx, otlpmetrichttp.WithEndpoint(u.Host+u.Path), otlpmetrichttp.WithHeaders(cfg.OTLP.Headers), @@ -175,6 +175,16 @@ func GetExporter(ctx context.Context, cfg *config.MetricsConfig) (sdkmetric.Read metricExpErr = fmt.Errorf("creating otlp metrics exporter: %w", err) return } + case "http": + exporter, err = otlpmetrichttp.New(ctx, + otlpmetrichttp.WithEndpoint(u.Host+u.Path), + otlpmetrichttp.WithHeaders(cfg.OTLP.Headers), + otlpmetrichttp.WithInsecure(), + ) + if err != nil { + metricExpErr = fmt.Errorf("creating otlp metrics exporter: %w", err) + return + } case "grpc": exporter, err = otlpmetricgrpc.New(ctx, otlpmetricgrpc.WithEndpoint(u.Host+u.Path), diff --git a/internal/tracing/tracing.go b/internal/tracing/tracing.go index dcc5cd5ae4..a1720c5253 100644 --- a/internal/tracing/tracing.go +++ b/internal/tracing/tracing.go @@ -79,11 +79,17 @@ func GetExporter(ctx context.Context, cfg *config.TracingConfig) (tracesdk.SpanE var client otlptrace.Client switch u.Scheme { - case "http", "https": + case "https": client = otlptracehttp.NewClient( otlptracehttp.WithEndpoint(u.Host+u.Path), otlptracehttp.WithHeaders(cfg.OTLP.Headers), ) + case "http": + client = otlptracehttp.NewClient( + otlptracehttp.WithEndpoint(u.Host+u.Path), + otlptracehttp.WithHeaders(cfg.OTLP.Headers), + otlptracehttp.WithInsecure(), + ) case "grpc": // TODO: support additional configuration options client = otlptracegrpc.NewClient( diff --git a/internal/tracing/tracing_test.go b/internal/tracing/tracing_test.go index 9c8bbf4281..0dfb05d48b 100644 --- a/internal/tracing/tracing_test.go +++ b/internal/tracing/tracing_test.go @@ -148,7 +148,6 @@ func TestGetExporter(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, exp) assert.NotNil(t, expFunc) - }) } }