dongluanjie8678 2018-01-09 16:11
浏览 117
已采纳

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

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条回答 默认 最新

  • dqwh1218 2018-01-09 23:56
    关注

    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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?