Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
supported dubbo-go v3.0.2 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgqypl authored Jul 18, 2022
1 parent 47241c9 commit cb8f743
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 489 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- { name: 'resty', plugin_dir: 'resty', go_version: '1.13' }
- { name: 'go-restful', plugin_dir: 'go-restful', go_version: '1.13' }
- { name: 'logrus', plugin_dir: 'logrus', go_version: '1.13' }
- { name: 'dubbo-go', plugin_dir: 'dubbo-go', go_version: '1.14' }
- { name: 'dubbo-go', plugin_dir: 'dubbo-go', go_version: '1.15' }
- { name: 'grom', plugin_dir: 'grom', go_version: '1.16' }
- { name: 'kafka-reporter', plugin_dir: 'kafkareporter', go_version: '1.16' }
- { name: 'kratos', plugin_dir: 'kratos', go_version: '1.16' }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ deps:

LINTER := bin/golangci-lint
$(LINTER):
curl -L https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.45.2
curl -L https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2

.PHONY: lint
lint: $(LINTER)
Expand Down
18 changes: 3 additions & 15 deletions dubbo-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
##### Installation

```
go get -u github.com/SkyAMP/go2sky-plugins/dubbo-go
go get -u github.com/SkyAPM/go2sky-plugins/dubbo-go
```

##### Usage
Expand All @@ -12,17 +12,11 @@ Server:

