You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/06/12 15:31:27 UTC
[GitHub] [apisix] shuqingzai opened a new issue, #7239: help request: 插件 request-id 与 opentelemetry 结合
shuqingzai opened a new issue, #7239:
URL: https://github.com/apache/apisix/issues/7239
### Description
### 问题
[request-id](https://apisix.apache.org/zh/docs/apisix/plugins/request-id) 支持三种方式生成: ["uuid", "snowflake", "nanoid"]
1. 我想使用 request-id 作为 [opentelemetry](https://apisix.apache.org/zh/docs/apisix/plugins/opentelemetry) 的 trace_id 但是 trace_id 需要符合 `[0-9a-f]{32}` 规范,request-id 并没有这样的生成器,是否可以新增一个 request-id 的生成方式?我认为基于上面三种生成 ID 后使用 `md5` hash 即可?
2. 我想在 opentelemetry 的 additional_attributes 追加 request-id 属性,但是我试了很多种读取的方式,好像都不能读取,以下是我的配置,请问有啥方式可以读取?
```json
{
"id": "1",
"create_time": 1655032228,
"update_time": 1655045468,
"plugins": {
"opentelemetry": {
"additional_attributes": [
"route_id",
"x-request-id",
"request-id",
"http_x-request-id",
"X-Request-Id",
"http_X-Request-Id"
],
"disable": false,
"sampler": {
"name": "always_on",
"options": {
"fraction": 1,
"root": {
"name": "always_on"
}
}
}
},
"request-id": {
"algorithm": "snowflake",
"disable": false,
"header_name": "X-Request-Id",
"include_in_response": true
}
}
}
```
### Environment
### 使用版本
官方`docker`镜像: `apache/apisix:2.14.1-centos`
```shell
docker pull apache/apisix:2.14.1-centos
````
- APISIX version (run `apisix version`):
```text
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version
2.14.1
```
- Operating system (run `uname -a`):
```text
Linux apisix1 5.10.104-linuxkit #1 SMP Thu Mar 17 17:08:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
```
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
```text
nginx version: openresty/1.19.9.1
built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
built with OpenSSL 1.1.1n 15 Mar 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.19.9.1.6 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.20 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.10 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-ap
i/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../mod_dubbo --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../ngx_multi_upstream_module --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../apisix-nginx-module --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../apisix-nginx-module/src/stream --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../wasm-nginx-module --add-module=/tmp/tmp.itsGpY3Nfs/openresty-1.19.9.1/../lua-var-nginx-module --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_modul
e --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
```
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1153465137
> 2\. 我想在 opentelemetry 的 additional_attributes 追加 request-id 属性,但是我试了很多种读取的方式,好像都不能读取,以下是我的配置,请问有啥方式可以读取?
`opentelemetry` and `request-id` both work on `rewrite` phase in APISIX, but `opentelemetry` has a higher priority and is executed before the `request-id`, so it can't get the id generated by `request-id`.
maybe we can raise the priority of `request-id`? what is your option? cc @spacewander @membphis
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #7239: help request: 插件 request-id 与 opentelemetry 结合
URL: https://github.com/apache/apisix/issues/7239
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jagerzhang commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
jagerzhang commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1158592435
> opentelemetry is moved to the top so we can report requests which are rejected. If opentelemetry needs to depend on request-id, the priority of request-id should be higher.
嗯嗯,那这个调整是在apisix这边改还是用户自己改
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1153465265
> 1. 我想使用 request-id 作为 [opentelemetry](https://apisix.apache.org/zh/docs/apisix/plugins/opentelemetry) 的 trace_id 但是 trace_id 需要符合 `[0-9a-f]{32}` 规范,request-id 并没有这样的生成器,是否可以新增一个 request-id 的生成方式?
SGTM
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jagerzhang commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
jagerzhang commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1157426251
> Maybe after `request-validation`?
@tokers request-id现在的优先级不低,感觉这里的问题可能还是 opentelemetry 的优先级调得太高了,超过了request-id。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shuqingzai commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
shuqingzai commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1153475198
> > 2. 我想在 opentelemetry 的 additional_attributes 追加 request-id 属性,但是我试了很多种读取的方式,好像都不能读取,以下是我的配置,请问有啥方式可以读取?
>
> `opentelemetry` and `request-id` both work on `rewrite` phase in APISIX, but `opentelemetry` has a higher priority and is executed before the `request-id`, so it can't get the id generated by `request-id`.
>
> maybe we can raise the priority of `request-id`? what is your option? cc @spacewander @membphis
我觉得 request-id 应该是级别最高的吧?无论请求是否成功响应,都应该记录一个 request-id 方便排查问题?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1153515684
> maybe we can raise the priority of request-id? what is your option?
LGTM.
@shuqingzai
Would you like to work on it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shuqingzai commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
shuqingzai commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1153797864
> > maybe we can raise the priority of request-id? what is your option?
>
> LGTM. @shuqingzai Would you like to work on it?
十分抱歉,我对 `lua` 不是很熟悉。。。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1158556812
opentelemetry is moved to the top so we can report requests which are rejected.
If opentelemetry needs to depend on request-id, the priority of request-id should be higher.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1159704040
> > opentelemetry is moved to the top so we can report requests which are rejected. If opentelemetry needs to depend on request-id, the priority of request-id should be higher.
>
> 嗯嗯,那这个调整是在apisix这边改还是用户自己改
You can change it yourselves, and submit it to APISIX.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jagerzhang commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
jagerzhang commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1157419406
看了下2.11版本的插件优先级:
```
client-control 22000
ext-plugin-pre-req 12000
zipkin 11011
request-id 11010
fault-injection 11000
serverless-pre-function 10000
batch-requests 4010
cors 4000
ip-restriction 3000
ua-restriction 2999
referer-restriction 2990
uri-blocker 2900
request-validation 2800
openid-connect 2599
wolf-rbac 2555
hmac-auth 2530
basic-auth 2520
jwt-auth 2510
key-auth 2500
consumer-restriction 2400
authz-keycloak 2000
proxy-mirror 1010
proxy-cache 1009
proxy-rewrite 1008
api-breaker 1005
limit-conn 1003
limit-count-by-client 1002
limit-count 1002
limit-req 1001
gzip 995
server-info 990
traffic-split 966
redirect 900
response-rewrite 899
trpc-transcode 677
grpc-transcode 506
zhiyan-log 504
prometheus 500
echo 412
http-logger 410
skywalking-logger 408
sls-logger 406
tcp-logger 405
kafka-logger 403
syslog 401
udp-logger 400
opentelemetry -1200 -- last running plugin, but before serverless post func
serverless-post-function -2000
ext-plugin-post-req -3000
```
requests-id的执行阶段是比较靠前的,不过看最新的代码,opentelemetry 的优先级由-1200改为12009,排到了第二位:
https://github.com/apache/apisix/blob/70ba952ef7123b463af219a036548aa8721255b4/apisix/plugins/opentelemetry.lua#L179
https://github.com/apache/apisix/blob/70ba952ef7123b463af219a036548aa8721255b4/apisix/plugins/request-id.lua#L67
所以@[shuqingzai](https://github.com/shuqingzai) 你只需要改下插件代码里面的 priority 就能改变这个执行阶段顺序。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #7239: help request: 插件 request-id 与 opentelemetry 结合
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #7239:
URL: https://github.com/apache/apisix/issues/7239#issuecomment-1157424007
Maybe after `request-validation`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org