Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 自定义开发wasm 遇见的几个问题 #6163

Open
3 tasks done
wuzongling opened this issue Apr 19, 2024 · 6 comments
Open
3 tasks done

[BUG] 自定义开发wasm 遇见的几个问题 #6163

wuzongling opened this issue Apr 19, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@wuzongling
Copy link

wuzongling commented Apr 19, 2024

Search before asking

  • I had searched in the issues and found no similar feature requirement.

DeepFlow Component

Agent

What you expected to happen

1 wasn_instance: "tx_wasm" wasm on http resp fail: vm call on_http_resp fail: error while executing at wasm backtrace:
0: memory fault at wasm address 0x18828a4 in linear memory of size 0x1000000
1: wasm trap: out of bounds memory acces
image

加上_ "github.com/wasilibs/nottinygc"后,报了新错误:wasn_instance: "tx_wasm" wasm on http resp fail: vm call on_http_resp fail: error while executing at wasm backtrace:

2 wasn_instance: "tx_wasm" wasm on http resp fail: vm call on_http_resp fail: error while executing at wasm backtrace:

3 采集到的body 是缺失的,有的是没有采集到body,有的是采集的json 不全
image
image

4 采集到的trace id 在grafana 上,根据查询条件查询不出来
image
image

5 这里生成的request id 不知道哪里生成出来的
image

6 Exception 的值设置不省心,都是OK
企业微信截图_31601fee-6d56-4e0d-9d66-bc1ded90e47a
企业微信截图_0c3b4810-2647-48af-9daa-c9d7f4757049
企业微信截图_29b10512-da8e-4ab7-99f0-239ec3be5c77

How to reproduce

No response

DeepFlow version

agent :6.3.8

server : 基于6.2.5 二次开发

DeepFlow agent list

No response

Kubernetes CNI

No response

Operation-System/Kernel version

No response

Anything else

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@wuzongling wuzongling added the bug Something isn't working label Apr 19, 2024
@1473371932
Copy link
Contributor

你好,目前经过分析与复现,得出结论:

  1. 导致 painc 原因如下: 代码中些问题,比如下面这里如果还没赋值,可能会导致 panic。建议将错误处理完善一下,目前 wasm 插件发生 panic 会 trap 且无法捕获,所以需要自己预防一下 panic
    img_v3_02a9_7839aeb3-85a1-4793-ba8b-27a3cd85361g
  2. 数据缺失问题(body,json 缺失)原因如下:可能是出现分包了(不确定)
  3. 采集到的 trace id 在 grafana 上,根据查询条件查询不出来,可能为 trace_id 等数据匹配时带有引号,建议前后去掉引号,或者把引号换位星号
    img_v3_02a9_2e3b6b7b-c835-4c4b-9257-c3a63f751e3g
  4. 生成的 request id 不知道哪里生成出来的,原因如下:我们是无插桩的,也不会凭空生成一个 request id,需要检查一下代码中有没有赋值的位置
  5. exception 不省心,需要检查一下对应设置
    img_v3_02a9_5335a98d-d62d-48f8-9de7-1ed97190f8cg
    img_v3_02a9_03f6187b-ec12-4f88-ad36-658908875a5g

@wuzongling
Copy link
Author

1 导致 painc 原因如下: 代码中些问题,比如下面这里如果还没赋值,可能会导致 panic。建议将错误处理完善一下,目前 wasm 插件发生 panic 会 trap 且无法捕获,所以需要自己预防一下 panic。
这个我们测试的时候也发现,现在是可能空指针的都做了判断。这里有个问题,在wasm 插件里面做defer 去捕获panic 不知道会不会生效,现在代码是这样写了

@wuzongling
Copy link
Author

生成的 request id 不知道哪里生成出来的,原因如下:我们是无插桩的,也不会凭空生成一个 request id,需要检查一下代码中有没有赋值的位置。
可能是我们网关集成了otel ,它自己做了一些设置导致的。这个问题不大

@wuzongling
Copy link
Author

exception 不省心,需要检查一下对应设置。 这个我们代码是没有设置OK,所以为了排查我们把response.Exception的值写到了属性里面的Exception,来做比较。看我上面的截图就发现Exception: error-, 但是 grafana上面显示的还是Ok

@TomatoMr
Copy link
Contributor

1 导致 painc 原因如下: 代码中些问题,比如下面这里如果还没赋值,可能会导致 panic。建议将错误处理完善一下,目前 wasm 插件发生 panic 会 trap 且无法捕获,所以需要自己预防一下 panic。 这个我们测试的时候也发现,现在是可能空指针的都做了判断。这里有个问题,在wasm 插件里面做defer 去捕获panic 不知道会不会生效,现在代码是这样写了

panic 不会被捕获,会直接 trap,所以还是要预防一下 panic

@TomatoMr
Copy link
Contributor

exception 不省心,需要检查一下对应设置。 这个我们代码是没有设置OK,所以为了排查我们把response.Exception的值写到了属性里面的Exception,来做比较。看我上面的截图就发现Exception: error-, 但是 grafana上面显示的还是Ok

你好,我确认了一下,response_exception 确实是从插件赋值的。所以 grafana 里查到的 response_exception 应该是和 attributes 里的一致,是否 grafana 的 query 有改动呢?

@sharang sharang assigned 1473371932 and unassigned TomatoMr May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants