feat: add otlptracegrpc otlptracehttp headers support for Uptrace (#3219)

Signed-off-by: Toby Yan <me@tobyan.com>
Co-authored-by: cong <zhangcong1992@gmail.com>
This commit is contained in:
Toby
2023-05-09 04:58:29 +08:00
committed by GitHub
parent 3637e10815
commit 1853428011
3 changed files with 28 additions and 9 deletions

View File

@@ -71,17 +71,29 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
// endpoint can not reach.
// If the connection not dial success, the global otel ErrorHandler will catch error
// when reporting data like other exporters.
return otlptracegrpc.New(
context.Background(),
opts := []otlptracegrpc.Option{
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint(c.Endpoint),
}
if len(c.OtlpHeaders) > 0 {
opts = append(opts, otlptracegrpc.WithHeaders(c.OtlpHeaders))
}
return otlptracegrpc.New(
context.Background(),
opts...,
)
case kindOtlpHttp:
// Not support flexible configuration now.
return otlptracehttp.New(
context.Background(),
opts := []otlptracehttp.Option{
otlptracehttp.WithInsecure(),
otlptracehttp.WithEndpoint(c.Endpoint),
}
if len(c.OtlpHeaders) > 0 {
opts = append(opts, otlptracehttp.WithHeaders(c.OtlpHeaders))
}
return otlptracehttp.New(
context.Background(),
opts...,
)
default:
return nil, fmt.Errorf("unknown exporter: %s", c.Batcher)