Skip to content

bug: zipkin plugin's traceId printed to accessLog are all escaped characters #12271

@lchpersonal

Description

@lchpersonal

Current Behavior

I configured the zipkin plugin in the route and added the printing of fields such as traceId in config.yaml, but found that all the printed traceIds are escape characters.
"10.10.112.82 - - [30/May/2025:14:37:18 +0800] \x93\xAAu\xD1\x86\xC3)\xE3\x1F))\xA5\x85\x90\xB8\xC2 9cm\xC9D\xE6\x22\xEF 172.30.94.83:9080 "GET /TradingCenterService/info?id=7643278011111 HTTP/1.1" 200 12 0.020 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" 172.31.241.185:8658 200 0.021 "http://172.31.241.185:8658""

zipkin plugin configuration:
{
"_meta": {
"disable": false
},
"endpoint": "http://172.30.9.198:9411/api/v2/spans",
"sample_ratio": 1,
"service_name": "xxxService",
"span_version": 2
}

Expected Behavior

Expected to print normal strings as logs:

"10.10.112.82 - - [30/May/2025:14:37:18 +0800] 68390dfc6ad634967dd98a6b209fc317 7dd98a6b209fc317172.30.94.83:9080 "GET /TradingCenterService/info?id=7643278011111 HTTP/1.1" 200 12 0.020 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" 172.31.241.185:8658 200 0.021 "http://172.31.241.185:8658""

Error Logs

2025/05/30 14:37:08 [warn] 452172#452172: 6 [lua] utils.lua:418: find_and_log(): Using zipkin endpoint with no TLS is a security risk, context: init_worker_by_lua
2025/05/30 14:37:08 [warn] 452172#452172: 6 [lua] utils.lua:418: find_and_log(): Using zipkin endpoint with no TLS is a security risk, context: init_worker_by_lua

Steps to Reproduce

  1. create a route:
{
  "uri": "/anything",
  "name": "anything",
  "plugins": {
    "zipkin": {
      "_meta": {
        "disable": false
      },
      "endpoint": "http://172.30.9.198:9411/api/v2/spans",
      "sample_ratio": 1,
      "service_name": "APISIX",
      "span_version": 2
    }
  },
  "upstream": {
    "nodes": [
      {
        "host": "httpbin.org",
        "weight": 1
      }
    ],
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "http",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}
  1. modify the accesslog format,according to the doc: https://apisix.apache.org/zh/docs/apisix/plugins/zipkin/
  2. send a get request: http://172.30.94.83:9080/anything, got response:
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Host": "172.30.94.83", 
    "User-Agent": "curl/7.79.1", 
    "X-Amzn-Trace-Id": "Root=1-68395d66-71f2fc5117203bad0ca30d57", 
    "X-B3-Parentspanid": "eae1a760e4060ded", 
    "X-B3-Sampled": "1", 
    "X-B3-Spanid": "9b955f9d7cbde437", 
    "X-B3-Traceid": "a04ab3e00c3fdcffa5eba0c42c8b8b81", 
    "X-Forwarded-Host": "172.30.94.83"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "172.30.94.83, 211.91.71.13", 
  "url": "http://172.30.94.83/anything"
}
  1. View access.log found the traceIds printed are all escape characters.

Environment

  • APISIX version (run apisix version): 3.12
  • Operating system (run uname -a): Linux 172.30.94.83 5.10.0-60.18.0.50.oe2203.x86_64 change: added doc of how to load plugin. #1 SMP Wed Mar 30 03:12:24 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):
    nginx version: openresty/1.27.1.1
  • 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

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions