kingluo commented on issue #7674:
URL: https://github.com/apache/apisix/issues/7674#issuecomment-1216450883
@akalittle The `hex2bytes` assumes the input string is in valid hex format
(`[0-9a-f]{32}`), and transforms each hex u8 number into char. The `char()`
assumes the number ranges from 0~255, otherwise it would throw error.
It's likely your `span.ctx.trace_id`
(https://github.com/yangxikun/opentelemetry-lua/blob/v0.1.3/lib/opentelemetry/trace/exporter/otlp.lua#L50)
contains `-`, which means negative number and cause `char()` failed. It means
your trace id comes from `x-request-id` in invalid format.
```lua
local function hex2bytes(str)
return (str:gsub('..', function (cc)
local n = tonumber(cc, 16)
if n then
print(n)
return string.char(n)
end
end))
end
hex2bytes("xx-1")
```
```
/usr/local/openresty-debug/luajit/bin/luajit: bad argument #1 to '?'
(invalid value)
stack traceback:
[builtin#80]: at 0x5571dae60530
[C]: in function 'gsub'
/tmp/test_gsub.lua:2: in function 'hex2bytes'
/tmp/test_gsub.lua:11: in main chunk
[C]: at 0x5571dadfc320
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]