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/23 10:18:20 UTC

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

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