tengine icon indicating copy to clipboard operation
tengine copied to clipboard

ngx-http-reqstats-module 统计 bytes_out 问题

Open whitehatboxer opened this issue 2 years ago • 1 comments

Question

为了统计 bytes_out 的大小,tengine 修改了 src/http/ngx_http_write_filter_module.c 中的 ngx_http_write_filter 函数,以统计发送出去的字节数。

想知道为什么不在模块中写一个 ngx_http_output_body_filter 呢?这样可以避免修改核心代码,感觉是一种更简洁友好的做法。

whitehatboxer avatar Aug 02 '22 10:08 whitehatboxer

只有在 紧接着 chain = c->send_chain(c, r->out, limit); 后才能保证拿到准确发送的数据,任何往后推迟的阶段都可能导致你的统计逻辑无法被运行到(尤其是output filter,任意3方逻辑和nginx core错误处理逻辑都可能跳过后续统计)

chobits avatar Aug 08 '22 13:08 chobits

think it resolved

chobits avatar Aug 15 '22 02:08 chobits