@ -10,6 +10,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/exporters/zipkin"
"go.opentelemetry.io/otel/exporters/zipkin"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@ -17,9 +18,10 @@ import (
)
)
const (
const (
kindJaeger = "jaeger"
kindJaeger = "jaeger"
kindZipkin = "zipkin"
kindZipkin = "zipkin"
kindGrpc = "grpc"
kindOtlpGrpc = "otlpgrpc"
kindOtlpHttp = "otlphttp"
)
)
var (
var (
@ -58,7 +60,7 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
return jaeger . New ( jaeger . WithCollectorEndpoint ( jaeger . WithEndpoint ( c . Endpoint ) ) )
return jaeger . New ( jaeger . WithCollectorEndpoint ( jaeger . WithEndpoint ( c . Endpoint ) ) )
case kindZipkin :
case kindZipkin :
return zipkin . New ( c . Endpoint )
return zipkin . New ( c . Endpoint )
case kind Grpc:
case kind Otlp Grpc:
// Always treat trace exporter as optional component, so we use nonblock here,
// Always treat trace exporter as optional component, so we use nonblock here,
// otherwise this would slow down app start up even set a dial timeout here when
// otherwise this would slow down app start up even set a dial timeout here when
// endpoint can not reach.
// endpoint can not reach.
@ -69,6 +71,13 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
otlptracegrpc . WithInsecure ( ) ,
otlptracegrpc . WithInsecure ( ) ,
otlptracegrpc . WithEndpoint ( c . Endpoint ) ,
otlptracegrpc . WithEndpoint ( c . Endpoint ) ,
)
)
case kindOtlpHttp :
// Not support flexible configuration now.
return otlptracehttp . New (
context . Background ( ) ,
otlptracehttp . WithInsecure ( ) ,
otlptracehttp . WithEndpoint ( c . Endpoint ) ,
)
default :
default :
return nil , fmt . Errorf ( "unknown exporter: %s" , c . Batcher )
return nil , fmt . Errorf ( "unknown exporter: %s" , c . Batcher )
}
}