Please go2sky E2E to go agent (#11568)

This commit is contained in:
mrproliu 2023-11-20 20:22:25 +08:00 committed by GitHub
parent 600ea37a4d
commit 7f9a8bb042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 179 additions and 64 deletions

View File

@ -44,6 +44,7 @@
* Add self-observability metric `metrics_aggregator_abandon` to count the number of abandon metrics.
* Support Nginx monitoring.
* Fix `BanyanDB Metadata Query`: make query single instance/process return full tags to avoid NPE.
* Repleace go2sky E2E to GO agent.
#### UI

View File

@ -31,22 +31,25 @@ services:
oap:
condition: service_healthy
go2sky:
go-service:
build:
context: .
dockerfile: Dockerfile.go
context: ./service
dockerfile: Dockerfile
args:
- SW_AGENT_GO_COMMIT=${SW_AGENT_GO_COMMIT}
networks:
- e2e
expose:
- 8080
environment:
SW_AGENT_NAME: go-service
SW_AGENT_REPORTER_GRPC_BACKEND_SERVICE: oap:11800
UPSTREAM_URL: http://provider:9090/correlation
depends_on:
oap:
condition: service_healthy
provider:
condition: service_healthy
command: ['--grpc', '--oap-server', 'oap:11800', '--upstream-url', 'http://provider:9090/correlation']
healthcheck:
test: ["CMD", "sh", "-c", "nc -z 127.0.0.1 8080"]
interval: 5s
@ -58,11 +61,11 @@ services:
file: ../../script/docker-compose/base-compose.yml
service: consumer
environment:
PROVIDER_URL: http://go2sky:8080
PROVIDER_URL: http://go-service:8080
depends_on:
oap:
condition: service_healthy
go2sky:
go-service:
condition: service_healthy
ports:
- 9092

View File

@ -46,17 +46,17 @@ verify:
# service instance list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=e2e-service-provider
expected: expected/service-instance-provider.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go2sky
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go-service
expected: expected/service-instance-go.yml
# service endpoint
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=correlation --service-name=go2sky
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=correlation --service-name=go-service
expected: expected/service-endpoint-go.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=correlation --service-name=e2e-service-consumer
expected: expected/service-endpoint-consumer.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=correlation --service-name=e2e-service-provider
expected: expected/service-endpoint-provider.yml
# trace segment list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --service-name=go2sky
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --service-name=go-service
expected: expected/traces-list-go.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --service-name=e2e-service-consumer
expected: expected/traces-list-consumer.yml
@ -70,19 +70,19 @@ verify:
)
expected: expected/trace-correlation-detail.yml
# dependency service
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency service --service-name=go2sky
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency service --service-name=go-service
expected: expected/dependency-services-go.yml
# dependency instance
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency instance --service-name=go2sky --dest-service-name=e2e-service-provider
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency instance --service-name=go-service --dest-service-name=e2e-service-provider
expected: expected/dependency-instance-go.yml
# service metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_sla --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_sla --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_cpm --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_cpm --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_resp_time --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_resp_time --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_apdex --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_apdex --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# service instance metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_instance_resp_time --instance-name=provider1 --service-name=e2e-service-provider |yq e 'to_entries' -
@ -92,25 +92,25 @@ verify:
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_instance_sla --instance-name=provider1 --service-name=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# service endpoint metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_cpm --endpoint-name=/POST/correlation --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_cpm --endpoint-name=POST:/correlation --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_resp_time --endpoint-name=/POST/correlation --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_resp_time --endpoint-name=POST:/correlation --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_sla --endpoint-name=/POST/correlation --service-name=go2sky |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=endpoint_sla --endpoint-name=POST:/correlation --service-name=go-service |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# service relation metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_relation_client_cpm --service-name=go2sky --dest-service-name=e2e-service-provider |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_relation_client_cpm --service-name=go-service --dest-service-name=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_relation_server_cpm --service-name=go2sky --dest-service-name=e2e-service-provider |yq e 'to_entries' -
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_relation_server_cpm --service-name=go-service --dest-service-name=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# service instance relation metrics
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_instance_relation_client_cpm --instance-name=$( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go2sky | yq e '.[0].name' - ) \
--service-name=go2sky --dest-instance-name=provider1 --dest-service-name=e2e-service-provider |yq e 'to_entries' -
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go-service | yq e '.[0].name' - ) \
--service-name=go-service --dest-instance-name=provider1 --dest-service-name=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_instance_relation_server_cpm --instance-name=$( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go2sky | yq e '.[0].name' - ) \
--service-name=go2sky --dest-instance-name=provider1 --dest-service-name=e2e-service-provider |yq e 'to_entries' -
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=go-service | yq e '.[0].name' - ) \
--service-name=go-service --dest-instance-name=provider1 --dest-service-name=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml

