diff --git a/common/extension/otel_trace.go b/common/extension/otel_trace.go index 4def9f149b..f8023d7a09 100644 --- a/common/extension/otel_trace.go +++ b/common/extension/otel_trace.go @@ -19,7 +19,13 @@ package extension import ( "context" +) + +import ( "dubbo.apache.org/dubbo-go/v3/otel/trace" +) + +import ( "github.com/dubbogo/gost/log/logger" ) diff --git a/config/otel_config_test.go b/config/otel_config_test.go index 4fb4fa4f04..af1b302926 100644 --- a/config/otel_config_test.go +++ b/config/otel_config_test.go @@ -1,18 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package config import ( - "github.com/stretchr/testify/assert" "testing" ) +import ( + "github.com/stretchr/testify/assert" +) + func TestNewOtelConfigBuilder(t *testing.T) { config := NewOtelConfigBuilder().Build() assert.NotNil(t, config) assert.NotNil(t, config.TraceConfig) - err := config.Init() + ac := NewApplicationConfigBuilder().Build() + err := config.Init(ac) assert.NoError(t, err) - tpc := config.TraceConfig.toTraceProviderConfig() + tpc := config.TraceConfig.toTraceProviderConfig(ac) assert.NotNil(t, tpc) } diff --git a/filter/otel/trace/doc.go b/filter/otel/trace/doc.go index 5d7dfb3c70..c3c1ce3579 100644 --- a/filter/otel/trace/doc.go +++ b/filter/otel/trace/doc.go @@ -15,6 +15,6 @@ * limitations under the License. */ -// Package jaeger instruments dubbogo with open-telemetry +// Package trace instruments dubbogo with open-telemetry // (https://github.com/open-telemetry/opentelemetry-go). package trace diff --git a/otel/trace/exporter.go b/otel/trace/exporter.go index 5d4a303b4e..454b02a975 100644 --- a/otel/trace/exporter.go +++ b/otel/trace/exporter.go @@ -20,6 +20,9 @@ package trace import ( "errors" "fmt" +) + +import ( "github.com/dubbogo/gost/log/logger" "go.opentelemetry.io/contrib/propagators/b3" "go.opentelemetry.io/otel/propagation" @@ -57,6 +60,7 @@ func (e *DefaultExporter) GetPropagator() propagation.TextMapPropagator { return e.Propagator } +// NewExporter is an absolute function with @customFunc to create a spec exporter func NewExporter(config *ExporterConfig, customFunc func() (sdktrace.SpanExporter, error)) (tracerProvider *sdktrace.TracerProvider, propagator propagation.TextMapPropagator, err error) { if config == nil { err = errors.New("otel exporter config is nil") diff --git a/otel/trace/jaeger/exporter.go b/otel/trace/jaeger/exporter.go index efcad8fb92..65a269022c 100644 --- a/otel/trace/jaeger/exporter.go +++ b/otel/trace/jaeger/exporter.go @@ -17,12 +17,18 @@ package jaeger +import ( + "sync" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/otel/trace" +) + +import ( "go.opentelemetry.io/otel/exporters/jaeger" sdktrace "go.opentelemetry.io/otel/sdk/trace" - "sync" ) var ( diff --git a/otel/trace/otlp/exporter.go b/otel/trace/otlp/exporter.go index 8c02208794..69e2adeb1f 100644 --- a/otel/trace/otlp/exporter.go +++ b/otel/trace/otlp/exporter.go @@ -19,13 +19,19 @@ package otlp import ( "context" + "sync" +) + +import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/otel/trace" +) + +import ( "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" sdktrace "go.opentelemetry.io/otel/sdk/trace" - "sync" ) var ( diff --git a/otel/trace/zipkin/exporter.go b/otel/trace/zipkin/exporter.go index 383717623a..4068872ce3 100644 --- a/otel/trace/zipkin/exporter.go +++ b/otel/trace/zipkin/exporter.go @@ -17,12 +17,18 @@ package zipkin +import ( + "sync" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/otel/trace" +) + +import ( "go.opentelemetry.io/otel/exporters/zipkin" sdktrace "go.opentelemetry.io/otel/sdk/trace" - "sync" ) var (