go-kratos / kratos

Your ultimate Go microservices framework for the cloud-native era.
https://go-kratos.dev
MIT License
23.13k stars 3.99k forks source link

[Question]Why design middleware after bind? #3186

Closed FPNL closed 4 months ago

FPNL commented 7 months ago

主要想問的是設計上的理念

我有個情境是,Access log 想要記錄所有的 API,就我理解在 go-kratos 中 log 是 middleware,可是如果出現了 CODEC 錯誤,這樣不會進到 middleware,使用者回報問題時,就找不到相關紀錄。

為什麼設計上是先 bind 在 mid? 另外,上述的情境也是有方法可以做到 log 包含 404 所有的 API 嗎?

kratos-ci-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The main thing I want to ask about is the design concept

I have a situation where the Access log wants to record all APIs. As I understand it, the log in go-kratos is middleware. However, if a CODEC error occurs, it will not enter the middleware. When users report problems, they cannot find it. to relevant records.

Why is the design designed to bind first in mid? In addition, in the above situation, is there a way to make the log include 404 for all APIs?

dosubot[bot] commented 4 months ago

Hi, @FPNL,

I'm helping the Kratos team manage their backlog and am marking this issue as stale. From what I understand, you are seeking clarification on the design philosophy behind placing middleware after binding, specifically regarding logging all API requests, including those that may result in codec errors, and ensuring that all API requests, including 404 errors, are logged. Currently, there hasn't been any further activity or resolution on this issue.

Could you please confirm if this issue is still relevant to the latest version of the Kratos repository? If it is, please let the Kratos team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!