View File

@ -17,8 +17,8 @@ nodes:
{{- contains .nodes }}
- id: {{ notEmpty .id }}
name: {{ notEmpty .name }}
serviceid: {{ b64enc "go2sky" }}.1
servicename: go2sky
serviceid: {{ b64enc "go-service" }}.1
servicename: go-service
type: ""
isreal: true
- id: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}

View File

@ -23,9 +23,9 @@ nodes:
name: e2e-service-consumer
type: Tomcat
isreal: true
- id: {{ b64enc "go2sky" }}.1
name: go2sky
type: GoHttpServer
- id: {{ b64enc "go-service" }}.1
name: go-service
type: Gin
isreal: true
{{- end }}
calls:
@ -33,20 +33,20 @@ calls:
- source: {{ b64enc "e2e-service-consumer"}}.1
sourcecomponents:
- SpringRestTemplate
target: {{ b64enc "go2sky"}}.1
target: {{ b64enc "go-service"}}.1
targetcomponents:
- GoHttpServer
id: {{ b64enc "e2e-service-consumer"}}.1-{{ b64enc "go2sky"}}.1
- Gin
id: {{ b64enc "e2e-service-consumer"}}.1-{{ b64enc "go-service"}}.1
detectpoints:
- CLIENT
- SERVER
- source: {{ b64enc "go2sky" }}.1
- source: {{ b64enc "go-service" }}.1
sourcecomponents:
- GoHttpClient
target: {{ b64enc "e2e-service-provider"}}.1
targetcomponents:
- Tomcat
id: {{ b64enc "go2sky" }}.1-{{ b64enc "e2e-service-provider"}}.1
id: {{ b64enc "go-service" }}.1-{{ b64enc "e2e-service-provider"}}.1
detectpoints:
- CLIENT
- SERVER

View File

@ -14,6 +14,6 @@
# limitations under the License.
{{- contains . }}
- id: {{ b64enc "go2sky" }}.1_{{ b64enc "/POST/correlation" }}
name: /POST/correlation
- id: {{ b64enc "go-service" }}.1_{{ b64enc "POST:/correlation" }}
name: POST:/correlation
{{- end}}

View File

@ -28,10 +28,10 @@
normal: true
layers:
- GENERAL
- id: {{ b64enc "go2sky" }}.1
name: go2sky
- id: {{ b64enc "go-service" }}.1
name: go-service
group: ""
shortname: go2sky
shortname: go-service
normal: true
layers:
- GENERAL

View File

@ -48,14 +48,14 @@ spans:
endtime: {{ gt .endtime 0 }}
endpointname: /correlation
type: Exit
peer: go2sky:8080
peer: go-service:8080
component: SpringRestTemplate
iserror: false
layer: Http
tags:
{{- contains .tags }}
- key: url
value: http://go2sky:8080/correlation
value: http://go-service:8080/correlation
- key: http.method
value: POST
{{- end }}
@ -72,20 +72,20 @@ spans:
parentspanid: 1
type: CROSS_PROCESS
{{- end }}
servicecode: go2sky
servicecode: go-service
serviceinstancename: {{ notEmpty .serviceinstancename }}
starttime: {{ gt .starttime 0 }}
endtime: {{ gt .endtime 0 }}
endpointname: /POST/correlation
endpointname: POST:/correlation
type: Entry
peer: ""
component: GoHttpServer
component: Gin
iserror: false
layer: Http
tags:
{{- contains .tags }}
- key: url
value: go2sky:8080/correlation
value: go-service:8080/correlation
- key: http.method
value: POST
- key: status_code
@ -98,11 +98,11 @@ spans:
spanid: {{ .spanid }}
parentspanid: {{ .parentspanid }}
refs: []
servicecode: go2sky
servicecode: go-service
serviceinstancename: {{ notEmpty .serviceinstancename }}
starttime: {{ gt .starttime 0 }}
endtime: {{ gt .endtime 0 }}
endpointname: /POST/correlation
endpointname: POST:/correlation
type: Exit
peer: provider:9090
component: GoHttpClient
@ -111,7 +111,7 @@ spans:
tags:
{{- contains .tags }}
- key: url
value: http://provider:9090/correlation
value: provider:9090/correlation
- key: http.method
value: POST
- key: status_code

