This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new afc686da4 fix(filter/trace): adjust the trace scope name with the otel 
spec (#3041)
afc686da4 is described below

commit afc686da4078b113fa6c008c26d208506f60e249
Author: ian <[email protected]>
AuthorDate: Sat Oct 18 16:14:26 2025 +0800

    fix(filter/trace): adjust the trace scope name with the otel spec (#3041)
    
    * fileter(otel/trace): fix the name and version of trace
---
 common/constant/otel.go         |  6 +++---
 filter/otel/trace/attachment.go |  2 +-
 filter/otel/trace/filter.go     | 35 ++++++++++++++++++++++-------------
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/common/constant/otel.go b/common/constant/otel.go
index ce0542675..91aa0e955 100644
--- a/common/constant/otel.go
+++ b/common/constant/otel.go
@@ -17,6 +17,6 @@
 
 package constant
 
-const (
-       OtelPackageName = "go.opentelemetry.io/otel"
-)
+// TraceScopeName is unique name of trace used for the filter
+// Reference: https://github.com/open-telemetry/opentelemetry-specification/
+const TraceScopeName = "dubbo.apache.org/dubbo-go/v3/filter/otel/trace"
diff --git a/filter/otel/trace/attachment.go b/filter/otel/trace/attachment.go
index 6d46cab59..f6d88e76e 100644
--- a/filter/otel/trace/attachment.go
+++ b/filter/otel/trace/attachment.go
@@ -33,7 +33,7 @@ type metadataSupplier struct {
        metadata map[string]any
 }
 
-var _ propagation.TextMapCarrier = &metadataSupplier{}
+var _ propagation.TextMapCarrier = (*metadataSupplier)(nil)
 
 func (s *metadataSupplier) Get(key string) string {
        if s.metadata == nil {
diff --git a/filter/otel/trace/filter.go b/filter/otel/trace/filter.go
index ab55f4cf8..3b40619c0 100644
--- a/filter/otel/trace/filter.go
+++ b/filter/otel/trace/filter.go
@@ -26,7 +26,6 @@ import (
        "go.opentelemetry.io/otel/baggage"
        "go.opentelemetry.io/otel/codes"
        "go.opentelemetry.io/otel/propagation"
-       "go.opentelemetry.io/otel/sdk"
        semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
        "go.opentelemetry.io/otel/trace"
 )
@@ -55,6 +54,11 @@ func init() {
        })
 }
 
+var _ filter.Filter = (*otelServerFilter)(nil)
+
+// otelServerFilter implements server-side tracing for Dubbo requests
+// by creating and managing trace spans using the configured propagator
+// and tracer provider.
 type otelServerFilter struct {
        Propagators    propagation.TextMapPropagator
        TracerProvider trace.TracerProvider
@@ -70,8 +74,8 @@ func (f *otelServerFilter) Invoke(ctx context.Context, 
invoker base.Invoker, inv
        ctx = baggage.ContextWithBaggage(ctx, bags)
 
        tracer := f.TracerProvider.Tracer(
-               constant.OtelPackageName,
-               trace.WithInstrumentationVersion(sdk.Version()),
+               constant.TraceScopeName,
+               trace.WithInstrumentationVersion(constant.Version),
        )
 
        ctx, span := tracer.Start(
@@ -86,16 +90,21 @@ func (f *otelServerFilter) Invoke(ctx context.Context, 
invoker base.Invoker, inv
        )
        defer span.End()
 
-       result := invoker.Invoke(ctx, invocation)
+       res := invoker.Invoke(ctx, invocation)
 
-       if result.Error() != nil {
-               span.SetStatus(codes.Error, result.Error().Error())
+       if res.Error() != nil {
+               span.SetStatus(codes.Error, res.Error().Error())
        } else {
                span.SetStatus(codes.Ok, codes.Ok.String())
        }
-       return result
+       return res
 }
 
+var _ filter.Filter = (*otelClientFilter)(nil)
+
+// otelClientFilter implements client-side tracing for Dubbo requests
+// by creating and managing trace spans using the configured propagator
+// and tracer provider.
 type otelClientFilter struct {
        Propagators    propagation.TextMapPropagator
        TracerProvider trace.TracerProvider
@@ -107,8 +116,8 @@ func (f *otelClientFilter) OnResponse(ctx context.Context, 
result result.Result,
 
 func (f *otelClientFilter) Invoke(ctx context.Context, invoker base.Invoker, 
invocation base.Invocation) result.Result {
        tracer := f.TracerProvider.Tracer(
-               constant.OtelPackageName,
-               trace.WithInstrumentationVersion(sdk.Version()),
+               constant.TraceScopeName,
+               trace.WithInstrumentationVersion(constant.Version),
        )
 
        var span trace.Span
@@ -132,12 +141,12 @@ func (f *otelClientFilter) Invoke(ctx context.Context, 
invoker base.Invoker, inv
        for k, v := range attachments {
                invocation.SetAttachment(k, v)
        }
-       result := invoker.Invoke(ctx, invocation)
+       res := invoker.Invoke(ctx, invocation)
 
-       if result.Error() != nil {
-               span.SetStatus(codes.Error, result.Error().Error())
+       if res.Error() != nil {
+               span.SetStatus(codes.Error, res.Error().Error())
        } else {
                span.SetStatus(codes.Ok, codes.Ok.String())
        }
-       return result
+       return res
 }

Reply via email to