Skip to content

Commit

Permalink
chore: set insecure on otlp tracing/metrics for http protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Apr 25, 2024
1 parent 40610b3 commit 6dab355
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
8 changes: 7 additions & 1 deletion internal/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion internal/tracing/tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func TestGetExporter(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, exp)
assert.NotNil(t, expFunc)

})
}
}

0 comments on commit 6dab355

Please sign in to comment.