Skip to content

Commit 1d6ba2f

Browse files
committed
insecure settings for otlp over http
1 parent 068e154 commit 1d6ba2f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

tracing/all.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66

77
"go.opentelemetry.io/otel/attribute"
8-
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
98
)
109

1110
// Config is universal config being used to tune tracing
@@ -79,15 +78,11 @@ func Start(cfg Config, extraAttributes ...attribute.KeyValue) (err error) {
7978
func StartWithContext(ctx context.Context, cfg Config, extraAttributes ...attribute.KeyValue) (err error) {
8079
switch cfg.Protocol {
8180
case "otlp_http", "OTLP_HTTP":
82-
var opts []otlptracehttp.Option
83-
if cfg.Insecure {
84-
opts = append(opts, otlptracehttp.WithInsecure())
85-
}
8681
return ConfigureOTLPoverHTTP(ctx, OTLPoverHTTPConfig{
8782
Endpoint: cfg.Endpoint,
8883
Compression: true,
8984
Ratio: cfg.Ratio,
90-
Opts: opts,
85+
Insecure: cfg.Insecure,
9186
}, extraAttributes...)
9287
case "udp", "UDP":
9388
return ConfigureUDP(UDPConfig{

tracing/otlp_over_http.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type OTLPoverHTTPConfig struct {
1414
Ratio float64 `yaml:"ratio" validate:"lte=1,gte=0"`
1515
Headers map[string]string `yaml:"headers"`
1616
Opts []otlptracehttp.Option `yaml:"-"`
17+
Insecure bool `yaml:"insecure"`
1718
}
1819

1920
// ConfigureOTLPoverHTTP fine tunes OTLP HTTP exporter to deliver spans via OTLP over HTTP protocol to collector http endpoint
@@ -28,6 +29,9 @@ func ConfigureOTLPoverHTTP(ctx context.Context, cfg OTLPoverHTTPConfig, extraAtt
2829
if len(cfg.Headers) > 0 {
2930
opts = append(opts, otlptracehttp.WithHeaders(cfg.Headers))
3031
}
32+
if cfg.Insecure {
33+
opts = append(opts, otlptracehttp.WithInsecure())
34+
}
3135
opts = append(opts, cfg.Opts...)
3236
exp, err = otlptracehttp.New(ctx, opts...)
3337
if err != nil {

0 commit comments

Comments
 (0)