Skip to content

help request: 插件 request-id 与 opentelemetry 结合 #7239

Description

@shuqingzai

Description

问题

request-id 支持三种方式生成: ["uuid", "snowflake", "nanoid"]

  1. 我想使用 request-id 作为 opentelemetry 的 trace_id 但是 trace_id 需要符合 [0-9a-f]{32} 规范,request-id 并没有这样的生成器,是否可以新增一个 request-id 的生成方式?
  2. 我想在 opentelemetry 的 additional_attributes 追加 request-id 属性,但是我试了很多种读取的方式,好像都不能读取,以下是我的配置,请问有啥方式可以读取?
{
    "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

docker pull apache/apisix:2.14.1-centos
  • APISIX version (run apisix version):
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version
2.14.1
  • Operating system (run uname -a):
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):
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-api/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_module --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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions