在Go中将统计处理程序附加到gRPC

因此,我正在使用多路复用器来确定传入的请求类型(gRPC或REST)并路由请求 因此。 对于gRPC请求,我附加了一个统计处理程序以收集一些元数据,但未调用用于标记元数据的接口方法之一 TagRPC()</ code>。 </ p>

  app.httpMux.HandleFunc(“ /”,func(w http.ResponseWriter,r * http.Request){
if isgRPC(r){
应用。 gRPCServer.ServeHTTP(w,r)
}其他{
app.rMux.ServeHTTP(w,r)
}
})
</ code> </ pre>

I 认为问题出在gRPC的ServeHTTP方法不支持所有方法。 如果我要手动附加 TagGRPC()</ code>,在哪里可以实现?</ p>
</ div>

展开原文

原文

So I am using a mux that will determine what type of request is incoming (gRPC or REST) and route the request accordingly. For gRPC requests I am attaching a stats handler to collect some metadata but one of the interface methods TagRPC() which we use to tag our metadata is not being called.

app.httpMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    if isgRPC(r) {
        app.gRPCServer.ServeHTTP(w, r)
    } else {
        app.rMux.ServeHTTP(w, r)
    }
})

I think the problem is with gRPC's ServeHTTP method not supporting all the methods. If I were to attach TagGRPC() manually where would be a good place to do it?

1个回答



统计处理程序现在在ServeHTTP处理程序中不完全受支持。</ p>

https://github.com/grpc/grpc-go/issues/1784 </ p>

(我刚刚注意到您也提出了此问题,但这可能对其他对此也有帮助的人有所帮助)</ p>
</ div>

展开原文

原文

stats handler is not fully support in ServeHTTP Handler now.

More details in https://github.com/grpc/grpc-go/issues/1784

(I just noticed that you also filed the issue, but this may help other people also interested in this)

立即提问
相关内容推荐