You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "zbchi (via GitHub)" <gi...@apache.org> on 2025/12/21 04:46:27 UTC

[PR] test: add unit test for otel/trace [dubbo-go]

zbchi opened a new pull request, #3123:
URL: https://github.com/apache/dubbo-go/pull/3123

   ## Summary
   
   Improve unit test coverage for the otel/trace package.
   
   ## Changes
   
   ### Add unit tests for core trace functionality:
   exporter_test.go: DefaultExporter and NewExporter implementations
   options_test.go: configuration options and option functions
   stdout/exporter_test.go: stdout exporter implementation
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123#issuecomment-3678449319

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [20 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123#discussion_r2637580158


##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeNever(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "never",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/stdout/exporter_test.go:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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 stdout
+
+import (
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+)
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/otel/trace"
+)
+
+func TestNewStdoutExporter(t *testing.T) {
+	config := &trace.ExporterConfig{
+		Exporter:    "stdout",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	exporter, err := newStdoutExporter(config)
+	assert.NoError(t, err)
+	assert.NotNil(t, exporter)
+	assert.NotNil(t, exporter.GetTracerProvider())
+	assert.NotNil(t, exporter.GetPropagator())
+}
+
+func TestNewStdoutExporter_WithConfig(t *testing.T) {
+	config := &trace.ExporterConfig{
+		Exporter:       "stdout",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "b3",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	exporter, err := newStdoutExporter(config)
+	assert.NoError(t, err)
+	assert.NotNil(t, exporter)
+	assert.NotNil(t, exporter.GetTracerProvider())
+	assert.NotNil(t, exporter.GetPropagator())
+}
+
+func TestNewStdoutExporter_Singleton(t *testing.T) {
+	config := &trace.ExporterConfig{
+		Exporter:    "stdout",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	exporter1, err1 := newStdoutExporter(config)
+	assert.NoError(t, err1)
+	assert.NotNil(t, exporter1)
+
+	exporter2, err2 := newStdoutExporter(config)
+	assert.NoError(t, err2)
+	assert.NotNil(t, exporter2)
+
+	// Should return the same instance due to sync.Once
+	assert.Equal(t, exporter1, exporter2)
+}

Review Comment:
   The singleton test may fail on subsequent runs or when run in parallel with other tests. The sync.Once in the implementation (exporter.go line 36) is package-level and will only initialize once across all tests. This means that after the first test calls newStdoutExporter, the second test may use the cached instance with different configuration, making this test unreliable. Consider adding cleanup between tests or resetting the singleton state for test isolation.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeNever(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "never",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorW3c(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorB3(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "b3",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeNever(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "never",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorW3c(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorB3(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "b3",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorEmpty(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	// When propagator is empty or unknown, it should be nil
+	assert.Nil(t, propagator)
+}
+
+func TestNewExporter_PropagatorUnknown(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "unknown-propagator",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	// When propagator is unknown, it should be nil
+	assert.Nil(t, propagator)
+}
+
+func TestNewExporter_WithServiceInfo(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:         "test",
+		SampleMode:       "always",
+		Propagator:       "w3c",
+		ServiceNamespace: "test-namespace",
+		ServiceName:      "test-service",
+		ServiceVersion:   "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeNever(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "never",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorW3c(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorB3(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "b3",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorEmpty(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	// When propagator is empty or unknown, it should be nil
+	assert.Nil(t, propagator)
+}
+
+func TestNewExporter_PropagatorUnknown(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "unknown-propagator",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	// When propagator is unknown, it should be nil
+	assert.Nil(t, propagator)
+}
+
+func TestNewExporter_WithServiceInfo(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:         "test",
+		SampleMode:       "always",
+		Propagator:       "w3c",
+		ServiceNamespace: "test-namespace",
+		ServiceName:      "test-service",
+		ServiceVersion:   "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_CompleteConfig(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:         "test",
+		Endpoint:         "localhost:4318",
+		SampleMode:       "ratio",
+		SampleRatio:      0.75,
+		Propagator:       "b3",
+		ServiceNamespace: "test-namespace",
+		ServiceName:      "test-service",
+		ServiceVersion:   "1.0.0",
+		Insecure:         true,
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



##########
otel/trace/exporter_test.go:
##########
@@ -0,0 +1,283 @@
+/*
+ * 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 trace
+
+import (
+	"errors"
+	"testing"
+)
+
+import (
+	"github.com/stretchr/testify/assert"
+
+	"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
+
+	"go.opentelemetry.io/otel/propagation"
+
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+)
+
+func TestDefaultExporter_GetTracerProvider(t *testing.T) {
+	tracerProvider := sdktrace.NewTracerProvider()
+	exporter := &DefaultExporter{
+		TracerProvider: tracerProvider,
+	}
+
+	result := exporter.GetTracerProvider()
+	assert.Equal(t, tracerProvider, result)
+}
+
+func TestDefaultExporter_GetPropagator(t *testing.T) {
+	propagator := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
+	exporter := &DefaultExporter{
+		Propagator: propagator,
+	}
+
+	result := exporter.GetPropagator()
+	assert.Equal(t, propagator, result)
+}
+
+func TestNewExporter_NilConfig(t *testing.T) {
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, nil
+	}
+
+	tracerProvider, propagator, err := NewExporter(nil, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel exporter config is nil")
+}
+
+func TestNewExporter_CustomFuncError(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "always",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return nil, errors.New("custom func error")
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "failed to create test exporter")
+}
+
+func TestNewExporter_InvalidSampleMode(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:    "test",
+		SampleMode:  "invalid-mode",
+		Propagator:  "w3c",
+		ServiceName: "test-service",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		// Return a simple stdout exporter as mock
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.Nil(t, tracerProvider)
+	assert.Nil(t, propagator)
+	assert.Error(t, err)
+	assert.Contains(t, err.Error(), "otel sample mode invalid-mode not supported")
+}
+
+func TestNewExporter_SampleModeRatio(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "ratio",
+		SampleRatio:    0.5,
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeAlways(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_SampleModeNever(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "never",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}
+
+func TestNewExporter_PropagatorW3c(t *testing.T) {
+	config := &ExporterConfig{
+		Exporter:       "test",
+		SampleMode:     "always",
+		Propagator:     "w3c",
+		ServiceName:    "test-service",
+		ServiceVersion: "1.0.0",
+	}
+
+	customFunc := func() (sdktrace.SpanExporter, error) {
+		return stdouttrace.New(stdouttrace.WithPrettyPrint())
+	}
+
+	tracerProvider, propagator, err := NewExporter(config, customFunc)
+	assert.NoError(t, err)
+	assert.NotNil(t, tracerProvider)
+	assert.NotNil(t, propagator)
+}

Review Comment:
   The TracerProvider instances created in these tests are not properly shut down. TracerProviders should be shut down after use to ensure proper cleanup of resources and flushing of spans. Consider adding defer statements to call tracerProvider.Shutdown(context.Background()) after each TracerProvider is created.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123#issuecomment-3678450536

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [20 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123#issuecomment-3678452083

   ## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/3123?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 37.59%. Comparing base ([`ffc02ca`](https://app.codecov.io/gh/apache/dubbo-go/commit/ffc02cad8ecaa4f26314e57b390d7a3fbe9840ed?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d111ec0`](https://app.codecov.io/gh/apache/dubbo-go/commit/d111ec0a9aed7261cd7e72f1c1e7a9d4747dbd3b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 3 commits behind head on develop.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop    #3123      +/-   ##
   ===========================================
   + Coverage    37.04%   37.59%   +0.54%     
   ===========================================
     Files          460      460              
     Lines        32997    32997              
   ===========================================
   + Hits         12224    12404     +180     
   + Misses       19547    19358     -189     
   - Partials      1226     1235       +9     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/dubbo-go/pull/3123?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123#issuecomment-3680139342

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [18 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3123&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3123&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3123)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] test: add unit test for otel/trace [dubbo-go]

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks merged PR #3123:
URL: https://github.com/apache/dubbo-go/pull/3123


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org