You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/04/08 02:01:10 UTC

[GitHub] [dubbo-go-pixiu] maxingg opened a new pull request, #394: trace support for pixiu

maxingg opened a new pull request, #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394

   <!--  Thanks for sending a pull request! 
   -->
   
   **Provide scalable trace support for pixiu, which developers can use to customize multiple exporters to collect data, and the flexibility to trace requests for multiple protocols.**:
   
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #376
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   Yes. Trace configuration in conf.yaml includes exporter name and detailed configuration, sampling policy, etc. You can start the relevant container in docker-compose.yaml, and later encode it in the component to trace the request, or choose to customize the trace for a certain protocol.
   ```


-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856753575


##########
pkg/server/otel.go:
##########
@@ -73,3 +78,45 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// NewTracer create tracer and need to be specified protocol.
+func NewTracer(name tracing.ProtocolName) (tracing.Trace, error) {
+	driver := GetTraceDriverManager().GetDriver()
+	if driver == nil {
+		return nil, errors.New("You must specify the exporter in conf.yaml first\n")
+	}
+	holder := driver.GetHolder(name)
+
+	builder := strings.Builder{}
+	builder.WriteString(string(name))
+	builder.WriteString("-" + fmt.Sprint(holder.ID))
+
+	traceId := builder.String()
+	tmp := driver.Tp.Tracer(traceId)
+	tracer := &tracing.Tracer{
+		ID:     traceId,
+		Trace:  tmp,
+		Holder: holder,
+	}
+
+	holder.Tracers[traceId] = tracing.TraceFactory[name](tracer)
+
+	atomic.AddUint64(&holder.ID, 1)
+	return holder.Tracers[traceId], nil

Review Comment:
   tracing.Trace是接口,指向的就是引用类型。



##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		return nil
+	}
+	driver := NewTraceDriver()
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+
+// GetHolder return the holder of the corresponding protocol. If None, create new holder.
+func (driver *TraceDriver) GetHolder(name ProtocolName) *Holder {
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &Holder{
+			Tracers: make(map[string]Trace),
+		}
+		driver.Holders[name] = holder
+	}
+	return holder
+}
+
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {

Review Comment:
   同上



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845758002


##########
pkg/tracing/http.go:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"net/http"
+)
+
+import (
+	"go.opentelemetry.io/otel/trace"
+)
+
+//Wrap the tracer provided by otel and be asked to implement the Trace interface
+//to customize the Span implementation.
+type Tracer struct {
+	Id string

Review Comment:
   ID



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r849057586


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// Loading BootStrap configuration about trace
+func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		//TODO 错误处理
+		return driver
+	}
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
+	if cfg.Name == "otlp" {
+		return otlp.NewOTLPExporter(ctx, cfg)
+	} else {
+		return jaeger.NewJaegerExporter(cfg)
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),
+	)
+
+	return sdktrace.NewTracerProvider(
+		sdktrace.WithBatcher(exp),
+		sdktrace.WithResource(resource),
+		sdktrace.WithSampler(newSampler(cfg.Sampler)),
+	)
+}
+
+// Default sampler's Type: fraction
+func newSampler(sample model.Sampler) sdktrace.Sampler {
+	if sample.Type == "never" {

Review Comment:
   @AlexStocks 



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r846951853


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// Loading BootStrap configuration about trace
+func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		//TODO 错误处理
+		return driver
+	}
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
+	if cfg.Name == "otlp" {
+		return otlp.NewOTLPExporter(ctx, cfg)
+	} else {
+		return jaeger.NewJaegerExporter(cfg)
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),
+	)
+
+	return sdktrace.NewTracerProvider(
+		sdktrace.WithBatcher(exp),
+		sdktrace.WithResource(resource),
+		sdktrace.WithSampler(newSampler(cfg.Sampler)),
+	)
+}
+
+// Default sampler's Type: fraction
+func newSampler(sample model.Sampler) sdktrace.Sampler {
+	if sample.Type == "never" {

Review Comment:
   	switch sample.Type {
   case "never" :
   		return sdktrace.NeverSample()
   case "always":
   		return sdktrace.AlwaysSample()
   	default:
   		return sdktrace.TraceIDRatioBased(sample.Param)
   	}



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r849083217


##########
pkg/server/otel.go:
##########
@@ -73,3 +78,52 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// NewTracer create tracer and need to be specified protocol.
+func NewTracer(name tracing.ProtocolName) (tracing.Trace, error) {
+	driver := GetTraceDriverManager().GetDriver()
+	if driver == nil {
+		return nil, errors.New("You must specify the exporter in conf.yaml first\n")
+	}
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &tracing.Holder{
+			Tracers: make(map[string]tracing.Trace),
+		}
+		holder.ID = 0

Review Comment:
   为零不用赋值,go 中默认就是零值。



-- 
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


[GitHub] [dubbo-go-pixiu] ztelur commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
ztelur commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856687477


##########
pkg/server/otel.go:
##########
@@ -73,3 +78,45 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// NewTracer create tracer and need to be specified protocol.
+func NewTracer(name tracing.ProtocolName) (tracing.Trace, error) {
+	driver := GetTraceDriverManager().GetDriver()
+	if driver == nil {
+		return nil, errors.New("You must specify the exporter in conf.yaml first\n")
+	}
+	holder := driver.GetHolder(name)
+
+	builder := strings.Builder{}
+	builder.WriteString(string(name))
+	builder.WriteString("-" + fmt.Sprint(holder.ID))
+
+	traceId := builder.String()
+	tmp := driver.Tp.Tracer(traceId)
+	tracer := &tracing.Tracer{
+		ID:     traceId,
+		Trace:  tmp,
+		Holder: holder,
+	}
+
+	holder.Tracers[traceId] = tracing.TraceFactory[name](tracer)
+
+	atomic.AddUint64(&holder.ID, 1)
+	return holder.Tracers[traceId], nil

Review Comment:
   这里是不是返回引用类型 *tracing.Trace 更好一些?涉及到对象拷贝等



##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		return nil
+	}
+	driver := NewTraceDriver()
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+
+// GetHolder return the holder of the corresponding protocol. If None, create new holder.
+func (driver *TraceDriver) GetHolder(name ProtocolName) *Holder {
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &Holder{
+			Tracers: make(map[string]Trace),
+		}
+		driver.Holders[name] = holder
+	}
+	return holder
+}
+
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {

Review Comment:
   同上,是否 *sdktrace.SpanExporter 更好一些?



##########
pkg/client/dubbo/dubbo.go:
##########
@@ -196,11 +196,10 @@ func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
 	_, span := tr.Start(req.Context, spanNameDubbogoClient)
 	trace.SpanFromContext(req.Context).SpanContext()
 	span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-	span.SetAttributes(attribute.Key(spanTagType).Array(types))
-	span.SetAttributes(attribute.Key(spanTagValues).Array(vals))
+	//span.SetAttributes(attribute.Key(spanTagType).Array(types))

Review Comment:
   为什么要注释掉这两行,因为把 vals 信息上传到链路追踪可能会有信息泄露的问题?



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r847973596


##########
pkg/tracing/driver.go:
##########
@@ -76,9 +76,10 @@ func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
 }
 func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
 	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
-	if cfg.Name == "otlp" {
+	switch cfg.Name {
+	case "otlp":
 		return otlp.NewOTLPExporter(ctx, cfg)

Review Comment:
   要么你把第一行改为 "case 'otlp', 'always':",要么你把你这句解释翻译为英语放在 default 上作为注释。



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r855089507


##########
.github/workflows/github-actions.yml:
##########
@@ -35,7 +35,7 @@ jobs:
       # If you want to matrix build , you can append the following list.
       matrix:
         go_version:
-          - 1.15
+          - 1.17

Review Comment:
   什么情况导致必须升级 go version?



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg closed pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg closed pull request #394: trace support for pixiu
URL: https://github.com/apache/dubbo-go-pixiu/pull/394


-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845757850


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTP ProtocolName = "HTTP"

Review Comment:
   HTTPProtocol



##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTP ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	Id      uint64

Review Comment:
   ID



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845758136


##########
pkg/tracing/http.go:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"net/http"
+)
+
+import (
+	"go.opentelemetry.io/otel/trace"
+)
+
+//Wrap the tracer provided by otel and be asked to implement the Trace interface
+//to customize the Span implementation.
+type Tracer struct {
+	Id string
+	T  trace.Tracer

Review Comment:
   名字补全。下面一行一样。



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r848355814


##########
pkg/tracing/driver.go:
##########
@@ -76,9 +76,10 @@ func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
 }
 func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
 	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
-	if cfg.Name == "otlp" {
+	switch cfg.Name {
+	case "otlp":
 		return otlp.NewOTLPExporter(ctx, cfg)

Review Comment:
   我修改了下,现在针对exporter默认会返回nil,也就是driver为初始化成功,并进行简单的错误处理。



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r847199451


##########
pkg/tracing/driver.go:
##########
@@ -76,9 +76,10 @@ func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
 }
 func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
 	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
-	if cfg.Name == "otlp" {
+	switch cfg.Name {
+	case "otlp":
 		return otlp.NewOTLPExporter(ctx, cfg)

Review Comment:
   这个是exporter的设置,always是采样策略,我这里默认策略是always



-- 
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


[GitHub] [dubbo-go-pixiu] PhilYue commented on pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
PhilYue commented on PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#issuecomment-1104724621

   @PhilYue 


-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r857209679


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+	"github.com/apache/dubbo-go-pixiu/pkg/logger"

Review Comment:
   已调整



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks merged pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks merged PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394


-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r847098294


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// Loading BootStrap configuration about trace
+func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		//TODO 错误处理
+		return driver
+	}
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
+	if cfg.Name == "otlp" {
+		return otlp.NewOTLPExporter(ctx, cfg)
+	} else {
+		return jaeger.NewJaegerExporter(cfg)
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),
+	)
+
+	return sdktrace.NewTracerProvider(
+		sdktrace.WithBatcher(exp),
+		sdktrace.WithResource(resource),
+		sdktrace.WithSampler(newSampler(cfg.Sampler)),
+	)
+}
+
+// Default sampler's Type: fraction
+func newSampler(sample model.Sampler) sdktrace.Sampler {
+	if sample.Type == "never" {

Review Comment:
   代码中的newExporter和newSampler都已改为switch写法



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r857198454


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+	"github.com/apache/dubbo-go-pixiu/pkg/logger"

Review Comment:
   move it to the 3rd pacakge.



##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+	"github.com/apache/dubbo-go-pixiu/pkg/logger"

Review Comment:
   move it to the 3rd package.



-- 
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


[GitHub] [dubbo-go-pixiu] PhilYue commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
PhilYue commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856876635


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		return nil
+	}
+	driver := NewTraceDriver()
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+
+// GetHolder return the holder of the corresponding protocol. If None, create new holder.
+func (driver *TraceDriver) GetHolder(name ProtocolName) *Holder {
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &Holder{
+			Tracers: make(map[string]Trace),
+		}
+		driver.Holders[name] = holder
+	}
+	return holder
+}
+
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// You must specify exporter to collect traces, otherwise return nil.
+	switch cfg.Name {
+	case "otlp":
+		return otlp.NewOTLPExporter(ctx, cfg)
+	case "jaeger":
+		return jaeger.NewJaegerExporter(cfg)
+	default:
+		return nil, errors.New("no exporter error\n")
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),

Review Comment:
   建议 使用常量 或者使用 配置获取应用名



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856928868


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {

Review Comment:
   两个我都完善了一下:
   `if config == nil {
   		logger.Warnf("[dubbo-go-pixiu] no trace configuration in conf.yaml")
   		return nil
   	}
   	ctx := context.Background()
   	exp, err := newExporter(ctx, config)
   	if err != nil {
   		logger.Warnf("[dubbo-go-pixiu] create trace exporter failed: %v", err)
   		return nil
   	}`



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845756739


##########
pkg/common/http/manager.go:
##########
@@ -81,10 +83,16 @@ func (hcm *HttpConnectionManager) ServeHTTP(w stdHttp.ResponseWriter, r *stdHttp
 	hc := hcm.pool.Get().(*pch.HttpContext)
 	defer hcm.pool.Put(hc)
 
-	hc.Request = r
 	hc.Writer = w
 	hc.Reset()
 
+	traceId := r.Header.Get("tracing-id")

Review Comment:
   ID. HTTP UDP TCP 这些专有名词统统大写,养成好的编程习惯。



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856929724


##########
pkg/client/dubbo/dubbo.go:
##########
@@ -196,11 +196,8 @@ func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
 	_, span := tr.Start(req.Context, spanNameDubbogoClient)
 	trace.SpanFromContext(req.Context).SpanContext()
 	span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-	span.SetAttributes(attribute.Key(spanTagType).Array(types))
-	span.SetAttributes(attribute.Key(spanTagValues).Array(vals))

Review Comment:
   我用json.Marshal进行了处理



-- 
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


[GitHub] [dubbo-go-pixiu] PhilYue commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
PhilYue commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856878911


##########
pkg/client/dubbo/dubbo.go:
##########
@@ -196,11 +196,10 @@ func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
 	_, span := tr.Start(req.Context, spanNameDubbogoClient)
 	trace.SpanFromContext(req.Context).SpanContext()
 	span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-	span.SetAttributes(attribute.Key(spanTagType).Array(types))
-	span.SetAttributes(attribute.Key(spanTagValues).Array(vals))
+	//span.SetAttributes(attribute.Key(spanTagType).Array(types))

Review Comment:
   将 vals 转成 String 能收集么?如果是这样,建议还是适配一下?



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r857126923


##########
.github/workflows/github-actions.yml:
##########
@@ -35,7 +35,7 @@ jobs:
       # If you want to matrix build , you can append the following list.
       matrix:
         go_version:
-          - 1.15
+          - 1.17

Review Comment:
   travis中的go版本过低,导致ci失败,所以和github-action一同升级到1.17



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856929221


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {

Review Comment:
   ```go
   if config == nil {
   	logger.Warnf("[dubbo-go-pixiu] no trace configuration in conf.yaml")
   	return nil
   }
   ctx := context.Background()
   exp, err := newExporter(ctx, config)
   if err != nil {
   	logger.Warnf("[dubbo-go-pixiu] create trace exporter failed: %v", err)
   	return nil
   }
   ```



-- 
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


[GitHub] [dubbo-go-pixiu] PhilYue commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
PhilYue commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856876441


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {

Review Comment:
   没有 exporter 时需要打印 warn 目的是方便定位问题



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#issuecomment-1094172456

   @AlexStocks 已更改


-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845757228


##########
pkg/server/otel.go:
##########
@@ -73,3 +78,46 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// Call NewTracer method to create tracer and need to specify protocol.

Review Comment:
   函数注释,以函数名开头。



##########
pkg/server/otel.go:
##########
@@ -73,3 +78,46 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// Call NewTracer method to create tracer and need to specify protocol.
+func NewTracer(name tracing.ProtocolName) tracing.Trace {
+	driver := GetTraceDriverManager().GetDriver()
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &tracing.Holder{
+			Tracers: make(map[string]tracing.Trace),
+		}
+		holder.Id = 0
+		driver.Holders[name] = holder
+	}
+	// tarceId的生成,并且在协议接口唯一
+	builder := strings.Builder{}
+	builder.WriteString(string(name))
+	builder.WriteString("-" + string(holder.Id))
+
+	traceId := builder.String()
+	tmp := driver.Tp.Tracer(traceId)
+	tracer := &tracing.Tracer{
+		Id: traceId,
+		T:  tmp,
+		H:  holder,
+	}
+
+	holder.Tracers[traceId] = tracing.TraceFactory[name](tracer)
+
+	atomic.AddUint64(&holder.Id, 1)
+	return holder.Tracers[traceId]
+}
+
+// One protocol corresponds to one type of tracers, so you need to specify both the protocol and id.
+func GetTracer(name tracing.ProtocolName, tracerId string) (tracing.Trace, error) {

Review Comment:
   同上。



-- 
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


[GitHub] [dubbo-go-pixiu] codecov-commenter commented on pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#issuecomment-1095677912

   # [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#394](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7de6b29) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/bcdbae1aa4d5899f02a5ef7a487c01ff16c37fa2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bcdbae1) will **decrease** coverage by `0.37%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop     #394      +/-   ##
   ===========================================
   - Coverage    37.00%   36.62%   -0.38%     
   ===========================================
     Files           55       55              
     Lines         3616     3653      +37     
   ===========================================
     Hits          1338     1338              
   - Misses        2126     2163      +37     
     Partials       152      152              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/client/dubbo/dubbo.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2NsaWVudC9kdWJiby9kdWJiby5nbw==) | `19.72% <ø> (+0.26%)` | :arrow_up: |
   | [pkg/common/http/manager.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2NvbW1vbi9odHRwL21hbmFnZXIuZ28=) | `41.77% <0.00%> (-2.83%)` | :arrow_down: |
   | [pkg/server/otel.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3NlcnZlci9vdGVsLmdv) | `0.00% <0.00%> (ø)` | |
   | [pkg/server/pixiu\_start.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3NlcnZlci9waXhpdV9zdGFydC5nbw==) | `3.44% <0.00%> (-0.33%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bcdbae1...7de6b29](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/394?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r845757712


##########
pkg/tracing/api.go:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel/trace"
+)
+
+//

Review Comment:
   这个接口和函数,都加上注释



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r847196661


##########
pkg/tracing/driver.go:
##########
@@ -76,9 +76,10 @@ func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
 }
 func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
 	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
-	if cfg.Name == "otlp" {
+	switch cfg.Name {
+	case "otlp":
 		return otlp.NewOTLPExporter(ctx, cfg)

Review Comment:
   case "always" 呢?



-- 
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


[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r846950996


##########
pkg/server/otel.go:
##########
@@ -73,3 +78,46 @@ func registerOtelMetricMeter(conf model.Metric) {
 		logger.Info("Prometheus server running on " + addr)
 	}
 }
+
+// Call NewTracer method to create tracer and need to specify protocol.
+func NewTracer(name tracing.ProtocolName) tracing.Trace {
+	driver := GetTraceDriverManager().GetDriver()
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &tracing.Holder{
+			Tracers: make(map[string]tracing.Trace),
+		}
+		holder.Id = 0
+		driver.Holders[name] = holder
+	}
+	// tarceId的生成,并且在协议接口唯一
+	builder := strings.Builder{}
+	builder.WriteString(string(name))
+	builder.WriteString("-" + string(holder.Id))
+
+	traceId := builder.String()
+	tmp := driver.Tp.Tracer(traceId)
+	tracer := &tracing.Tracer{
+		Id: traceId,
+		T:  tmp,
+		H:  holder,
+	}
+
+	holder.Tracers[traceId] = tracing.TraceFactory[name](tracer)
+
+	atomic.AddUint64(&holder.Id, 1)
+	return holder.Tracers[traceId]
+}
+
+// One protocol corresponds to one type of tracers, so you need to specify both the protocol and id.
+func GetTracer(name tracing.ProtocolName, tracerId string) (tracing.Trace, error) {

Review Comment:
   tracerId  -> tracerID



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r848356164


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// Loading BootStrap configuration about trace
+func (driver *TraceDriver) Init(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		//TODO 错误处理
+		return driver
+	}
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// Your preferred exporter: console, jaeger, zipkin, OTLP, etc.
+	if cfg.Name == "otlp" {
+		return otlp.NewOTLPExporter(ctx, cfg)
+	} else {
+		return jaeger.NewJaegerExporter(cfg)
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),
+	)
+
+	return sdktrace.NewTracerProvider(
+		sdktrace.WithBatcher(exp),
+		sdktrace.WithResource(resource),
+		sdktrace.WithSampler(newSampler(cfg.Sampler)),
+	)
+}
+
+// Default sampler's Type: fraction
+func newSampler(sample model.Sampler) sdktrace.Sampler {
+	if sample.Type == "never" {

Review Comment:
   针对采样策略默认是always



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856753082


##########
pkg/client/dubbo/dubbo.go:
##########
@@ -196,11 +196,10 @@ func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
 	_, span := tr.Start(req.Context, spanNameDubbogoClient)
 	trace.SpanFromContext(req.Context).SpanContext()
 	span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-	span.SetAttributes(attribute.Key(spanTagType).Array(types))
-	span.SetAttributes(attribute.Key(spanTagValues).Array(vals))
+	//span.SetAttributes(attribute.Key(spanTagType).Array(types))

Review Comment:
   Array方法在较新版本的otel里已经弃用,改用Slice,但并不支持对象,当时因为报错而直接先注释掉。https://pkg.go.dev/go.opentelemetry.io/otel/attribute#KeyValue



-- 
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


[GitHub] [dubbo-go-pixiu] PhilYue commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
PhilYue commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856880135


##########
pkg/client/dubbo/dubbo.go:
##########
@@ -196,11 +196,8 @@ func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
 	_, span := tr.Start(req.Context, spanNameDubbogoClient)
 	trace.SpanFromContext(req.Context).SpanContext()
 	span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-	span.SetAttributes(attribute.Key(spanTagType).Array(types))
-	span.SetAttributes(attribute.Key(spanTagValues).Array(vals))

Review Comment:
   将 vals 转成 String 能收集么?如果可行,建议还是适配一下?



-- 
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


[GitHub] [dubbo-go-pixiu] maxingg commented on a diff in pull request #394: trace support for pixiu

Posted by GitBox <gi...@apache.org>.
maxingg commented on code in PR #394:
URL: https://github.com/apache/dubbo-go-pixiu/pull/394#discussion_r856928764


##########
pkg/tracing/driver.go:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 tracing
+
+import (
+	"context"
+	"errors"
+)
+
+import (
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/sdk/resource"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/jaeger"
+	"github.com/apache/dubbo-go-pixiu/pkg/tracing/otlp"
+)
+
+// Different Listeners listen to different protocol requests, and create the corresponding tracer
+type ProtocolName string
+
+const HTTPProtocol ProtocolName = "HTTP"
+
+// Unique Name by making Id self-incrementing。
+type Holder struct {
+	Tracers map[string]Trace
+	ID      uint64
+}
+
+// Tracers corresponding to the listening protocol are maintained by the holder
+type TraceDriver struct {
+	Holders map[ProtocolName]*Holder
+	Tp      *sdktrace.TracerProvider
+	context context.Context
+}
+
+func NewTraceDriver() *TraceDriver {
+	return &TraceDriver{
+		Holders: make(map[ProtocolName]*Holder),
+	}
+}
+
+// InitDriver loading BootStrap configuration about trace
+func InitDriver(bs *model.Bootstrap) *TraceDriver {
+	config := bs.Trace
+	if config == nil {
+		return nil
+	}
+	ctx := context.Background()
+	exp, err := newExporter(ctx, config)
+	if err != nil {
+		return nil
+	}
+	driver := NewTraceDriver()
+	provider := newTraceProvider(exp, config)
+
+	otel.SetTracerProvider(provider)
+
+	driver.Tp = provider
+	return driver
+}
+
+// GetHolder return the holder of the corresponding protocol. If None, create new holder.
+func (driver *TraceDriver) GetHolder(name ProtocolName) *Holder {
+	holder, ok := driver.Holders[name]
+	if !ok {
+		holder = &Holder{
+			Tracers: make(map[string]Trace),
+		}
+		driver.Holders[name] = holder
+	}
+	return holder
+}
+
+func newExporter(ctx context.Context, cfg *model.TracerConfig) (sdktrace.SpanExporter, error) {
+	// You must specify exporter to collect traces, otherwise return nil.
+	switch cfg.Name {
+	case "otlp":
+		return otlp.NewOTLPExporter(ctx, cfg)
+	case "jaeger":
+		return jaeger.NewJaegerExporter(cfg)
+	default:
+		return nil, errors.New("no exporter error\n")
+	}
+}
+
+func newTraceProvider(exp sdktrace.SpanExporter, cfg *model.TracerConfig) *sdktrace.TracerProvider {
+	// The service.name attribute is required.
+	resource := resource.NewWithAttributes(
+		semconv.SchemaURL,
+		semconv.ServiceNameKey.String("dubbo-go-pixiu"),

Review Comment:
   好的,这里我在trace的model里加一个属性,另外定义ServiceName常量,如果conf.yaml未设置就采用默认值。



-- 
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