Skip to content

Commit

Permalink
add export usehttp falg
Browse files Browse the repository at this point in the history
  • Loading branch information
afocus committed Apr 25, 2022
1 parent ecdc061 commit 628c0e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ import (

type exporter func(ctx context.Context) (trace.SpanExporter, error)

func ExportHTTP(endpoint string) func(ctx context.Context) (trace.SpanExporter, error) {
func ExportHTTP(endpoint string, usehttps bool) func(ctx context.Context) (trace.SpanExporter, error) {
return func(ctx context.Context) (trace.SpanExporter, error) {
return otlptracehttp.New(ctx,
opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint(endpoint),
otlptracehttp.WithTimeout(time.Second*30),
)
otlptracehttp.WithTimeout(time.Second * 30),
}
if !usehttps {
opts = append(opts, otlptracehttp.WithInsecure())
}
return otlptracehttp.New(ctx,...opts)
}
}

Expand Down

0 comments on commit 628c0e4

Please sign in to comment.