From 8d486f539114b6dbb732113812653cdc43e4e4e6 Mon Sep 17 00:00:00 2001 From: innerpeacez Date: Wed, 25 Aug 2021 19:44:01 +0800 Subject: [PATCH] feature: Trace query and debug enhancement (#1553) * trace feature * openapi * fix duration check * fix duration bug * fix service name * update ut * add license * imports format * update ut * update ut * add ut TestTranslateCondition() * add ut Test_queryConditions() * add ut Test_traceService_getDebugStatus() * imports format * Keep spaces between Chinese characters and letters --- .../msp/20210818-sp_trace_request_history.sql | 3 + conf/msp/i18n/msp-i18n.yaml | 28 +- go.mod | 4 +- go.sum | 83 +++++- modules/monitor/apm/topology/topology.go | 4 + modules/monitor/apm/topology/topology_test.go | 24 ++ modules/msp/apm/trace/core/common/common.go | 19 ++ modules/msp/apm/trace/core/debug/debug.go | 24 ++ modules/msp/apm/trace/core/query/query.go | 89 +++++++ .../msp/apm/trace/core/query/query_test.go | 132 ++++++++++ modules/msp/apm/trace/db/tables.go | 1 + .../msp/apm/trace/db/trace_request_history.go | 15 +- modules/msp/apm/trace/trace.service.go | 241 ++++++++++++------ modules/msp/apm/trace/trace.service_test.go | 119 ++++++++- .../apm/trace/get_trace_conditions_list.go | 28 ++ 15 files changed, 710 insertions(+), 104 deletions(-) create mode 100644 .erda/migrations/msp/20210818-sp_trace_request_history.sql create mode 100644 modules/msp/apm/trace/core/common/common.go create mode 100644 modules/msp/apm/trace/core/debug/debug.go create mode 100644 modules/msp/apm/trace/core/query/query.go create mode 100644 modules/msp/apm/trace/core/query/query_test.go create mode 100644 modules/openapi/api/apis/msp/apm/trace/get_trace_conditions_list.go diff --git a/.erda/migrations/msp/20210818-sp_trace_request_history.sql b/.erda/migrations/msp/20210818-sp_trace_request_history.sql new file mode 100644 index 00000000000..e6ff5b7d268 --- /dev/null +++ b/.erda/migrations/msp/20210818-sp_trace_request_history.sql @@ -0,0 +1,3 @@ +ALTER TABLE `sp_trace_request_history` MODIFY COLUMN `response_body` MEDIUMTEXT DEFAULT NULL COMMENT '请求响应体'; + +ALTER TABLE `sp_trace_request_history` ADD COLUMN `name` VARCHAR(100) NOT NULL COMMENT '链路调试名称' AFTER `request_id`; diff --git a/conf/msp/i18n/msp-i18n.yaml b/conf/msp/i18n/msp-i18n.yaml index ce97ec02194..22a61b76e13 100644 --- a/conf/msp/i18n/msp-i18n.yaml +++ b/conf/msp/i18n/msp-i18n.yaml @@ -10,6 +10,19 @@ en: workspace_default: "DEFAULT" project_type_dop: "DevOps Project" project_type_msp: "MSP Project" + span_count_desc: Span Count DESC + span_count_asc: Span Count ASC + trace_duration_desc: Trace Duration DESC + trace_duration_asc: Trace Duration ASC + trace_time_desc: Trace Time DESC + trace_time_asc: Trace Time ASC + service_name: Service Name + trace_id: Trace ID + dubbo_method: Dubbo Method + http_path: HTTP Path + trace_success: SUCCESS + trace_error: ERROR + trace_all: ALL zh: waiting_for_tracing_data: "正在获取链路追踪数据" success_get_tracing_data: "获取链路追踪数据成功" @@ -21,4 +34,17 @@ zh: workspace_prod: "生产" workspace_default: "默认" project_type_dop: "DevOps 项目" - project_type_msp: "微服务治理项目" \ No newline at end of file + project_type_msp: "微服务治理项目" + span_count_desc: Span 数量倒序 + span_count_asc: Span 数量正序 + trace_duration_desc: 追踪持续时间倒序 + trace_duration_asc: 追踪持续时间正序 + trace_time_desc: 追踪发生时间倒序 + trace_time_asc: 追踪发生时间正序 + service_name: 服务名 + trace_id: 追踪 ID + dubbo_method: Dubbo Method + http_path: HTTP Path + trace_success: 成功 + trace_error: 错误 + trace_all: 所有 \ No newline at end of file diff --git a/go.mod b/go.mod index 832bd70ff56..a16ab91ec90 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/elastic/cloud-on-k8s v0.0.0-20210205172912-5ce0eca90c60 github.com/elazarl/goproxy v0.0.0-20200421181703-e76ad31c14f6 github.com/erda-project/erda-infra v0.0.0-20210817063509-a477b158393d - github.com/erda-project/erda-proto-go v0.0.0-20210805063629-d4e8ac75e06d + github.com/erda-project/erda-proto-go v0.0.0-20210823110307-c397defb820e github.com/extrame/ole2 v0.0.0-20160812065207-d69429661ad7 // indirect github.com/extrame/xls v0.0.1 github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect @@ -113,7 +113,7 @@ require ( github.com/shopspring/decimal v1.2.0 github.com/sirupsen/logrus v1.8.1 github.com/sony/sonyflake v1.0.0 - github.com/spf13/cobra v1.1.3 + github.com/spf13/cobra v1.2.1 github.com/stretchr/testify v1.7.0 github.com/syndtr/goleveldb v1.0.1-0.20190625010220-02440ea7a285 github.com/t-tiger/gorm-bulk-insert v1.3.0 diff --git a/go.sum b/go.sum index 7fdf8aa5e89..591fa18314c 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,13 @@ cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bP cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0 h1:at8Tk2zUz63cLPR0JPWm5vp77pEZmzxEQBEfRKn1VV8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -222,6 +227,7 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYE github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/blacktear23/go-proxyprotocol v0.0.0-20180807104634-af7a81e8dd0d/go.mod h1:VKt7CNAQxpFpSDz3sXyj9hY/GbVsQCr0sB3w59nE7lU= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= @@ -334,6 +340,7 @@ github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.3.1/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -443,8 +450,8 @@ github.com/erda-project/elastic v0.0.1-ex/go.mod h1:iAVsas6fcmt9pxtge1+dErMhecv+ github.com/erda-project/erda-infra v0.0.0-20210706133120-0a742437972c/go.mod h1:TUQYSZ60w9dk7m0q3U3AVg7U74APj/sdEVvRWR3wYv8= github.com/erda-project/erda-infra v0.0.0-20210817063509-a477b158393d h1:1y55yg46RQa0mVg4Rn41gKo/89e1XMzU9jMUs71fTOo= github.com/erda-project/erda-infra v0.0.0-20210817063509-a477b158393d/go.mod h1:YpMIFoipL7XardYV3C58qx9fm74JM5QK/E3kd/t1CJU= -github.com/erda-project/erda-proto-go v0.0.0-20210805063629-d4e8ac75e06d h1:6qHof6d0/OWdgKGGpdhvSWZGwtZNK6GXLLcXfn7W5UA= -github.com/erda-project/erda-proto-go v0.0.0-20210805063629-d4e8ac75e06d/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU= +github.com/erda-project/erda-proto-go v0.0.0-20210823110307-c397defb820e h1:iRg9u84sDRggQyhMo3mwy2OqFh4AioPHd7OivgccBLE= +github.com/erda-project/erda-proto-go v0.0.0-20210823110307-c397defb820e/go.mod h1:rSETXX3nKxxIhgrVn7fKDM3mla1nNlWcPz4AkepixaU= github.com/erda-project/influxql v1.1.0-ex h1:NgP5+S5Qo234IVSIJ3N/egvzCNYJURfMAett3e8a9LE= github.com/erda-project/influxql v1.1.0-ex/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= github.com/erda-project/remotedialer v0.2.6-0.20210713103000-da03eb9e4b23 h1:NaKo6voQVqZM6DMBVhcTT4gjd+lr1C3zE17RROspfg0= @@ -707,6 +714,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v0.0.0-20180814211427-aa810b61a9c7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -762,6 +770,7 @@ github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190930153522-6ce02741cba3/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -770,8 +779,12 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200407044318-7d83b28da2e9/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99 h1:Ak8CrdlwwXwAZxzS66vgPt4U8yUZX7JwLvVR58FN5jM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5 h1:zIaiqGYDQwa4HVx5wGRTXbx38Pqxjemn4BP98wpzpXo= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/readahead v0.0.0-20161222183148-eaceba169032/go.mod h1:qYysrqQXuV4tzsizt4oOQ6mrBZQ0xnQXP3ylXX8Jk5Y= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf/go.mod h1:RpwtwJQFrIEPstU94h88MWPXP2ektJZ8cZ0YntAmXiE= @@ -830,8 +843,9 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6soZe6fT7iteq8wDPdhb0= -github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69/go.mod h1:YLEMZOtU+AZ7dhN9T/IpGhXVGly2bvkJQ+zxj3WeVQo= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= @@ -890,6 +904,7 @@ github.com/hypnoglow/gormzap v0.3.0/go.mod h1:5Wom8B7Jl2oK0Im9hs6KQ+Kl92w4Y7gKCr github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 h1:VHgatEHNcBFEB7inlalqfNqw65aNkM1lGX2yt3NmbS8= github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/igm/sockjs-go v3.0.0+incompatible h1:4w5ztbp2brVLJYz+o3u0m7+zmuup6eZ/Fr1ehbJOsBo= github.com/igm/sockjs-go v3.0.0+incompatible/go.mod h1:Yu6pvqjNniWNJe07LPObeCG6R77Qc97C6Kss0roF8tU= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -988,6 +1003,7 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -1383,6 +1399,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/profile v1.5.0 h1:042Buzk+NhDI+DeSAA62RwJL8VAuZUMQZUjCsRz1Mug= github.com/pkg/profile v1.5.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1570,8 +1587,9 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= @@ -1581,8 +1599,9 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= +github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -1594,6 +1613,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/storageos/go-api v2.2.0+incompatible/go.mod h1:ZrLn+e0ZuF3Y65PNF6dIwbJPZqfmtCXxFm9ckv0agOY= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -1765,6 +1785,9 @@ go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mI go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2 h1:jxcFYjlkl8xaERsgLo+RNquI0epW6zuy/ZRQs6jnrFA= @@ -1777,6 +1800,7 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= @@ -1833,6 +1857,7 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -1878,6 +1903,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= @@ -1891,6 +1917,8 @@ golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hM golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1946,12 +1974,15 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8= @@ -1962,8 +1993,14 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 h1:0Ja1LBD+yisY6RWM/BH7TJVXWsSjs2VwBSmvSX4HdBc= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2051,17 +2088,24 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200819171115-d785dc25833f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2165,7 +2209,12 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -2211,8 +2260,14 @@ google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0 h1:yfrXXP61wVuLb0vBcG6qaOoIoqYEzOQS8jum51jkv2w= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.44.0 h1:URs6qR1lAxDsqWITsQXI4ZkGiYJ5dHtRNiCpfs2OeKA= +google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2259,9 +2314,19 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210317182105-75c7a8546eb9/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210729151513-df9385d47c1b h1:4xoALQmXxqVdDdLimpPyPeDdsJzo+nFTJw9euAMpqgM= google.golang.org/genproto v0.0.0-20210729151513-df9385d47c1b/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= diff --git a/modules/monitor/apm/topology/topology.go b/modules/monitor/apm/topology/topology.go index 98572ce009e..a1c8b13f2f8 100644 --- a/modules/monitor/apm/topology/topology.go +++ b/modules/monitor/apm/topology/topology.go @@ -606,6 +606,10 @@ func queryConditions(indexType string, params Vo) *elastic.BoolQuery { sbq.Should(elastic.NewTermQuery(apm.TagsApplicationName, value)). Should(elastic.NewTermQuery(apm.TagsTargetApplicationName, value)). Should(elastic.NewTermQuery(apm.TagsSourceApplicationName, value)) + case ServiceSearchTag.Tag: + sbq.Should(elastic.NewTermQuery(apm.TagsServiceName, value)). + Should(elastic.NewTermQuery(apm.TagsTargetServiceName, value)). + Should(elastic.NewTermQuery(apm.TagsSourceServiceName, value)) } } boolQuery.Filter(sbq) diff --git a/modules/monitor/apm/topology/topology_test.go b/modules/monitor/apm/topology/topology_test.go index e3aa746c007..be5631e17d6 100644 --- a/modules/monitor/apm/topology/topology_test.go +++ b/modules/monitor/apm/topology/topology_test.go @@ -189,3 +189,27 @@ func Test_getDashboardId(t *testing.T) { }) } } + +func Test_queryConditions(t *testing.T) { + type args struct { + indexType string + params Vo + } + tests := []struct { + name string + args args + want bool + }{ + {"case1", args{indexType: MQDBCacheIndexType, params: Vo{Tags: []string{"service:apm-demo-api"}}}, false}, + {"case1", args{indexType: HttpRecMircoIndexType, params: Vo{Tags: []string{"application:apm-demo"}}}, false}, + {"case1", args{indexType: ServiceNodeIndexType, params: Vo{Tags: nil}}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := queryConditions(tt.args.indexType, tt.args.params) + if got == nil { + t.Errorf("queryConditions() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/modules/msp/apm/trace/core/common/common.go b/modules/msp/apm/trace/core/common/common.go new file mode 100644 index 00000000000..cb53d6234a8 --- /dev/null +++ b/modules/msp/apm/trace/core/common/common.go @@ -0,0 +1,19 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// Licensed 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 common + +const Layout = "2006-01-02 15:04:05" + +type Void struct{} diff --git a/modules/msp/apm/trace/core/debug/debug.go b/modules/msp/apm/trace/core/debug/debug.go new file mode 100644 index 00000000000..0839334022f --- /dev/null +++ b/modules/msp/apm/trace/core/debug/debug.go @@ -0,0 +1,24 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// Licensed 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 debug + +type Status int32 + +const ( + Init Status = 0 + Success Status = 1 + Fail Status = 2 + Stop Status = 3 +) diff --git a/modules/msp/apm/trace/core/query/query.go b/modules/msp/apm/trace/core/query/query.go new file mode 100644 index 00000000000..bd4a4dea144 --- /dev/null +++ b/modules/msp/apm/trace/core/query/query.go @@ -0,0 +1,89 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// Licensed 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 query + +import ( + "encoding/json" + "strings" + + "github.com/erda-project/erda-infra/providers/i18n" + "github.com/erda-project/erda-proto-go/msp/apm/trace/pb" +) + +type SpanTree map[string]*pb.Span +type ConditionType string + +const ( + INPUT ConditionType = "input" +) + +var sortConditions = []*pb.TraceQueryCondition{ + {Key: strings.ToLower(pb.SortCondition_TRACE_TIME_DESC.String()), Value: strings.ToLower(pb.SortCondition_TRACE_TIME_DESC.String())}, + {Key: strings.ToLower(pb.SortCondition_TRACE_TIME_ASC.String()), Value: strings.ToLower(pb.SortCondition_TRACE_TIME_ASC.String())}, + {Key: strings.ToLower(pb.SortCondition_SPAN_COUNT_DESC.String()), Value: strings.ToLower(pb.SortCondition_SPAN_COUNT_DESC.String())}, + {Key: strings.ToLower(pb.SortCondition_SPAN_COUNT_ASC.String()), Value: strings.ToLower(pb.SortCondition_SPAN_COUNT_ASC.String())}, + {Key: strings.ToLower(pb.SortCondition_TRACE_DURATION_DESC.String()), Value: strings.ToLower(pb.SortCondition_TRACE_DURATION_DESC.String())}, + {Key: strings.ToLower(pb.SortCondition_TRACE_DURATION_ASC.String()), Value: strings.ToLower(pb.SortCondition_TRACE_DURATION_ASC.String())}, +} + +var limitConditions = []*pb.TraceQueryCondition{ + {Key: strings.ToLower(pb.LimitCondition_NUMBER_100.String()), Value: "100", DisplayName: "100"}, + {Key: strings.ToLower(pb.LimitCondition_NUMBER_200.String()), Value: "200", DisplayName: "200"}, + {Key: strings.ToLower(pb.LimitCondition_NUMBER_500.String()), Value: "500", DisplayName: "500"}, + {Key: strings.ToLower(pb.LimitCondition_NUMBER_1000.String()), Value: "1000", DisplayName: "1000"}, +} + +var TraceStatusConditions = []*pb.TraceQueryCondition{ + {Key: strings.ToLower(pb.TraceStatusCondition_TRACE_ALL.String()), Value: strings.ToLower(pb.TraceStatusCondition_TRACE_ALL.String())}, + {Key: strings.ToLower(pb.TraceStatusCondition_TRACE_SUCCESS.String()), Value: strings.ToLower(pb.TraceStatusCondition_TRACE_SUCCESS.String())}, + {Key: strings.ToLower(pb.TraceStatusCondition_TRACE_ERROR.String()), Value: strings.ToLower(pb.TraceStatusCondition_TRACE_ERROR.String())}, +} + +var TraceQueryConditions = pb.TraceQueryConditions{ + Sort: sortConditions, + Limit: limitConditions, + TraceStatus: TraceStatusConditions, + Others: []*pb.OtherTraceQueryCondition{ + {Key: strings.ToLower(pb.OtherCondition_SERVICE_NAME.String()), ParamKey: "serviceName", Type: string(INPUT)}, + {Key: strings.ToLower(pb.OtherCondition_TRACE_ID.String()), ParamKey: "traceID", Type: string(INPUT)}, + {Key: strings.ToLower(pb.OtherCondition_DUBBO_METHOD.String()), ParamKey: "dubboMethod", Type: string(INPUT)}, + {Key: strings.ToLower(pb.OtherCondition_HTTP_PATH.String()), ParamKey: "httpPath", Type: string(INPUT)}, + }, +} + +func TranslateCondition(i18n i18n.Translator, lang i18n.LanguageCodes, key string) string { + if lang == nil { + return key + } + return i18n.Text(lang, strings.ToLower(key)) +} + +func DepthCopyQueryConditions() *pb.TraceQueryConditions { + conditions, err := clone(&TraceQueryConditions) + if err != nil { + return nil + } + return conditions +} + +func clone(src *pb.TraceQueryConditions) (*pb.TraceQueryConditions, error) { + var dst pb.TraceQueryConditions + buffer, _ := json.Marshal(&src) + err := json.Unmarshal(buffer, &dst) + if err != nil { + return nil, err + } + return &dst, nil +} diff --git a/modules/msp/apm/trace/core/query/query_test.go b/modules/msp/apm/trace/core/query/query_test.go new file mode 100644 index 00000000000..bc7c6a553fe --- /dev/null +++ b/modules/msp/apm/trace/core/query/query_test.go @@ -0,0 +1,132 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// Licensed 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 query + +import ( + "fmt" + "reflect" + "testing" + + "github.com/erda-project/erda-infra/providers/i18n" + "github.com/erda-project/erda-proto-go/msp/apm/trace/pb" +) + +func TestDepthCopyQueryConditions(t *testing.T) { + tests := []struct { + name string + want *pb.TraceQueryConditions + }{ + {"case1", &TraceQueryConditions}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := DepthCopyQueryConditions() + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("DepthCopyQueryConditions() = %v, want %v", got, tt.want) + } + // got point + gotPoint := getMemoryPoint(got) + gotPointOthers := getMemoryPoint(got.Others) + gotPointLimit := getMemoryPoint(got.Limit) + gotPointSort := getMemoryPoint(got.Sort) + gotPointTraceStatus := getMemoryPoint(got.TraceStatus) + + // TraceQueryConditions point + wantPoint := getMemoryPoint(tt.want) + wantPointOthers := getMemoryPoint(tt.want.Others) + wantPointLimit := getMemoryPoint(tt.want.Limit) + wantPointSort := getMemoryPoint(tt.want.Sort) + wantPointTraceStatus := getMemoryPoint(tt.want.TraceStatus) + + if gotPoint == wantPoint { + t.Errorf("gotPointServiceName = %v, wantPointServiceName %v", gotPoint, wantPoint) + } + if gotPointOthers == wantPointOthers { + t.Errorf("gotPointOthers = %v, wantPointOthers %v", gotPointOthers, wantPointOthers) + } + if gotPointLimit == wantPointLimit { + t.Errorf("gotPointServiceName = %v, wantPointServiceName %v", gotPointLimit, wantPointLimit) + } + if gotPointSort == wantPointSort { + t.Errorf("gotPointServiceName = %v, wantPointServiceName %v", gotPointSort, wantPointSort) + } + if gotPointTraceStatus == wantPointTraceStatus { + t.Errorf("gotPointServiceName = %v, wantPointServiceName %v", gotPointTraceStatus, wantPointTraceStatus) + } + }) + } +} + +func getMemoryPoint(need interface{}) string { + return fmt.Sprintf("%p", need) +} + +func Test_clone(t *testing.T) { + type args struct { + src *pb.TraceQueryConditions + } + tests := []struct { + name string + args args + want *pb.TraceQueryConditions + wantErr bool + }{ + {"case1", args{src: &TraceQueryConditions}, &TraceQueryConditions, false}, + {"case2", args{src: nil}, &TraceQueryConditions, true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := clone(tt.args.src) + if (err != nil) != tt.wantErr { + t.Errorf("clone() error = %v, wantErr %v", err, tt.wantErr) + return + } + if err != nil { + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("clone() got = %v, want %v", got, tt.want) + } + gotPoint := getMemoryPoint(got) + wantPoint := getMemoryPoint(tt.want) + if gotPoint == wantPoint { + t.Errorf("gotPointServiceName = %v, wantPointServiceName %v", gotPoint, wantPoint) + } + }) + } +} + +func TestTranslateCondition(t *testing.T) { + type args struct { + i18n i18n.Translator + lang i18n.LanguageCodes + key string + } + i18n := new(i18n.Translator) + tests := []struct { + name string + args args + want string + }{ + {"case1", args{i18n: *i18n, lang: nil, key: "test"}, "test"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := TranslateCondition(tt.args.i18n, tt.args.lang, tt.args.key); got != tt.want { + t.Errorf("TranslateCondition() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/modules/msp/apm/trace/db/tables.go b/modules/msp/apm/trace/db/tables.go index c11f565404b..bd2f12b4659 100644 --- a/modules/msp/apm/trace/db/tables.go +++ b/modules/msp/apm/trace/db/tables.go @@ -22,6 +22,7 @@ const ( type TraceRequestHistory struct { RequestId string `gorm:"column:request_id" db:"request_id" json:"request_id" form:"request_id"` + Name string `gorm:"column:name" db:"name" json:"name" form:"name"` TerminusKey string `gorm:"column:terminus_key" db:"terminus_key" json:"terminus_key" form:"terminus_key"` Url string `gorm:"column:url" db:"url" json:"url" form:"url"` QueryString string `gorm:"column:query_string" db:"query_string" json:"query_string" form:"query_string"` diff --git a/modules/msp/apm/trace/db/trace_request_history.go b/modules/msp/apm/trace/db/trace_request_history.go index 28efac6bc9a..a2b683e0bff 100644 --- a/modules/msp/apm/trace/db/trace_request_history.go +++ b/modules/msp/apm/trace/db/trace_request_history.go @@ -71,16 +71,25 @@ func (db *TraceRequestHistoryDB) QueryHistoryByRequestID(scopeID string, request func (db *TraceRequestHistoryDB) UpdateDebugStatusByRequestID(scopeID string, requestID string, statusCode int) (*TraceRequestHistory, error) { history := TraceRequestHistory{} - err := db.db().Where("`terminus_key` = ? AND `request_id` = ?", scopeID, requestID).Update("status", statusCode).Update("update_time", time.Now()).Find(&history).Error + err := db.db().Where("`terminus_key` = ? AND `request_id` = ?", scopeID, requestID). + Update("status", statusCode). + Update("update_time", time.Now()). + Find(&history). + Error if err != nil { return nil, err } return &history, nil } -func (db *TraceRequestHistoryDB) UpdateDebugResponseByRequestID(scopeID string, requestID string, responseCode int) (*TraceRequestHistory, error) { +func (db *TraceRequestHistoryDB) UpdateDebugResponseByRequestID(scopeID string, requestID string, responseCode int, responseBody string) (*TraceRequestHistory, error) { history := TraceRequestHistory{} - err := db.db().Where("`terminus_key` = ? AND `request_id` = ?", scopeID, requestID).Update("response_status", responseCode).Update("update_time", time.Now()).Find(&history).Error + err := db.db().Where("`terminus_key` = ? AND `request_id` = ?", scopeID, requestID). + Update("response_status", responseCode). + Update("response_body", responseBody). + Update("update_time", time.Now()). + Find(&history). + Error if err != nil { return nil, err } diff --git a/modules/msp/apm/trace/trace.service.go b/modules/msp/apm/trace/trace.service.go index e368cb22bb8..0938b3f7ae1 100644 --- a/modules/msp/apm/trace/trace.service.go +++ b/modules/msp/apm/trace/trace.service.go @@ -34,6 +34,9 @@ import ( "github.com/erda-project/erda-infra/providers/i18n" metricpb "github.com/erda-project/erda-proto-go/core/monitor/metric/pb" "github.com/erda-project/erda-proto-go/msp/apm/trace/pb" + "github.com/erda-project/erda/modules/msp/apm/trace/core/common" + "github.com/erda-project/erda/modules/msp/apm/trace/core/debug" + "github.com/erda-project/erda/modules/msp/apm/trace/core/query" "github.com/erda-project/erda/modules/msp/apm/trace/db" "github.com/erda-project/erda/pkg/common/apis" "github.com/erda-project/erda/pkg/common/errors" @@ -46,37 +49,24 @@ type traceService struct { traceRequestHistoryDB *db.TraceRequestHistoryDB } -const layout = "2006-01-02 15:04:05" - -type DebugStatus int32 - -const ( - DebugInit DebugStatus = 0 - DebugSuccess DebugStatus = 1 - DebugFail DebugStatus = 2 - DebugStop DebugStatus = 3 -) - -func (s *traceService) getDebugStatus(lang i18n.LanguageCodes, statusCode DebugStatus) string { +func (s *traceService) getDebugStatus(lang i18n.LanguageCodes, statusCode debug.Status) string { if lang == nil { return "" } switch statusCode { - case DebugInit: + case debug.Init: return s.i18n.Text(lang, "waiting_for_tracing_data") - case DebugSuccess: + case debug.Success: return s.i18n.Text(lang, "success_get_tracing_data") - case DebugFail: + case debug.Fail: return s.i18n.Text(lang, "fail_get_tracing_data") - case DebugStop: + case debug.Stop: return s.i18n.Text(lang, "stop_get_tracing_data") default: return "" } } -type SpanTree map[string]*pb.Span - func (s *traceService) GetSpans(ctx context.Context, req *pb.GetSpansRequest) (*pb.GetSpansResponse, error) { if req.TraceID == "" || req.ScopeID == "" { return nil, errors.NewMissingParameterError("traceId or scopeId") @@ -85,7 +75,7 @@ func (s *traceService) GetSpans(ctx context.Context, req *pb.GetSpansRequest) (* req.Limit = 1000 } iter := s.p.cassandraSession.Query("SELECT * FROM spans WHERE trace_id = ? limit ?", req.TraceID, req.Limit).Iter() - spanTree := make(SpanTree) + spanTree := make(query.SpanTree) for { row := make(map[string]interface{}) if !iter.MapScan(row) { @@ -109,9 +99,7 @@ func (s *traceService) GetSpans(ctx context.Context, req *pb.GetSpansRequest) (* return response, nil } -type void struct{} - -func (s *traceService) handleSpanResponse(spanTree SpanTree) (*pb.GetSpansResponse, error) { +func (s *traceService) handleSpanResponse(spanTree query.SpanTree) (*pb.GetSpansResponse, error) { var ( spans []*pb.Span traceStartTime int64 = 0 @@ -123,9 +111,9 @@ func (s *traceService) handleSpanResponse(spanTree SpanTree) (*pb.GetSpansRespon if spanCount > 0 { depth = 1 } - services := map[string]void{} - for _, span := range spanTree { - services[span.Tags["service_name"]] = void{} + services := map[string]common.Void{} + for id, span := range spanTree { + services[span.Tags["service_name"]] = common.Void{} tempDepth := calculateDepth(depth, span, spanTree) if tempDepth > depth { depth = tempDepth @@ -137,6 +125,7 @@ func (s *traceService) handleSpanResponse(spanTree SpanTree) (*pb.GetSpansRespon traceEndTime = span.EndTime } span.Duration = mathpkg.AbsInt64(span.EndTime - span.StartTime) + span.SelfDuration = span.Duration - childSpanDuration(id, spanTree) spans = append(spans, span) } @@ -145,7 +134,17 @@ func (s *traceService) handleSpanResponse(spanTree SpanTree) (*pb.GetSpansRespon return &pb.GetSpansResponse{Spans: spans, ServiceCount: serviceCount, Depth: depth, Duration: mathpkg.AbsInt64(traceEndTime - traceStartTime), SpanCount: spanCount}, nil } -func calculateDepth(depth int64, span *pb.Span, spanTree SpanTree) int64 { +func childSpanDuration(id string, spanTree query.SpanTree) int64 { + duration := int64(0) + for _, span := range spanTree { + if span.ParentSpanId == id { + duration += span.EndTime - span.StartTime + } + } + return duration +} + +func calculateDepth(depth int64, span *pb.Span, spanTree query.SpanTree) int64 { if span.ParentSpanId != "" && spanTree[span.ParentSpanId] != nil { depth += 1 calculateDepth(depth, spanTree[span.ParentSpanId], spanTree) @@ -160,50 +159,28 @@ func (s *traceService) GetSpanCount(ctx context.Context, traceID string) (int64, } func (s *traceService) GetTraces(ctx context.Context, req *pb.GetTracesRequest) (*pb.GetTracesResponse, error) { - if req.ScopeID == "" { - return nil, errors.NewMissingParameterError("scopeId") + if req.TenantID == "" { + return nil, errors.NewMissingParameterError("tenantId") } if req.Limit <= 0 { - req.Limit = 10 + req.Limit = 100 } if req.Limit > 1000 { req.Limit = 1000 } + if (req.DurationMin != 0 && req.DurationMax == 0) || (req.DurationMax != 0 && req.DurationMin == 0) { + return nil, errors.NewInvalidParameterError("duration", "missing min or max duration") + } + if req.DurationMax != 0 && req.DurationMin != 0 && req.DurationMax <= req.DurationMin { + return nil, errors.NewInvalidParameterError("duration", "duration min <= duration max") + } if req.EndTime <= 0 || req.StartTime <= 0 { req.EndTime = time.Now().UnixNano() / 1e6 h, _ := time.ParseDuration("-1h") req.StartTime = time.Now().Add(h).UnixNano() / 1e6 } - metricsParams := url.Values{} - metricsParams.Set("start", strconv.FormatInt(req.StartTime, 10)) - metricsParams.Set("end", strconv.FormatInt(req.EndTime, 10)) - queryParams := make(map[string]*structpb.Value) - queryParams["terminus_keys"] = structpb.NewStringValue(req.ScopeID) - var where bytes.Buffer - if req.ApplicationID > 0 { - queryParams["applications_ids"] = structpb.NewStringValue(strconv.FormatInt(req.ApplicationID, 10)) - where.WriteString("applications_ids::field=$applications_ids AND ") - } - if req.TraceID != "" { - queryParams["trace_id"] = structpb.NewStringValue(req.TraceID) - where.WriteString("trace_id::tag=$trace_id AND ") - } - - // -1 error, 0 both, 1 success - if req.Status == 1 { - where.WriteString("errors_sum::field=0 AND") - } else if req.Status == 0 { - where.WriteString("errors_sum::field>=0 AND") - } else if req.Status == -1 { - where.WriteString("errors_sum::field>0 AND") - } else { - return nil, errors.NewParameterTypeError("status just -1,0,1") - } - - statement := fmt.Sprintf("SELECT start_time::field,end_time::field,components::field,"+ - "trace_id::tag,if(gt(errors_sum::field,0),'error','success') FROM trace WHERE %s terminus_keys::field=$terminus_keys "+ - "ORDER BY start_time::field DESC LIMIT %s", where.String(), strconv.FormatInt(req.Limit, 10)) + queryParams, statement := s.composeTraceQueryConditions(req) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -221,20 +198,104 @@ func (s *traceService) GetTraces(ctx context.Context, req *pb.GetTracesRequest) } rows := response.Results[0].Series[0].Rows + traces := s.handleTracesResponse(rows) + + return &pb.GetTracesResponse{Data: traces}, nil +} + +func (s *traceService) handleTracesResponse(rows []*metricpb.Row) []*pb.Trace { traces := make([]*pb.Trace, 0, len(rows)) for _, row := range rows { var trace pb.Trace values := row.Values trace.StartTime = int64(values[0].GetNumberValue() / 1e6) - trace.Elapsed = math.Abs(values[1].GetNumberValue() - values[0].GetNumberValue()) + trace.Duration = math.Abs(values[1].GetNumberValue() - values[0].GetNumberValue()) for _, serviceName := range values[2].GetListValue().Values { trace.Services = append(trace.Services, serviceName.GetStringValue()) } trace.Id = values[3].GetStringValue() traces = append(traces, &trace) } + return traces +} - return &pb.GetTracesResponse{Data: traces}, nil +func (s *traceService) composeTraceQueryConditions(req *pb.GetTracesRequest) (map[string]*structpb.Value, string) { + metricsParams := url.Values{} + metricsParams.Set("start", strconv.FormatInt(req.StartTime, 10)) + metricsParams.Set("end", strconv.FormatInt(req.EndTime, 10)) + + queryParams := make(map[string]*structpb.Value) + queryParams["terminus_keys"] = structpb.NewStringValue(req.TenantID) + + var where bytes.Buffer + // trace id condition + if req.TraceID != "" { + queryParams["trace_id"] = structpb.NewStringValue(req.TraceID) + where.WriteString("trace_id::tag=$trace_id AND ") + } + + if req.ServiceName != "" { + queryParams["service_names"] = structpb.NewStringValue(req.ServiceName) + where.WriteString("service_names::field=$service_names AND ") + } + + if req.DubboMethod != "" { + queryParams["dubbo_methods"] = structpb.NewStringValue(req.DubboMethod) + where.WriteString("dubbo_methods::field=$dubbo_methods AND ") + } + + if req.HttpPath != "" { + queryParams["http_paths"] = structpb.NewStringValue(req.HttpPath) + where.WriteString("http_paths::field=$http_paths AND ") + } + + if req.DurationMin > 0 && req.DurationMax > 0 && req.DurationMin < req.DurationMax { + queryParams["duration_min"] = structpb.NewNumberValue(float64(req.DurationMin)) + queryParams["duration_max"] = structpb.NewNumberValue(float64(req.DurationMax)) + where.WriteString("duration::field>$duration_min AND duration::field<$duration_max AND ") + } + + // trace status condition + where.WriteString(s.traceStatusConditionStrategy(req.Status)) + // sort condition + sort := s.sortConditionStrategy(req.Sort) + + statement := fmt.Sprintf("SELECT start_time::field,end_time::field,service_names::field,"+ + "trace_id::tag,if(gt(errors_sum::field,0),'error','success') FROM trace WHERE %s terminus_keys::field=$terminus_keys "+ + "%s LIMIT %s", where.String(), sort, strconv.FormatInt(req.Limit, 10)) + return queryParams, statement +} + +func (s *traceService) traceStatusConditionStrategy(traceStatus string) string { + switch traceStatus { + case strings.ToLower(pb.TraceStatusCondition_TRACE_SUCCESS.String()): + return "errors_sum::field=0 AND" + case strings.ToLower(pb.TraceStatusCondition_TRACE_ALL.String()): + return "errors_sum::field>=0 AND" + case strings.ToLower(pb.TraceStatusCondition_TRACE_ERROR.String()): + return "errors_sum::field>0 AND" + default: + return "errors_sum::field>=0 AND" + } +} + +func (s *traceService) sortConditionStrategy(sort string) string { + switch sort { + case strings.ToLower(pb.SortCondition_TRACE_TIME_DESC.String()): + return "ORDER BY start_time::field DESC" + case strings.ToLower(pb.SortCondition_TRACE_TIME_ASC.String()): + return "ORDER BY start_time::field ASC" + case strings.ToLower(pb.SortCondition_TRACE_DURATION_DESC.String()): + return "ORDER BY duration::field DESC" + case strings.ToLower(pb.SortCondition_TRACE_DURATION_ASC.String()): + return "ORDER BY duration::field ASC" + case strings.ToLower(pb.SortCondition_SPAN_COUNT_DESC.String()): + return "ORDER BY span_count::field DESC" + case strings.ToLower(pb.SortCondition_SPAN_COUNT_ASC.String()): + return "ORDER BY span_count::field ASC" + default: + return "ORDER BY start_time::field DESC" + } } func (s *traceService) GetTraceDebugHistories(ctx context.Context, req *pb.GetTraceDebugHistoriesRequest) (*pb.GetTraceDebugHistoriesResponse, error) { @@ -271,6 +332,27 @@ func (s *traceService) GetTraceDebugHistories(ctx context.Context, req *pb.GetTr return &pb.GetTraceDebugHistoriesResponse{Data: &td}, nil } +func (s *traceService) GetTraceQueryConditions(ctx context.Context, req *pb.GetTraceQueryConditionsRequest) (*pb.GetTraceQueryConditionsResponse, error) { + return &pb.GetTraceQueryConditionsResponse{Data: s.translateConditions(apis.Language(ctx))}, nil +} + +func (s *traceService) translateConditions(lang i18n.LanguageCodes) *pb.TraceQueryConditions { + conditions := query.DepthCopyQueryConditions() + + for _, condition := range conditions.Sort { + condition.DisplayName = query.TranslateCondition(s.i18n, lang, condition.Key) + } + + for _, condition := range conditions.TraceStatus { + condition.DisplayName = query.TranslateCondition(s.i18n, lang, condition.Key) + } + + for _, condition := range conditions.Others { + condition.DisplayName = query.TranslateCondition(s.i18n, lang, condition.Key) + } + return conditions +} + func (s *traceService) GetTraceDebugByRequestID(ctx context.Context, req *pb.GetTraceDebugRequest) (*pb.GetTraceDebugResponse, error) { dbHistory, err := s.traceRequestHistoryDB.QueryHistoryByRequestID(req.ScopeID, req.RequestID) if err != nil { @@ -285,6 +367,9 @@ func (s *traceService) CreateTraceDebug(ctx context.Context, req *pb.CreateTrace if !bodyValid { return nil, errors.NewParameterTypeError("body") } + if req.Name == "" { + req.Name = "no name" + } history, err := composeTraceRequestHistory(req) if err != nil { @@ -297,7 +382,7 @@ func (s *traceService) CreateTraceDebug(ctx context.Context, req *pb.CreateTrace statusInfo := pb.TraceDebugStatus{ RequestID: insertHistory.RequestId, Status: int32(insertHistory.Status), - StatusName: s.getDebugStatus(apis.Language(ctx), DebugStatus(insertHistory.Status)), + StatusName: s.getDebugStatus(apis.Language(ctx), debug.Status(insertHistory.Status)), ScopeID: insertHistory.TerminusKey, } @@ -306,6 +391,7 @@ func (s *traceService) CreateTraceDebug(ctx context.Context, req *pb.CreateTrace return nil, errors.NewInternalServerError(err) } responseCode := response.StatusCode + responseBody, err := ioutil.ReadAll(response.Body) defer func(Body io.ReadCloser) { err := Body.Close() @@ -314,7 +400,7 @@ func (s *traceService) CreateTraceDebug(ctx context.Context, req *pb.CreateTrace } }(response.Body) - _, err = s.traceRequestHistoryDB.UpdateDebugResponseByRequestID(req.ScopeID, req.RequestID, responseCode) + _, err = s.traceRequestHistoryDB.UpdateDebugResponseByRequestID(req.ScopeID, req.RequestID, responseCode, string(responseBody)) if err != nil { return nil, errors.NewInternalServerError(err) } @@ -339,20 +425,21 @@ func composeTraceRequestHistory(req *pb.CreateTraceDebugRequest) (*db.TraceReque if err != nil { return nil, errors.NewInternalServerError(err) } - if req.CreateTime == "" || req.UpdateTime == "" { - req.CreateTime = time.Now().Format(layout) - req.UpdateTime = time.Now().Format(layout) + if req.CreateTime == "" { + req.CreateTime = time.Now().Format(common.Layout) } - createTime, err := time.ParseInLocation(layout, req.CreateTime, time.Local) + createTime, err := time.ParseInLocation(common.Layout, req.CreateTime, time.Local) if err != nil { return nil, errors.NewInternalServerError(err) } - updateTime, err := time.ParseInLocation(layout, req.UpdateTime, time.Local) + req.UpdateTime = time.Now().Format(common.Layout) + updateTime, err := time.ParseInLocation(common.Layout, req.UpdateTime, time.Local) if err != nil { return nil, errors.NewInternalServerError(err) } history := &db.TraceRequestHistory{ + Name: req.Name, RequestId: req.RequestID, TerminusKey: req.ScopeID, Url: req.Url, @@ -393,7 +480,7 @@ func (s *traceService) tracing(request *http.Request, req *pb.CreateTraceDebugRe } func (s *traceService) StopTraceDebug(ctx context.Context, req *pb.StopTraceDebugRequest) (*pb.StopTraceDebugResponse, error) { - _, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(req.ScopeID, req.RequestID, int(DebugFail)) + _, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(req.ScopeID, req.RequestID, int(debug.Fail)) if err != nil { return nil, errors.NewDatabaseError(err) } @@ -426,31 +513,31 @@ func (s *traceService) GetTraceDebugHistoryStatusByRequestID(ctx context.Context statusInfo := pb.TraceDebugStatus{ RequestID: dbHistory.RequestId, Status: int32(dbHistory.Status), - StatusName: s.getDebugStatus(apis.Language(ctx), DebugStatus(dbHistory.Status)), + StatusName: s.getDebugStatus(apis.Language(ctx), debug.Status(dbHistory.Status)), ScopeID: dbHistory.TerminusKey, } - if DebugStatus(dbHistory.Status) == DebugInit { + if debug.Status(dbHistory.Status) == debug.Init { exist, err := s.isExistSpan(ctx, req.RequestID) if err != nil { return nil, errors.NewInternalServerError(err) } if exist { - info, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(dbHistory.TerminusKey, dbHistory.RequestId, int(DebugSuccess)) + info, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(dbHistory.TerminusKey, dbHistory.RequestId, int(debug.Success)) if err != nil { return nil, errors.NewInternalServerError(err) } statusInfo.Status = int32(info.Status) - statusInfo.StatusName = s.getDebugStatus(apis.Language(ctx), DebugStatus(info.Status)) + statusInfo.StatusName = s.getDebugStatus(apis.Language(ctx), debug.Status(info.Status)) } else { // If trace data is not obtained within 20 minutes, it is considered that the writing of trace data has failed. if (time.Now().UnixNano()-dbHistory.UpdateTime.UnixNano())/1e9 > 20*60 { - info, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(dbHistory.TerminusKey, dbHistory.RequestId, int(DebugFail)) + info, err := s.traceRequestHistoryDB.UpdateDebugStatusByRequestID(dbHistory.TerminusKey, dbHistory.RequestId, int(debug.Fail)) if err != nil { return nil, errors.NewInternalServerError(err) } statusInfo.Status = int32(info.Status) - statusInfo.StatusName = s.getDebugStatus(apis.Language(ctx), DebugStatus(info.Status)) + statusInfo.StatusName = s.getDebugStatus(apis.Language(ctx), debug.Status(info.Status)) } } } @@ -483,11 +570,11 @@ func (s *traceService) convertToTraceDebugHistory(ctx context.Context, dbHistory Header: headers, Body: dbHistory.Body, Status: int32(dbHistory.Status), - StatusName: s.getDebugStatus(language, DebugStatus(dbHistory.Status)), + StatusName: s.getDebugStatus(language, debug.Status(dbHistory.Status)), ResponseCode: int32(dbHistory.ResponseStatus), ResponseBody: dbHistory.ResponseBody, Method: dbHistory.Method, - CreateTime: dbHistory.CreateTime.Format(layout), - UpdateTime: dbHistory.UpdateTime.Format(layout), + CreateTime: dbHistory.CreateTime.Format(common.Layout), + UpdateTime: dbHistory.UpdateTime.Format(common.Layout), }, nil } diff --git a/modules/msp/apm/trace/trace.service_test.go b/modules/msp/apm/trace/trace.service_test.go index bf827e1fb39..9b9abd0877c 100644 --- a/modules/msp/apm/trace/trace.service_test.go +++ b/modules/msp/apm/trace/trace.service_test.go @@ -24,7 +24,10 @@ import ( uuid "github.com/satori/go.uuid" "github.com/erda-project/erda-infra/base/servicehub" + "github.com/erda-project/erda-infra/providers/i18n" "github.com/erda-project/erda-proto-go/msp/apm/trace/pb" + "github.com/erda-project/erda/modules/msp/apm/trace/core/common" + "github.com/erda-project/erda/modules/msp/apm/trace/core/debug" "github.com/erda-project/erda/modules/msp/apm/trace/db" ) @@ -142,6 +145,63 @@ func Test_traceService_GetTraces(t *testing.T) { } } +func Test_traceService_GetTraceQueryConditions(t *testing.T) { + type args struct { + ctx context.Context + req *pb.GetTraceQueryConditionsRequest + } + tests := []struct { + name string + service string + config string + args args + wantResp *pb.GetTraceQueryConditionsResponse + wantErr bool + }{ + // TODO: Add test cases. + // { + // "case 1", + // "erda.msp.apm.trace.TraceService", + // ` + //erda.msp.apm.trace: + //`, + // args{ + // context.TODO(), + // &pb.GetTraceQueryConditionsRequest{ + // // TODO: setup fields + // }, + // }, + // &pb.GetTraceQueryConditionsResponse{ + // // TODO: setup fields. + // }, + // false, + // }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + hub := servicehub.New() + events := hub.Events() + go func() { + hub.RunWithOptions(&servicehub.RunOptions{Content: tt.config}) + }() + err := <-events.Started() + if err != nil { + t.Error(err) + return + } + srv := hub.Service(tt.service).(pb.TraceServiceServer) + got, err := srv.GetTraceQueryConditions(tt.args.ctx, tt.args.req) + if (err != nil) != tt.wantErr { + t.Errorf("traceService.GetTraceQueryConditions() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.wantResp) { + t.Errorf("traceService.GetTraceQueryConditions() = %v, want %v", got, tt.wantResp) + } + }) + } +} + func Test_traceService_GetTraceDebugHistories(t *testing.T) { type args struct { ctx context.Context @@ -452,14 +512,14 @@ func Test_composeTraceRequestHistory(t *testing.T) { return } if req.CreateTime == "" || req.UpdateTime == "" { - req.CreateTime = time.Now().Format(layout) - req.UpdateTime = time.Now().Format(layout) + req.CreateTime = time.Now().Format(common.Layout) + req.UpdateTime = time.Now().Format(common.Layout) } - createTime, err := time.ParseInLocation(layout, req.CreateTime, time.Local) + createTime, err := time.ParseInLocation(common.Layout, req.CreateTime, time.Local) if err != nil { return } - updateTime, err := time.ParseInLocation(layout, req.UpdateTime, time.Local) + updateTime, err := time.ParseInLocation(common.Layout, req.UpdateTime, time.Local) if err != nil { return } @@ -488,14 +548,14 @@ func Test_composeTraceRequestHistory(t *testing.T) { return } if req2.CreateTime == "" || req2.UpdateTime == "" { - req2.CreateTime = time.Now().Format(layout) - req2.UpdateTime = time.Now().Format(layout) + req2.CreateTime = time.Now().Format(common.Layout) + req2.UpdateTime = time.Now().Format(common.Layout) } - createTime2, err := time.ParseInLocation(layout, req2.CreateTime, time.Local) + createTime2, err := time.ParseInLocation(common.Layout, req2.CreateTime, time.Local) if err != nil { return } - updateTime2, err := time.ParseInLocation(layout, req2.UpdateTime, time.Local) + updateTime2, err := time.ParseInLocation(common.Layout, req2.UpdateTime, time.Local) if err != nil { return } @@ -524,14 +584,14 @@ func Test_composeTraceRequestHistory(t *testing.T) { return } if req3.CreateTime == "" || req3.UpdateTime == "" { - req3.CreateTime = time.Now().Format(layout) - req3.UpdateTime = time.Now().Format(layout) + req3.CreateTime = time.Now().Format(common.Layout) + req3.UpdateTime = time.Now().Format(common.Layout) } - createTime3, err := time.ParseInLocation(layout, req3.CreateTime, time.Local) + createTime3, err := time.ParseInLocation(common.Layout, req3.CreateTime, time.Local) if err != nil { return } - updateTime3, err := time.ParseInLocation(layout, req3.UpdateTime, time.Local) + updateTime3, err := time.ParseInLocation(common.Layout, req3.UpdateTime, time.Local) if err != nil { return } @@ -629,3 +689,38 @@ func Test_bodyCheck(t *testing.T) { }) } } + +func Test_traceService_getDebugStatus(t *testing.T) { + type fields struct { + p *provider + i18n i18n.Translator + traceRequestHistoryDB *db.TraceRequestHistoryDB + } + type args struct { + lang i18n.LanguageCodes + statusCode debug.Status + } + tests := []struct { + name string + fields fields + args args + want string + }{ + {"case1", fields{p: nil, i18n: nil, traceRequestHistoryDB: nil}, args{lang: nil, statusCode: debug.Success}, ""}, + {"case2", fields{p: nil, i18n: nil, traceRequestHistoryDB: nil}, args{lang: nil, statusCode: debug.Init}, ""}, + {"case3", fields{p: nil, i18n: nil, traceRequestHistoryDB: nil}, args{lang: nil, statusCode: debug.Fail}, ""}, + {"case4", fields{p: nil, i18n: nil, traceRequestHistoryDB: nil}, args{lang: nil, statusCode: debug.Stop}, ""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := &traceService{ + p: tt.fields.p, + i18n: tt.fields.i18n, + traceRequestHistoryDB: tt.fields.traceRequestHistoryDB, + } + if got := s.getDebugStatus(tt.args.lang, tt.args.statusCode); got != tt.want { + t.Errorf("getDebugStatus() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/modules/openapi/api/apis/msp/apm/trace/get_trace_conditions_list.go b/modules/openapi/api/apis/msp/apm/trace/get_trace_conditions_list.go new file mode 100644 index 00000000000..263237121d9 --- /dev/null +++ b/modules/openapi/api/apis/msp/apm/trace/get_trace_conditions_list.go @@ -0,0 +1,28 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// Licensed 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 trace + +import "github.com/erda-project/erda/modules/openapi/api/apis" + +var GET_TRACE_CONDITIONS_LIST = apis.ApiSpec{ + Path: "/api/msp/apm/trace/conditions", + BackendPath: "/api/msp/apm/trace/conditions", + Host: "msp.marathon.l4lb.thisdcos.directory:8080", + Scheme: "http", + Method: "GET", + CheckLogin: true, + CheckToken: true, + Doc: "Query apm traces Conditions.", +}