Hi, Im trying to enclose echo's handle function to add tracing support from OpenCensus:
var e = echo.New()
// Wrap the Echo handler in an OpenCensus handler.
var ocHandler = &ochttp.Handler{Handler: e, IsPublicEndpoint: true}
e.Server.Handler = ocHandler
But later when starting echo server by: e.Start(), echo again points e.Server.Handler to it self. Why do it need to do it twice?
https://github.com/labstack/echo/blob/d36ff729613dd8e825455c504bea0586c43ac03d/echo.go#L647
https://github.com/census-instrumentation/opencensus-go
Made a PR to solve it: https://github.com/labstack/echo/pull/1149
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@niklas-karlsson how did you get by with this issue? I'm trying to fit in echo with opencensus tracing as well.
For people who find this thread via Google, here's what I did to integrate OpenCensus with Echo.
func NewCensus() echo.MiddlewareFunc {
return echo.WrapMiddleware(func(h http.Handler) http.Handler {
return &ochttp.Handler{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if span := trace.FromContext(r.Context()); span != nil {
// Do stuff
}
h.ServeHTTP(w, r)
}),
}
})
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi guys! I created a middleware for it
https://github.com/faabiosr/echo-middleware
Most helpful comment
For people who find this thread via Google, here's what I did to integrate OpenCensus with Echo.