|
|
@ -5,8 +5,6 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/lang"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
|
|
|
"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"
|
|
|
@ -14,7 +12,9 @@ import (
|
|
|
|
"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"
|
|
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
|
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/lang"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
@ -60,11 +60,15 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
|
|
|
case kindZipkin:
|
|
|
|
case kindZipkin:
|
|
|
|
return zipkin.New(c.Endpoint)
|
|
|
|
return zipkin.New(c.Endpoint)
|
|
|
|
case kindGrpc:
|
|
|
|
case kindGrpc:
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
// 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(
|
|
|
|
return otlptracegrpc.New(
|
|
|
|
context.Background(),
|
|
|
|
context.Background(),
|
|
|
|
otlptracegrpc.WithInsecure(),
|
|
|
|
otlptracegrpc.WithInsecure(),
|
|
|
|
otlptracegrpc.WithEndpoint(c.Endpoint),
|
|
|
|
otlptracegrpc.WithEndpoint(c.Endpoint),
|
|
|
|
otlptracegrpc.WithDialOption(grpc.WithBlock()),
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown exporter: %s", c.Batcher)
|
|
|
|
return nil, fmt.Errorf("unknown exporter: %s", c.Batcher)
|
|
|
|