This is an automated email from the ASF dual-hosted git repository.
xuetaoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/main by this push:
new b82b45e0 feat: migrate otel and remove old seata-go (#959)
b82b45e0 is described below
commit b82b45e0915fe86f61a696becf2343e92982b9f6
Author: zbchi <[email protected]>
AuthorDate: Tue Nov 18 20:45:09 2025 +0800
feat: migrate otel and remove old seata-go (#959)
* chore: remove duplicated compatibility/seata-go
---
README.md | 2 -
README_CN.md | 2 -
compatibility/otel/trace/config/config.go | 49 ------
.../otel/trace/go-client/conf/dubbogo.yaml | 14 --
compatibility/otel/trace/go-server/cmd/main.go | 59 -------
.../otel/trace/go-server/conf/dubbogo.yaml | 16 --
compatibility/seata-go/README.md | 12 --
compatibility/seata-go/README_zh.md | 12 --
compatibility/seata-go/docker-compose.yml | 33 ----
compatibility/seata-go/tcc/README.md | 12 --
compatibility/seata-go/tcc/client/cmd/client.go | 72 --------
compatibility/seata-go/tcc/client/conf/dubbogo.yml | 32 ----
compatibility/seata-go/tcc/server/cmd/server.go | 84 ---------
compatibility/seata-go/tcc/server/conf/dubbogo.yml | 36 ----
.../seata-go/tcc/server/service/user_provider.go | 51 ------
go.mod | 6 +-
otel/tracing/README.md | 6 +-
otel/tracing/README_zh.md | 86 ++++++++++
otel/tracing/jaeger/README.md | 67 ++++++++
otel/tracing/jaeger/README_zh.md | 67 ++++++++
.../tracing/jaeger}/go-client/cmd/main.go | 48 ++++--
.../tracing/jaeger/go-server}/cmd/main.go | 48 ++++--
otel/tracing/jaeger/proto/greet.pb.go | 191 +++++++++++++++++++++
.../tracing/jaeger/proto/greet.proto | 28 ++-
otel/tracing/jaeger/proto/greet.triple.go | 122 +++++++++++++
otel/tracing/stdout/README.md | 8 +-
otel/tracing/stdout/{README.md => README_zh.md} | 21 ++-
transcation/seata-go/non-idl/client/cmd/client.go | 3 +-
28 files changed, 634 insertions(+), 553 deletions(-)
diff --git a/README.md b/README.md
index 802356f1..7f97d272 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,6 @@
* compatibility/game: Game service example
* compatibility/generic: Generic invocation example
* compatibility/mesh: Proxy service mesh example showing how to deploy
Dubbo-go services with Envoy on Kubernetes
-* compatibility/otel: How to use OpenTelemetry as Dubbo-go tracing tool
* compatibility/proxyless: Proxyless service mesh example for deploying
Dubbo-go services on Kubernetes
* compatibility/registry: How to use etcd/nacos/zookeeper as Dubbo-go registry
* compatibility/rpc: Dubbo protocol communication examples
@@ -24,7 +23,6 @@
* compatibility/rpc/grpc: Dubbo-go RPC example based on gRPC
* compatibility/rpc/jsonrpc: Dubbo-go RPC example based on JSON-RPC
* compatibility/rpc/triple: Dubbo-go RPC example based on
hessian2/msgpack/pb(protobuf-v3)/pb2(protobuf-v2)/self-defined-serialization
-* compatibility/seata-go: Seata-go distributed transaction example
* compatibility/skywalking: How to integrate SkyWalking into Dubbo-go
* compatibility/tls: Use TLS encryption in getty (tcp)/triple/gRPC
communication mode
* compatibility/tracing: Tracing example
diff --git a/README_CN.md b/README_CN.md
index c57c8827..0aa7e679 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -12,7 +12,6 @@
* compatibility/game:游戏服务示例
* compatibility/generic:泛化调用示例
* compatibility/mesh:基于 Envoy 的服务网格部署示例
-* compatibility/otel:OpenTelemetry 链路追踪示例
* compatibility/proxyless:Kubernetes 下 proxyless 服务网格示例
* compatibility/registry:多种注册中心(etcd/nacos/zookeeper)用法
* compatibility/rpc:Dubbo 协议通信示例
@@ -20,7 +19,6 @@
* compatibility/rpc/grpc:基于 gRPC 的 Dubbo-go RPC 示例
* compatibility/rpc/jsonrpc:基于 JSON-RPC 的 Dubbo-go RPC 示例
* compatibility/rpc/triple:支持多种序列化(hessian2/msgpack/pb/pb2/自定义)的 triple 协议示例
-* compatibility/seata-go:seata-go 分布式事务示例
* compatibility/skywalking:集成 SkyWalking 的 Dubbo-go 示例
* compatibility/tls:getty(tcp)/triple/gRPC 全链路 TLS 加密通信示例
* compatibility/tracing:链路追踪示例
diff --git a/compatibility/otel/trace/config/config.go
b/compatibility/otel/trace/config/config.go
deleted file mode 100644
index af9db0f9..00000000
--- a/compatibility/otel/trace/config/config.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package config
-
-import (
- "log"
-)
-
-import (
- "go.opentelemetry.io/otel"
- "go.opentelemetry.io/otel/exporters/jaeger"
- "go.opentelemetry.io/otel/propagation"
- "go.opentelemetry.io/otel/sdk/resource"
- sdktrace "go.opentelemetry.io/otel/sdk/trace"
- semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
-)
-
-// Init configures an OpenTelemetry exporter and trace provider
-func Init() *sdktrace.TracerProvider {
- exporter, err :=
jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint("http://localhost:16686/api/traces")))
- if err != nil {
- log.Fatal(err)
- }
- tp := sdktrace.NewTracerProvider(
- sdktrace.WithSampler(sdktrace.AlwaysSample()),
- sdktrace.WithBatcher(exporter),
- sdktrace.WithResource(resource.NewSchemaless(
- semconv.ServiceNameKey.String("oteldubbo"),
- )),
- )
- otel.SetTracerProvider(tp)
-
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{},
propagation.Baggage{}))
- return tp
-}
diff --git a/compatibility/otel/trace/go-client/conf/dubbogo.yaml
b/compatibility/otel/trace/go-client/conf/dubbogo.yaml
deleted file mode 100644
index 6c686ef4..00000000
--- a/compatibility/otel/trace/go-client/conf/dubbogo.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-dubbo:
- registries:
- demoZK:
- protocol: zookeeper
- timeout: 3s
- address: 127.0.0.1:2181
- consumer:
- filter: otelClientTrace
- check: true
- request_timeout: 3s
- connect_timeout: 3s
- references:
- GreeterClientImpl:
- protocol: tri
\ No newline at end of file
diff --git a/compatibility/otel/trace/go-server/cmd/main.go
b/compatibility/otel/trace/go-server/cmd/main.go
deleted file mode 100644
index c2a18fb7..00000000
--- a/compatibility/otel/trace/go-server/cmd/main.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 main
-
-import (
- "context"
- "log"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
-
- "github.com/dubbogo/gost/log/logger"
-)
-
-import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
- otelconfig
"github.com/apache/dubbo-go-samples/compatibility/otel/trace/config"
-)
-
-type GreeterProvider struct {
- api.UnimplementedGreeterServer
-}
-
-func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest)
(*api.User, error) {
- logger.Infof("Dubbo3 GreeterProvider get user name = %s\n", in.Name)
- return &api.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
-}
-
-// export DUBBO_GO_CONFIG_PATH=
PATH_TO_SAMPLES/helloworld/go-server/conf/dubbogo.yml
-func main() {
- tp := otelconfig.Init()
- defer func() {
- if err := tp.Shutdown(context.Background()); err != nil {
- log.Printf("Error shutting down tracer provider: %v",
err)
- }
- }()
- config.SetProviderService(&GreeterProvider{})
- if err := config.Load(); err != nil {
- panic(err)
- }
- select {}
-}
diff --git a/compatibility/otel/trace/go-server/conf/dubbogo.yaml
b/compatibility/otel/trace/go-server/conf/dubbogo.yaml
deleted file mode 100644
index 66a48393..00000000
--- a/compatibility/otel/trace/go-server/conf/dubbogo.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-dubbo:
- registries:
- demoZK:
- protocol: zookeeper
- address: 127.0.0.1:2181
- protocols:
- tripleProtocol:
- name: tri
- port: 20000
- provider:
- services:
- GreeterProvider:
- filter: otelServerTrace
- loadbalance: random
- warmup: 100
- cluster: failover
diff --git a/compatibility/seata-go/README.md b/compatibility/seata-go/README.md
deleted file mode 100644
index 46cc4ef8..00000000
--- a/compatibility/seata-go/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Seata-go tcc example
-
-## How to run?
-
-1. Start the seata-server and zookeeper service with the docker file.
-
- ~~~shell
- cd seata-go/tcc
- docker-compose -f docker-compose.yml up -d seata-server zookeeper
- ~~~
-
-2. Just execute the main function under tcc/client/cmd and tcc/server/cmd
directory.
\ No newline at end of file
diff --git a/compatibility/seata-go/README_zh.md
b/compatibility/seata-go/README_zh.md
deleted file mode 100644
index 46a37ba3..00000000
--- a/compatibility/seata-go/README_zh.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Seata-go tcc 例子
-
-## 如何运行?
-
-1. 先执行以下命令,启动 seata-server和zookeeper。
-
- ~~~shell
- cd seata-go/tcc
- docker-compose -f docker-compose.yml up -d seata-server zookeeper
- ~~~
-
-2. 再执行 tcc/client/cmd 和 tcc/server/cmd 目录下的main()方法。
\ No newline at end of file
diff --git a/compatibility/seata-go/docker-compose.yml
b/compatibility/seata-go/docker-compose.yml
deleted file mode 100644
index 14003149..00000000
--- a/compatibility/seata-go/docker-compose.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# 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.
-#
-
-version: '3'
-services:
- seata-server:
- image: seataio/seata-server:1.5.2
- ports:
- - "8091:8091"
- - "7091:7091"
- environment:
- - SEATA_PORT=8091
- - STORE_MODE=file
-
- zookeeper:
- image: zookeeper
- ports:
- - "2181:2181"
- restart: on-failure
\ No newline at end of file
diff --git a/compatibility/seata-go/tcc/README.md
b/compatibility/seata-go/tcc/README.md
deleted file mode 100644
index b18cb9ec..00000000
--- a/compatibility/seata-go/tcc/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Seata-go tcc example
-
-## How to run
-
-1. Start the seata-server and zookeeper service with the docker file
-
- ~~~shell
- cd seata-go/tcc
- docker-compose -f docker-compose.yml up -d seata-server zookeeper
- ~~~
-
-2. Just execute the main function under tcc/client/cmd and tcc/server/cmd
directory
\ No newline at end of file
diff --git a/compatibility/seata-go/tcc/client/cmd/client.go
b/compatibility/seata-go/tcc/client/cmd/client.go
deleted file mode 100644
index cd1ee7b2..00000000
--- a/compatibility/seata-go/tcc/client/cmd/client.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 main
-
-import (
- "context"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
-
- "github.com/dubbogo/gost/log/logger"
-
- _ "github.com/seata/seata-go/pkg/imports"
- "github.com/seata/seata-go/pkg/integration"
- "github.com/seata/seata-go/pkg/rm/tcc"
- "github.com/seata/seata-go/pkg/tm"
-)
-
-import (
-
"github.com/apache/dubbo-go-samples/compatibility/seata-go/tcc/client/service"
-)
-
-// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to
"seata-go/tcc/client/conf/dubbogo.yml"
-// and run "seata-go/tcc/server/cmd/server.go" before run
-func main() {
- integration.UseDubbo()
- config.SetConsumerService(service.UserProviderInstance)
- err := config.Load()
- if err != nil {
- panic(err)
- }
- test()
-}
-
-func test() {
- var err error
- ctx := tm.Begin(context.Background(), "TestTCCServiceBusiness")
- defer func() {
- resp := tm.CommitOrRollback(ctx, err == nil)
- logger.Infof("tx result %v", resp)
- <-make(chan struct{})
- }()
-
- userProviderProxy, err :=
tcc.NewTCCServiceProxy(service.UserProviderInstance)
- if err != nil {
- logger.Infof("userProviderProxyis not tcc service")
- return
- }
- resp, err := userProviderProxy.Prepare(ctx, 1)
- if err != nil {
- logger.Infof("response prepare: %v", err)
- return
- }
- logger.Infof("get resp %#v", resp)
-}
diff --git a/compatibility/seata-go/tcc/client/conf/dubbogo.yml
b/compatibility/seata-go/tcc/client/conf/dubbogo.yml
deleted file mode 100644
index 9f50cd70..00000000
--- a/compatibility/seata-go/tcc/client/conf/dubbogo.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# 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.
-#
-
-# dubbo client yaml configure file
-dubbo:
- registries:
- demoZK:
- protocol: zookeeper
- address: 127.0.0.1:2181
- consumer:
- filter: seataDubboFilter
- references:
- UserProvider:
- protocol: dubbo
- interface: com.github.seata.sample.UserProvider
- logger:
- zap-config:
- level: info
\ No newline at end of file
diff --git a/compatibility/seata-go/tcc/server/cmd/server.go
b/compatibility/seata-go/tcc/server/cmd/server.go
deleted file mode 100644
index 39e295de..00000000
--- a/compatibility/seata-go/tcc/server/cmd/server.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 main
-
-import (
- "fmt"
- "os"
- "os/signal"
- "syscall"
- "time"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
-
- "github.com/dubbogo/gost/log/logger"
-
- _ "github.com/seata/seata-go/pkg/imports"
- "github.com/seata/seata-go/pkg/integration"
- "github.com/seata/seata-go/pkg/rm/tcc"
-)
-
-import (
-
"github.com/apache/dubbo-go-samples/compatibility/seata-go/tcc/server/service"
-)
-
-// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to
"seata-go/tcc/server/conf/dubbogo.yml" before run
-func main() {
- integration.UseDubbo()
- userProviderProxy, err :=
tcc.NewTCCServiceProxy(&service.UserProvider{})
- if err != nil {
- logger.Errorf("get userProviderProxy tcc service proxy error,
%v", err.Error())
- return
- }
- // server should register resource
- err = userProviderProxy.RegisterResource()
- if err != nil {
- logger.Errorf("userProviderProxy register resource error, %v",
err.Error())
- return
- }
- config.SetProviderService(userProviderProxy)
- if err := config.Load(); err != nil {
- panic(err)
- }
- initSignal()
-}
-
-func initSignal() {
- signals := make(chan os.Signal, 1)
- // It is not possible to block SIGKILL or syscall.SIGSTOP
- signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
- for {
- sig := <-signals
- logger.Infof("get signal %s", sig.String())
- switch sig {
- case syscall.SIGHUP:
- // reload()
- default:
- time.AfterFunc(time.Duration(int(3e9)), func() {
- logger.Warnf("app exit now by force...")
- os.Exit(1)
- })
- // The program exits normally or timeout forcibly exits.
- fmt.Println("provider app exit now...")
- return
- }
- }
-}
diff --git a/compatibility/seata-go/tcc/server/conf/dubbogo.yml
b/compatibility/seata-go/tcc/server/conf/dubbogo.yml
deleted file mode 100644
index ee9a77c3..00000000
--- a/compatibility/seata-go/tcc/server/conf/dubbogo.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# 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.
-#
-
-# dubbo server yaml configure file
-dubbo:
- registries:
- demoZK:
- protocol: zookeeper
- timeout: 3s
- address: 127.0.0.1:2181
- protocols:
- dubbo:
- name: dubbo
- port: 20000
- provider:
- services:
- UserProvider:
- interface: com.github.seata.sample.UserProvider
- filter: seataDubboFilter
- logger:
- zap-config:
- level: info
diff --git a/compatibility/seata-go/tcc/server/service/user_provider.go
b/compatibility/seata-go/tcc/server/service/user_provider.go
deleted file mode 100644
index a5fef0cd..00000000
--- a/compatibility/seata-go/tcc/server/service/user_provider.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 service
-
-import (
- "context"
-)
-
-import (
- "github.com/dubbogo/gost/log/logger"
-
- "github.com/seata/seata-go/pkg/tm"
-)
-
-type UserProvider struct {
-}
-
-func (t *UserProvider) Prepare(ctx context.Context, params ...interface{})
(bool, error) {
- logger.Infof("Prepare result: %v, xid %v", params, tm.GetXID(ctx))
- return true, nil
-}
-
-func (t *UserProvider) Commit(ctx context.Context, businessActionContext
*tm.BusinessActionContext) (bool, error) {
- logger.Infof("Commit result: %v, xid %s", businessActionContext,
tm.GetXID(ctx))
- return true, nil
-}
-
-func (t *UserProvider) Rollback(ctx context.Context, businessActionContext
*tm.BusinessActionContext) (bool, error) {
- logger.Infof("Rollback result: %v, xid %s", businessActionContext,
tm.GetXID(ctx))
- return true, nil
-}
-
-func (t *UserProvider) GetActionName() string {
- logger.Infof("GetActionName result")
- return "TwoPhaseDemoService"
-}
diff --git a/go.mod b/go.mod
index bcc4f822..bf6974d0 100644
--- a/go.mod
+++ b/go.mod
@@ -28,9 +28,6 @@ require (
github.com/stretchr/testify v1.9.0
github.com/tmc/langchaingo v0.1.13
github.com/uber/jaeger-client-go v2.30.0+incompatible
- go.opentelemetry.io/otel v1.26.0
- go.opentelemetry.io/otel/exporters/jaeger v1.17.0
- go.opentelemetry.io/otel/sdk v1.21.0
go.opentelemetry.io/proto/otlp v1.0.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
@@ -149,12 +146,15 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/v3 v3.5.7 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.10.0 // indirect
+ go.opentelemetry.io/otel v1.26.0 // indirect
+ go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0
// indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0
// indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 //
indirect
go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
+ go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/mock v0.5.0 // indirect
diff --git a/otel/tracing/README.md b/otel/tracing/README.md
index 23747501..faa78ff6 100644
--- a/otel/tracing/README.md
+++ b/otel/tracing/README.md
@@ -1,14 +1,16 @@
# Tracing
+English | [中文](./README_zh.md)
+
## Background
Dubbo-go supports [OpenTelemetry](https://opentelemetry.io/) tracing.
- [Stdout exporter](./stdout)
- [Jaeger exporter](./jaeger)
-- [Zipkin exporter](./zipkin)
+<!-- - [Zipkin exporter](./zipkin) -->
- [OTLP-HTTP exporter](./otlp-http)
-- [OTLP-gRPC exporter](./otlp-grpc)
+<!-- - [OTLP-gRPC exporter](./otlp-grpc) -->
## Usage
diff --git a/otel/tracing/README_zh.md b/otel/tracing/README_zh.md
new file mode 100644
index 00000000..0a4c26dc
--- /dev/null
+++ b/otel/tracing/README_zh.md
@@ -0,0 +1,86 @@
+# 链路追踪
+
+[English](./README.md) | 中文
+
+## 背景
+
+Dubbo-go 支持 [OpenTelemetry](https://opentelemetry.io/) 链路追踪。
+
+- [Stdout 导出器](./stdout)
+- [Jaeger 导出器](./jaeger)
+<!-- - [Zipkin 导出器](./zipkin) -->
+- [OTLP-HTTP 导出器](./otlp-http)
+<!-- - [OTLP-gRPC 导出器](./otlp-grpc) -->
+
+## 使用方法
+
+### 创建 Dubbo 实例
+
+要使用链路追踪功能,你需要使用 `dubbo.NewInstance` 来创建一个 Dubbo 实例。
+
+如果你直接创建 server 和 client,只能启用基本的 RPC 功能。
+
+### 使用链路追踪功能
+
+要配置链路追踪,你需要使用 `dubbo.WithTracing` 作为 `dubbo.NewInstance` 的选项。在
`dubbo.WithTracing` 中,你可以添加更多选项来配置链路追踪模块。
+
+并且必须导入 `dubbo.apache.org/dubbo-go/v3/imports` 包。
+
+```go
+package main
+
+import (
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "dubbo.apache.org/dubbo-go/v3/otel/trace"
+)
+
+func main() {
+ instance, err := dubbo.NewInstance(
+ dubbo.WithTracing(
+ // 在这里添加链路追踪选项
+ trace.WithEnabled(), // 启用链路追踪功能
+ trace.WithStdoutExporter(),
+ trace.WithW3cPropagator(),
+ trace.WithAlwaysMode(),
+ trace.WithRatioMode(), // 使用比例模式
+ trace.WithRatio(0.5), // 采样比例,仅在使用比例模式时生效
+ ),
+ )
+}
+
+```
+
+如果你在 `dubbo.WithTracing` 中不添加任何选项,将使用默认的链路追踪配置。默认配置如下所示。
+
+```yaml
+# 默认链路追踪配置
+enable: false
+exporter: stdout
+endpoint: ""
+propagator: w3c
+sample-mode: ratio
+sample-ratio: 0.5
+```
+
+### 选项说明
+
+- enable: 是否启用链路追踪
+ - `trace.WithEnabled()` 表示启用链路追踪
+- exporter: 链路追踪导出器后端,支持 stdout、jaeger、zipkin、otlp-http、otlp-grpc
+ - `trace.WithStdoutExporter()`
+ - `trace.WithJaegerExporter()`
+ - `trace.WithZipkinExporter()`
+ - `trace.WithOtlpHttpExporter()`
+ - `trace.WithOtlpGrpcExporter()`
+- endpoint: 导出器后端端点,例如,jaeger 导出器的端点是 `http://localhost:14268/api/traces`
+ - `trace.WithEndpoint(string)`
+- propagator: 上下文传播器类型,支持
w3c、b3,更多详情请参见[这里](https://opentelemetry.io/docs/concepts/context-propagation/)
+ - `trace.WithW3cPropagator()`
+ - `trace.WithB3Propagator()` zipkin 导出器默认使用此选项
+- sample-mode: 采样模式,支持 ratio(比例)、always(总是)、never(从不)
+ - `trace.WithAlwaysMode()`
+ - `trace.WithNeverMode()`
+ - `trace.WithRatioMode()`
+- sample-ratio: 采样比例,仅在采样模式为 ratio 时使用,范围在 0 到 1 之间
+ - `trace.WithRatio(float64)`
diff --git a/otel/tracing/jaeger/README.md b/otel/tracing/jaeger/README.md
new file mode 100644
index 00000000..2a8cb872
--- /dev/null
+++ b/otel/tracing/jaeger/README.md
@@ -0,0 +1,67 @@
+# Jaeger tracing exporter
+
+[English](README.md) | [中文](README_zh.md)
+
+This example shows dubbo-go's tracing feature with Jaeger exporter.
+
+## Prerequisites
+
+Before running this example, you need to start a Jaeger instance. You can use
Docker to run Jaeger:
+
+```shell
+docker run -d --name jaeger \
+ -e COLLECTOR_OTLP_ENABLED=true \
+ -p 16686:16686 \
+ -p 14268:14268 \
+ -p 4317:4317 \
+ -p 4318:4318 \
+ jaegertracing/all-in-one:latest
+```
+
+Or use docker-compose:
+
+```yaml
+version: '3'
+services:
+ jaeger:
+ image: jaegertracing/all-in-one:latest
+ ports:
+ - "16686:16686" # Jaeger UI
+ - "14268:14268" # Jaeger collector HTTP endpoint
+ environment:
+ - COLLECTOR_OTLP_ENABLED=true
+```
+
+## How to run
+
+### Run server
+
+```shell
+$ go run ./go-server/cmd/main.go
+```
+
+### Run client
+
+```shell
+$ go run ./go-client/cmd/main.go
+```
+
+## View traces
+
+After running the client and server, you can view the traces in the Jaeger UI:
+
+1. Open your browser and navigate to `http://localhost:16686`
+2. Select the service name (e.g., `dubbo_otel_jaeger_server` or
`dubbo_otel_jaeger_client`)
+3. Click "Find Traces" to see the tracing data
+
+## Configuration
+
+The Jaeger exporter is configured with the following options:
+
+- `trace.WithJaegerExporter()`: Use Jaeger as the tracing exporter
+- `trace.WithEndpoint("http://localhost:14268/api/traces")`: Set the Jaeger
collector endpoint
+- `trace.WithW3cPropagator()`: Use W3C trace context propagation
+- `trace.WithAlwaysMode()`: Always sample traces
+
+You can modify the endpoint to point to your Jaeger instance if it's running
on a different host or port.
+
diff --git a/otel/tracing/jaeger/README_zh.md b/otel/tracing/jaeger/README_zh.md
new file mode 100644
index 00000000..865b65a2
--- /dev/null
+++ b/otel/tracing/jaeger/README_zh.md
@@ -0,0 +1,67 @@
+# Jaeger 链路追踪导出器
+
+[English](README.md) | [中文](README_zh.md)
+
+本示例展示了 dubbo-go 使用 Jaeger 导出器的链路追踪功能。
+
+## 前置条件
+
+在运行本示例之前,需要先启动一个 Jaeger 实例。可以使用 Docker 运行 Jaeger:
+
+```shell
+docker run -d --name jaeger \
+ -e COLLECTOR_OTLP_ENABLED=true \
+ -p 16686:16686 \
+ -p 14268:14268 \
+ -p 4317:4317 \
+ -p 4318:4318 \
+ jaegertracing/all-in-one:latest
+```
+
+或者使用 docker-compose:
+
+```yaml
+version: '3'
+services:
+ jaeger:
+ image: jaegertracing/all-in-one:latest
+ ports:
+ - "16686:16686" # Jaeger UI
+ - "14268:14268" # Jaeger collector HTTP 端点
+ environment:
+ - COLLECTOR_OTLP_ENABLED=true
+```
+
+## 运行方法
+
+### 启动服务端
+
+```shell
+$ go run ./go-server/cmd/main.go
+```
+
+### 启动客户端
+
+```shell
+$ go run ./go-client/cmd/main.go
+```
+
+## 查看追踪数据
+
+运行客户端和服务端后,可以在 Jaeger UI 中查看追踪数据:
+
+1. 在浏览器中打开 `http://localhost:16686`
+2. 选择服务名称(例如 `dubbo_otel_jaeger_server` 或 `dubbo_otel_jaeger_client`)
+3. 点击 "Find Traces" 查看追踪数据
+
+## 配置说明
+
+Jaeger 导出器通过以下选项进行配置:
+
+- `trace.WithJaegerExporter()`: 使用 Jaeger 作为链路追踪导出器
+- `trace.WithEndpoint("http://localhost:14268/api/traces")`: 设置 Jaeger
collector 端点
+- `trace.WithW3cPropagator()`: 使用 W3C 追踪上下文传播
+- `trace.WithAlwaysMode()`: 始终采样追踪数据
+
+如果 Jaeger 实例运行在不同的主机或端口上,可以修改端点地址。
+
diff --git a/compatibility/otel/trace/go-client/cmd/main.go
b/otel/tracing/jaeger/go-client/cmd/main.go
similarity index 56%
copy from compatibility/otel/trace/go-client/cmd/main.go
copy to otel/tracing/jaeger/go-client/cmd/main.go
index b6e20430..a980b8a3 100644
--- a/compatibility/otel/trace/go-client/cmd/main.go
+++ b/otel/tracing/jaeger/go-client/cmd/main.go
@@ -19,41 +19,51 @@ package main
import (
"context"
- "log"
)
import (
- "dubbo.apache.org/dubbo-go/v3/config"
+ "dubbo.apache.org/dubbo-go/v3"
+ "dubbo.apache.org/dubbo-go/v3/client"
_ "dubbo.apache.org/dubbo-go/v3/imports"
+ "dubbo.apache.org/dubbo-go/v3/otel/trace"
"github.com/dubbogo/gost/log/logger"
)
import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
- otelconfig
"github.com/apache/dubbo-go-samples/compatibility/otel/trace/config"
+ greet "github.com/apache/dubbo-go-samples/otel/tracing/jaeger/proto"
)
-var userProvider = &api.GreeterClientImpl{}
-
-func init() {
- config.SetConsumerService(userProvider)
-}
-
func main() {
- tp := otelconfig.Init()
- defer func() {
- if err := tp.Shutdown(context.Background()); err != nil {
- log.Printf("Error shutting down tracer provider: %v",
err)
- }
- }()
- err := config.Load()
+ ins, err := dubbo.NewInstance(
+ dubbo.WithName("dubbo_otel_jaeger_client"),
+ dubbo.WithTracing(
+ trace.WithEnabled(),
+ trace.WithJaegerExporter(),
+ trace.WithW3cPropagator(),
+ trace.WithAlwaysMode(),
+ trace.WithEndpoint("http://localhost:14268/api/traces"),
+ ),
+ )
if err != nil {
panic(err)
}
- user, err := userProvider.SayHello(context.TODO(),
&api.HelloRequest{Name: "zheyu"})
+
+ cli, err := ins.NewClient(
+ client.WithClientURL("127.0.0.1:20000"),
+ )
if err != nil {
panic(err)
}
- logger.Infof("get user = %+v", user)
+
+ svc, err := greet.NewGreetService(cli)
+ if err != nil {
+ panic(err)
+ }
+
+ resp, err := svc.Greet(context.Background(), &greet.GreetRequest{Name:
"hello world"})
+ if err != nil {
+ logger.Error(err)
+ }
+ logger.Infof("Greet response: %s", resp)
}
diff --git a/compatibility/otel/trace/go-client/cmd/main.go
b/otel/tracing/jaeger/go-server/cmd/main.go
similarity index 50%
rename from compatibility/otel/trace/go-client/cmd/main.go
rename to otel/tracing/jaeger/go-server/cmd/main.go
index b6e20430..97c2a90c 100644
--- a/compatibility/otel/trace/go-client/cmd/main.go
+++ b/otel/tracing/jaeger/go-server/cmd/main.go
@@ -19,41 +19,57 @@ package main
import (
"context"
- "log"
)
import (
- "dubbo.apache.org/dubbo-go/v3/config"
+ "dubbo.apache.org/dubbo-go/v3"
_ "dubbo.apache.org/dubbo-go/v3/imports"
+ "dubbo.apache.org/dubbo-go/v3/otel/trace"
+ "dubbo.apache.org/dubbo-go/v3/protocol"
+ "dubbo.apache.org/dubbo-go/v3/server"
"github.com/dubbogo/gost/log/logger"
)
import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
- otelconfig
"github.com/apache/dubbo-go-samples/compatibility/otel/trace/config"
+ greet "github.com/apache/dubbo-go-samples/otel/tracing/jaeger/proto"
)
-var userProvider = &api.GreeterClientImpl{}
+type GreetTripleServer struct {
+}
-func init() {
- config.SetConsumerService(userProvider)
+func (srv *GreetTripleServer) Greet(ctx context.Context, req
*greet.GreetRequest) (*greet.GreetResponse, error) {
+ resp := &greet.GreetResponse{Greeting: req.Name}
+ return resp, nil
}
func main() {
- tp := otelconfig.Init()
- defer func() {
- if err := tp.Shutdown(context.Background()); err != nil {
- log.Printf("Error shutting down tracer provider: %v",
err)
- }
- }()
- err := config.Load()
+ ins, err := dubbo.NewInstance(
+ dubbo.WithName("dubbo_otel_jaeger_server"),
+ dubbo.WithTracing(
+ trace.WithEnabled(),
+ trace.WithJaegerExporter(),
+ trace.WithW3cPropagator(),
+ trace.WithAlwaysMode(),
+ trace.WithEndpoint("http://localhost:14268/api/traces"),
+ ),
+ )
if err != nil {
panic(err)
}
- user, err := userProvider.SayHello(context.TODO(),
&api.HelloRequest{Name: "zheyu"})
+
+ srv, err := ins.NewServer(
+ server.WithServerProtocol(protocol.WithPort(20000),
protocol.WithTriple()),
+ )
if err != nil {
panic(err)
}
- logger.Infof("get user = %+v", user)
+
+ if err := greet.RegisterGreetServiceHandler(srv, &GreetTripleServer{});
err != nil {
+ panic(err)
+ }
+
+ if err := srv.Serve(); err != nil {
+ logger.Error(err)
+ }
}
diff --git a/otel/tracing/jaeger/proto/greet.pb.go
b/otel/tracing/jaeger/proto/greet.pb.go
new file mode 100644
index 00000000..fc3106f9
--- /dev/null
+++ b/otel/tracing/jaeger/proto/greet.pb.go
@@ -0,0 +1,191 @@
+//
+// 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.
+
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.36.6
+// protoc v6.31.1
+// source: greet.proto
+
+package greet
+
+import (
+ reflect "reflect"
+ sync "sync"
+ unsafe "unsafe"
+
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type GreetRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Name string
`protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *GreetRequest) Reset() {
+ *x = GreetRequest{}
+ mi := &file_greet_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *GreetRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GreetRequest) ProtoMessage() {}
+
+func (x *GreetRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_greet_proto_msgTypes[0]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GreetRequest.ProtoReflect.Descriptor instead.
+func (*GreetRequest) Descriptor() ([]byte, []int) {
+ return file_greet_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *GreetRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+type GreetResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Greeting string
`protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *GreetResponse) Reset() {
+ *x = GreetResponse{}
+ mi := &file_greet_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *GreetResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GreetResponse) ProtoMessage() {}
+
+func (x *GreetResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_greet_proto_msgTypes[1]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GreetResponse.ProtoReflect.Descriptor instead.
+func (*GreetResponse) Descriptor() ([]byte, []int) {
+ return file_greet_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *GreetResponse) GetGreeting() string {
+ if x != nil {
+ return x.Greeting
+ }
+ return ""
+}
+
+var File_greet_proto protoreflect.FileDescriptor
+
+const file_greet_proto_rawDesc = "" +
+ "\n" +
+ "\vgreet.proto\x12\x05greet\"\"\n" +
+ "\fGreetRequest\x12\x12\n" +
+ "\x04name\x18\x01 \x01(\tR\x04name\"+\n" +
+ "\rGreetResponse\x12\x1a\n" +
+ "\bgreeting\x18\x01 \x01(\tR\bgreeting2D\n" +
+ "\fGreetService\x124\n" +
+
"\x05Greet\x12\x13.greet.GreetRequest\x1a\x14.greet.GreetResponse\"\x00BDZBgithub.com/apache/dubbo-go-samples/otel/tracing/jaeger/proto;greetb\x06proto3"
+
+var (
+ file_greet_proto_rawDescOnce sync.Once
+ file_greet_proto_rawDescData []byte
+)
+
+func file_greet_proto_rawDescGZIP() []byte {
+ file_greet_proto_rawDescOnce.Do(func() {
+ file_greet_proto_rawDescData =
protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_greet_proto_rawDesc),
len(file_greet_proto_rawDesc)))
+ })
+ return file_greet_proto_rawDescData
+}
+
+var file_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_greet_proto_goTypes = []any{
+ (*GreetRequest)(nil), // 0: greet.GreetRequest
+ (*GreetResponse)(nil), // 1: greet.GreetResponse
+}
+var file_greet_proto_depIdxs = []int32{
+ 0, // 0: greet.GreetService.Greet:input_type -> greet.GreetRequest
+ 1, // 1: greet.GreetService.Greet:output_type -> greet.GreetResponse
+ 1, // [1:2] is the sub-list for method output_type
+ 0, // [0:1] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_greet_proto_init() }
+func file_greet_proto_init() {
+ if File_greet_proto != nil {
+ return
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor:
unsafe.Slice(unsafe.StringData(file_greet_proto_rawDesc),
len(file_greet_proto_rawDesc)),
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_greet_proto_goTypes,
+ DependencyIndexes: file_greet_proto_depIdxs,
+ MessageInfos: file_greet_proto_msgTypes,
+ }.Build()
+ File_greet_proto = out.File
+ file_greet_proto_goTypes = nil
+ file_greet_proto_depIdxs = nil
+}
diff --git a/compatibility/seata-go/tcc/client/service/user_provider.go
b/otel/tracing/jaeger/proto/greet.proto
similarity index 55%
rename from compatibility/seata-go/tcc/client/service/user_provider.go
rename to otel/tracing/jaeger/proto/greet.proto
index 9ab9c20b..866bb98f 100644
--- a/compatibility/seata-go/tcc/client/service/user_provider.go
+++ b/otel/tracing/jaeger/proto/greet.proto
@@ -15,23 +15,21 @@
* limitations under the License.
*/
-package service
+syntax = "proto3";
-import (
- "context"
-)
+package greet;
-import (
- "github.com/seata/seata-go/pkg/tm"
-)
+option go_package =
"github.com/apache/dubbo-go-samples/otel/tracing/jaeger/proto;greet";
-var (
- UserProviderInstance = &UserProvider{}
-)
+message GreetRequest {
+ string name = 1;
+}
+
+message GreetResponse {
+ string greeting = 1;
+}
-type UserProvider struct {
- Prepare func(ctx context.Context, params ...interface{}) (bool,
error) `seataTwoPhaseAction:"prepare"
seataTwoPhaseServiceName:"TwoPhaseDemoService"`
- Commit func(ctx context.Context, businessActionContext
*tm.BusinessActionContext) (bool, error) `seataTwoPhaseAction:"commit"`
- Rollback func(ctx context.Context, businessActionContext
*tm.BusinessActionContext) (bool, error) `seataTwoPhaseAction:"rollback"`
- GetActionName func() string
+service GreetService {
+ rpc Greet(GreetRequest) returns (GreetResponse) {}
}
+
diff --git a/otel/tracing/jaeger/proto/greet.triple.go
b/otel/tracing/jaeger/proto/greet.triple.go
new file mode 100644
index 00000000..6f906938
--- /dev/null
+++ b/otel/tracing/jaeger/proto/greet.triple.go
@@ -0,0 +1,122 @@
+// Code generated by protoc-gen-triple. DO NOT EDIT.
+//
+// Source: greet.proto
+package greet
+
+import (
+ "context"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3"
+ "dubbo.apache.org/dubbo-go/v3/client"
+ "dubbo.apache.org/dubbo-go/v3/common"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
+ "dubbo.apache.org/dubbo-go/v3/server"
+)
+
+// This is a compile-time assertion to ensure that this generated file and the
Triple package
+// are compatible. If you get a compiler error that this constant is not
defined, this code was
+// generated with a version of Triple newer than the one compiled into your
binary. You can fix the
+// problem by either regenerating this code with an older version of Triple or
updating the Triple
+// version compiled into your binary.
+const _ = triple_protocol.IsAtLeastVersion0_1_0
+
+const (
+ // GreetServiceName is the fully-qualified name of the GreetService
service.
+ GreetServiceName = "greet.GreetService"
+)
+
+// These constants are the fully-qualified names of the RPCs defined in this
package. They're
+// exposed at runtime as procedure and as the final two segments of the HTTP
route.
+//
+// Note that these are different from the fully-qualified method names used by
+// google.golang.org/protobuf/reflect/protoreflect. To convert from these
constants to
+// reflection-formatted method names, remove the leading slash and convert the
remaining slash to a
+// period.
+const (
+ // GreetServiceGreetProcedure is the fully-qualified name of the
GreetService's Greet RPC.
+ GreetServiceGreetProcedure = "/greet.GreetService/Greet"
+)
+
+var (
+ _ GreetService = (*GreetServiceImpl)(nil)
+)
+
+// GreetService is a client for the greet.GreetService service.
+type GreetService interface {
+ Greet(ctx context.Context, req *GreetRequest, opts
...client.CallOption) (*GreetResponse, error)
+}
+
+// NewGreetService constructs a client for the greet.GreetService service.
+func NewGreetService(cli *client.Client, opts ...client.ReferenceOption)
(GreetService, error) {
+ conn, err := cli.DialWithInfo("greet.GreetService",
&GreetService_ClientInfo, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &GreetServiceImpl{
+ conn: conn,
+ }, nil
+}
+
+func SetConsumerGreetService(srv common.RPCService) {
+ dubbo.SetConsumerServiceWithInfo(srv, &GreetService_ClientInfo)
+}
+
+// GreetServiceImpl implements GreetService.
+type GreetServiceImpl struct {
+ conn *client.Connection
+}
+
+func (c *GreetServiceImpl) Greet(ctx context.Context, req *GreetRequest, opts
...client.CallOption) (*GreetResponse, error) {
+ resp := new(GreetResponse)
+ if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "Greet",
opts...); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+var GreetService_ClientInfo = client.ClientInfo{
+ InterfaceName: "greet.GreetService",
+ MethodNames: []string{"Greet"},
+ ConnectionInjectFunc: func(dubboCliRaw interface{}, conn
*client.Connection) {
+ dubboCli := dubboCliRaw.(*GreetServiceImpl)
+ dubboCli.conn = conn
+ },
+}
+
+// GreetServiceHandler is an implementation of the greet.GreetService service.
+type GreetServiceHandler interface {
+ Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+
+func RegisterGreetServiceHandler(srv *server.Server, hdlr GreetServiceHandler,
opts ...server.ServiceOption) error {
+ return srv.Register(hdlr, &GreetService_ServiceInfo, opts...)
+}
+
+func SetProviderGreetService(srv common.RPCService) {
+ dubbo.SetProviderServiceWithInfo(srv, &GreetService_ServiceInfo)
+}
+
+var GreetService_ServiceInfo = server.ServiceInfo{
+ InterfaceName: "greet.GreetService",
+ ServiceType: (*GreetServiceHandler)(nil),
+ Methods: []server.MethodInfo{
+ {
+ Name: "Greet",
+ Type: constant.CallUnary,
+ ReqInitFunc: func() interface{} {
+ return new(GreetRequest)
+ },
+ MethodFunc: func(ctx context.Context, args
[]interface{}, handler interface{}) (interface{}, error) {
+ req := args[0].(*GreetRequest)
+ res, err :=
handler.(GreetServiceHandler).Greet(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ return triple_protocol.NewResponse(res), nil
+ },
+ },
+ },
+}
diff --git a/otel/tracing/stdout/README.md b/otel/tracing/stdout/README.md
index a68613f8..1d6fafc9 100644
--- a/otel/tracing/stdout/README.md
+++ b/otel/tracing/stdout/README.md
@@ -1,5 +1,7 @@
# Stdout tracing exporter
+[English](README.md) | [中文](README_zh.md)
+
This example shows dubbo-go's tracing feature with stdout exporter.
## How to run
@@ -7,13 +9,13 @@ This example shows dubbo-go's tracing feature with stdout
exporter.
### Run server
```shell
-$ go run ./go-server/cmd/server.go
+$ go run ./go-server/cmd/main.go
```
### Run client
```shell
-$ go run ./go-client/cmd/client.go
+$ go run ./go-client/cmd/main.go
```
In the server's console, you will see the tracing log like this:
@@ -88,6 +90,8 @@ INFO tracing/tracing.go:54 tracing enabled, sampler: always_on
"Type": "STRING",
"Value": "dubbo-go"
}
+ },
+ {
"Key": "service.version",
"Value": {
"Type": "STRING",
diff --git a/otel/tracing/stdout/README.md b/otel/tracing/stdout/README_zh.md
similarity index 87%
copy from otel/tracing/stdout/README.md
copy to otel/tracing/stdout/README_zh.md
index a68613f8..82430e52 100644
--- a/otel/tracing/stdout/README.md
+++ b/otel/tracing/stdout/README_zh.md
@@ -1,22 +1,24 @@
-# Stdout tracing exporter
+# Stdout 链路追踪导出器
-This example shows dubbo-go's tracing feature with stdout exporter.
+[English](README.md) | [中文](README_zh.md)
-## How to run
+本示例展示了 dubbo-go 使用 stdout 导出器的链路追踪功能。
-### Run server
+## 运行方法
+
+### 启动服务端
```shell
-$ go run ./go-server/cmd/server.go
+$ go run ./go-server/cmd/main.go
```
-### Run client
+### 启动客户端
```shell
-$ go run ./go-client/cmd/client.go
+$ go run ./go-client/cmd/main.go
```
-In the server's console, you will see the tracing log like this:
+在服务端的控制台中,你将看到类似以下的链路追踪日志:
```shell
INFO tracing/tracing.go:53 tracing enabled, exporter: stdout
@@ -88,6 +90,8 @@ INFO tracing/tracing.go:54 tracing enabled, sampler: always_on
"Type": "STRING",
"Value": "dubbo-go"
}
+ },
+ {
"Key": "service.version",
"Value": {
"Type": "STRING",
@@ -102,4 +106,5 @@ INFO tracing/tracing.go:54 tracing enabled, sampler:
always_on
}
}
+```
diff --git a/transcation/seata-go/non-idl/client/cmd/client.go
b/transcation/seata-go/non-idl/client/cmd/client.go
index 4303bf78..6535c98e 100644
--- a/transcation/seata-go/non-idl/client/cmd/client.go
+++ b/transcation/seata-go/non-idl/client/cmd/client.go
@@ -40,8 +40,7 @@ import (
"github.com/apache/dubbo-go-samples/transcation/seata-go/non-idl/client/service"
)
-// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to
"seata-go/tcc/client/conf/dubbogo.yml"
-// and run "seata-go/tcc/server/cmd/server.go" before run
+// need to run "transcation/seata-go/non-idl/server/cmd/server.go" before run
func main() {
integration.UseDubbo()
ins, err := dubbo.NewInstance(