```go
import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
"github.com/SkyAPM/go2sky"
"github.com/SkyAPM/go2sky/reporter"
_ "dubbo.apache.org/dubbo-go/v3/imports"
hessian "github.com/apache/dubbo-go-hessian2"

dubbo_go "github.com/SkyAPM/go2sky-plugins/dubbo-go"
Expand Down Expand Up @@ -58,14 +52,8 @@ Client:

```go
import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"github.com/SkyAPM/go2sky"
"github.com/SkyAPM/go2sky/reporter"
hessian "github.com/apache/dubbo-go-hessian2"
Expand Down
7 changes: 5 additions & 2 deletions dubbo-go/dubbo-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,18 @@ func (cf tracingFilter) Invoke(ctx context.Context, invoker protocol.Invoker, in

if cf.side == clientSide {
span, _ = cf.tracer.CreateExitSpan(ctx, operationName, invoker.GetURL().Location, func(key, value string) error {
invocation.SetAttachments(key, value)
invocation.SetAttachment(key, value)
return nil
})

span.SetComponent(componentID)
} else {
// componentIDGo2SkyServer
span, ctx, _ = cf.tracer.CreateEntrySpan(ctx, operationName, func(key string) (string, error) {
return invocation.AttachmentsByKey(key, ""), nil
if attachment, ok := invocation.GetAttachment(key); ok {
return attachment, nil
}
return "", nil
})

span.SetComponent(componentID)
Expand Down
8 changes: 4 additions & 4 deletions dubbo-go/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/SkyAPM/go2sky-plugins/dubbo-go

go 1.14
go 1.15

require (
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2
dubbo.apache.org/dubbo-go/v3 v3.0.2
github.com/SkyAPM/go2sky v1.4.1
github.com/apache/dubbo-go-hessian2 v1.9.3
github.com/dubbogo/gost v1.11.17
github.com/apache/dubbo-go-hessian2 v1.11.0
github.com/dubbogo/gost v1.11.25
skywalking.apache.org/repo/goapi v0.0.0-20220401015832-2c9eee9481eb
)
775 changes: 478 additions & 297 deletions dubbo-go/go.sum

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions dubbo-go/test/client/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ import (
"net/http"
"time"

_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"github.com/SkyAPM/go2sky"
"github.com/SkyAPM/go2sky/reporter"
hessian "github.com/apache/dubbo-go-hessian2"
Expand All @@ -51,10 +45,13 @@ const (
serviceName = "dubbo-go-client"
)

// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run
// need to setup environment variable "DUBBO_GO_CONFIG_PATH" to "conf/client.yml" before run
func main() {
hessian.RegisterPOJO(&pkg.User{})
config.Load()
err := config.Load()
if err != nil {
log.Fatalf("load config error: %v \n", err)
}
time.Sleep(3 * time.Second)

report, err := reporter.NewGRPCReporter(oap)
Expand All @@ -78,8 +75,9 @@ func main() {
route := http.NewServeMux()

route.HandleFunc("/hello", func(writer http.ResponseWriter, req *http.Request) {
user := &pkg.User{}
err1 := userProvider.GetUser(req.Context(), []interface{}{"A001"}, user)
var user *pkg.User
var err1 error
user, err1 = userProvider.GetUser(req.Context(), []interface{}{"A001"})
if err1 != nil {
writer.WriteHeader(http.StatusInternalServerError)
_, _ = writer.Write([]byte(fmt.Sprintf("call service err %v \n", err1)))
Expand Down
108 changes: 52 additions & 56 deletions dubbo-go/test/client/conf/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,59 @@
#
# dubbo client yaml configure file

check: true
# client
request_timeout : "3s"
# connect timeout
connect_timeout : "3s"

# application config
application:
organization : "dubbo.io"
name : "UserInfoClient"
module : "dubbo-go user-info client"
version : "0.0.1"
environment : "dev"

# registry config
registries :
"demoZk":
protocol: "zookeeper"
timeout : "3s"
address: "zookeeper:2181"
username: ""
password: ""
dubbo:
application:
organization: "dubbo.io"
name: "UserInfoClient"
module: "dubbo-go user-info client"
version: "0.0.1"
environment: "dev"

# filter config
filter: "go2sky-tracing-client"
# registry config
registries:
demoZk:
protocol: "zookeeper"
timeout: "3s"
address: "zookeeper:2181"
username: ""
password: ""

# reference config
references:
"UserProvider":
registry: "demoZk"
protocol : "dubbo"
interface : "org.apache.dubbo.UserProvider"
cluster: "failover"
methods :
- name: "GetUser"
retries: 3
# reference config
consumer:
check: true
references:
"UserProvider":
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
# filter config
filter: "go2sky-tracing-client"
cluster: "failover"
methods:
-
name: "GetUser"
retries: 3

# protocol config
protocol_conf:
dubbo:
reconnect_interval: 0
connection_number: 1
heartbeat_period: "5s"
session_timeout: "180s"
pool_size: 64
pool_ttl: 600
getty_session_param:
compress_encoding: false
tcp_no_delay: true
tcp_keep_alive: true
keep_alive_period: "120s"
tcp_r_buf_size: 262144
tcp_w_buf_size: 65536
pkg_rq_size: 1024
pkg_wq_size: 512
tcp_read_timeout: "1s"
tcp_write_timeout: "5s"
wait_timeout: "1s"
max_msg_len: 1024000
session_name: "client"
# protocol config
protocols:
"dubbo":
params:
"dubbo":
reconnect_interval: 0
connection_number: 1
heartbeat_period: "5s"
session_timeout: "180s"
pool_size: 64
pool_ttl: 600
getty_session_param:
compress_encoding: false
tcp_no_delay: true
tcp_keep_alive: true
keep_alive_period: "120s"
tcp_r_buf_size: 262144
tcp_w_buf_size: 65536
tcp_read_timeout: "1s"
tcp_write_timeout: "5s"
wait_timeout: "1s"
max_msg_len: 1024000
session_name: "client"
2 changes: 1 addition & 1 deletion dubbo-go/test/client/pkg/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type User struct {

// UserProvider user provider service
type UserProvider struct {
GetUser func(ctx context.Context, req []interface{}, rsp *User) error
GetUser func(ctx context.Context, req []interface{}) (*User, error)
}

// Reference rpc service id or reference id
Expand Down
4 changes: 2 additions & 2 deletions dubbo-go/test/docker/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# limitations under the License.
#

FROM golang:1.14
FROM golang:1.15

ADD ./dubbo-go /dubbo-go
WORKDIR /dubbo-go

ENV APP_LOG_CONF_FILE /dubbo-go/test/client/conf/log.yml
ENV CONF_CONSUMER_FILE_PATH /dubbo-go/test/client/conf/client.yml
ENV DUBBO_GO_CONFIG_PATH /dubbo-go/test/client/conf/client.yml

EXPOSE 8080

Expand Down
4 changes: 2 additions & 2 deletions dubbo-go/test/docker/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@



FROM golang:1.14
FROM golang:1.15

ADD ./dubbo-go /dubbo-go
WORKDIR /dubbo-go

ENV APP_LOG_CONF_FILE /dubbo-go/test/server/conf/log.yml
ENV CONF_PROVIDER_FILE_PATH /dubbo-go/test/server/conf/server.yml
ENV DUBBO_GO_CONFIG_PATH /dubbo-go/test/server/conf/server.yml

EXPOSE 20000

Expand Down
72 changes: 36 additions & 36 deletions dubbo-go/test/expected.data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,49 @@

segmentItems:
{{- contains .segmentItems }}
- serviceName: dubbo-go-server
segmentSize: {{ gt .segmentSize 0 }}
segments:
{{- contains .segments }}
- segmentId: {{ notEmpty .segmentId }}
spans:
{{- contains .spans}}
- operationName: org.apache.dubbo.UserProvider:0.0.1#GetUser
parentSpanId: -1
spanId: 0
spanLayer: RPCFramework
startTime: {{ gt .startTime 0 }}
endTime: {{ gt .endTime 0 }}
componentId: 3
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: extra-tags, value: server}
- {key: release, value: dubbo-golang-3.0.0}
- {key: organization, value: dubbo.io}
refs:
{{- contains .refs }}
- parentEndpoint: /GET/hello
networkAddress: {{ notEmpty .networkAddress }}
refType: CrossProcess
parentSpanId: {{ ge .parentSpanId 0 }}
parentTraceSegmentId: {{ notEmpty .parentTraceSegmentId }}
parentServiceInstance: {{ notEmpty .parentServiceInstance }}
parentService: dubbo-go-client
traceId: {{ notEmpty .traceId }}
{{- end}}
{{- end}}
{{- end}}
- serviceName: dubbo-go-client
segmentSize: {{ gt .segmentSize 0 }}
segments:
{{- contains .segments }}
- segmentId: {{ notEmpty .segmentId }}
spans:
{{- contains .spans }}
- operationName: org.apache.dubbo.UserProvider#GetUser
- operationName: org.apache.dubbo.UserProvider:0.0.1#GetUser
parentSpanId: 0
spanId: 1
spanLayer: RPCFramework
Expand Down Expand Up @@ -60,40 +95,5 @@ segmentItems:
{{- end }}
{{- end}}
{{- end}}
- serviceName: dubbo-go-server
segmentSize: {{ gt .segmentSize 0 }}
segments:
{{- contains .segments }}
- segmentId: {{ notEmpty .segmentId }}
spans:
{{- contains .spans}}
- operationName: org.apache.dubbo.UserProvider#GetUser
parentSpanId: -1
spanId: 0
spanLayer: RPCFramework
startTime: {{ gt .startTime 0 }}
endTime: {{ gt .endTime 0 }}
componentId: 3
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: extra-tags, value: server}
- {key: release, value: dubbo-golang-3.0.0}
- {key: organization, value: dubbo.io}
refs:
{{- contains .refs }}
- parentEndpoint: /GET/hello
networkAddress: {{ notEmpty .networkAddress }}
refType: CrossProcess
parentSpanId: {{ ge .parentSpanId 0 }}
parentTraceSegmentId: {{ notEmpty .parentTraceSegmentId }}
parentServiceInstance: {{ notEmpty .parentServiceInstance }}
parentService: dubbo-go-client
traceId: {{ notEmpty .traceId }}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
meterItems: []
Loading

0 comments on commit cb8f743

Please sign in to comment.