View File

@ -17,7 +17,7 @@ traces:
{{- contains .traces }}
- segmentid: {{ notEmpty .segmentid }}
endpointnames:
- /POST/correlation
- POST:/correlation
duration: {{ ge .duration 0 }}
start: "{{ notEmpty .start}}"
iserror: false

View File

@ -13,25 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM golang:1.13 AS builder
ARG SW_AGENT_GO_COMMIT
ARG GO2SKY_CODE=${SW_AGENT_GO_COMMIT}.tar.gz
ARG GO2SKY_CODE_URL=https://github.com/SkyAPM/go2sky/archive/${GO2SKY_CODE}
ARG SW_AGENT_GO_COMMIT=
FROM ghcr.io/apache/skywalking-go/skywalking-go:${SW_AGENT_GO_COMMIT}-go1.18 as base
ENV CGO_ENABLED=0
ENV GO111MODULE=on
WORKDIR /go2sky
WORKDIR /go-service
COPY .. /go-service
ADD ${GO2SKY_CODE_URL} .
RUN tar -xf ${GO2SKY_CODE} --strip 1
RUN rm ${GO2SKY_CODE}
WORKDIR /go2sky/test/e2e/example-server
RUN go build -o main
RUN go mod tidy && go build -toolexec="skywalking-go-agent" -a -o service
FROM alpine:3.10
COPY --from=builder /go2sky/test/e2e/example-server/main .
ENTRYPOINT ["/main"]
COPY --from=base /go-service/service /service
ENTRYPOINT ["/service"]

View File

@ -0,0 +1,57 @@
// Licensed to 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. Apache Software Foundation (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 (
"github.com/apache/skywalking-go/toolkit/trace"
"io/ioutil"
"log"
"net/http"
"os"
"time"
"github.com/gin-gonic/gin"
_ "github.com/apache/skywalking-go"
)
func main() {
upstream := os.Getenv("UPSTREAM_URL")
engine := gin.New()
engine.Handle("POST", "/correlation", func(context *gin.Context) {
time.Sleep(time.Duration(500) * time.Millisecond)
trace.SetCorrelation("MIDDLE_KEY", "go-service")
res, err := http.Post(upstream, "text/html", nil)
if err != nil {
context.Status(http.StatusInternalServerError)
log.Printf("unable to do http request error: %v \n", err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
context.Status(http.StatusInternalServerError)
log.Printf("read http response error: %v \n", err)
return
}
context.Status(res.StatusCode)
context.Writer.Write(body)
})
_ = engine.Run(":8080")
}

View File

@ -0,0 +1,60 @@
// Licensed to 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. Apache Software Foundation (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.
module sw-e2e
go 1.18
require (
github.com/apache/skywalking-go v0.3.0
github.com/apache/skywalking-go/toolkit v0.3.0
github.com/gin-gonic/gin v1.9.1
)
require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
skywalking.apache.org/repo/goapi v0.0.0-20230314034821-0c5a44bb767a // indirect
)

View File

@ -17,7 +17,7 @@ SW_AGENT_JAVA_COMMIT=c82287e1dd1593cf3e7dbc390b92f9224943252a
SW_AGENT_SATELLITE_COMMIT=ea27a3f4e126a24775fe12e2aa2695bcb23d99c3
SW_AGENT_NGINX_LUA_COMMIT=c3cee4841798a147d83b96a10914d4ac0e11d0aa
SW_AGENT_NODEJS_COMMIT=4f9a91dad3dfd8cfe5ba8f7bd06b39e11eb5e65e
SW_AGENT_GO_COMMIT=4af380c2db6243106b0fc650b6003ce3b3eb82a0
SW_AGENT_GO_COMMIT=774a6d56baba1187eb03bf1861af542c923b3dff
SW_AGENT_PYTHON_COMMIT=c76a6ec51a478ac91abb20ec8f22a99b8d4d6a58
SW_AGENT_CLIENT_JS_COMMIT=af0565a67d382b683c1dbd94c379b7080db61449
SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016