Use ochttp for proxied requests
@@ -11,6 +11,7 @@ import (
"github.com/hellofresh/stats-go/client"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
+ "go.opencensus.io/plugin/ochttp"
)
const (
@@ -66,14 +67,14 @@ func (p *Register) Add(definition *RouterDefinition) error {
)
if p.matcher.Match(definition.ListenPath) {
- p.doRegister(p.matcher.Extract(definition.ListenPath), definition, handler.ServeHTTP)
+ p.doRegister(p.matcher.Extract(definition.ListenPath), definition, &ochttp.Handler{Handler: handler, IsPublicEndpoint: true})
}
- p.doRegister(definition.ListenPath, definition, handler.ServeHTTP)
+ p.doRegister(definition.ListenPath, definition, &ochttp.Handler{Handler: handler, IsPublicEndpoint: true})
return nil
}
-func (p *Register) doRegister(listenPath string, def *RouterDefinition, handler http.HandlerFunc) {
+func (p *Register) doRegister(listenPath string, def *RouterDefinition, handler http.Handler) {
log.WithFields(log.Fields{
"listen_path": listenPath,
}).Debug("Registering a route")
@@ -84,9 +85,9 @@ func (p *Register) doRegister(listenPath string, def *RouterDefinition, handler
} else {
for _, method := range def.Methods {
if strings.ToUpper(method) == methodAll {
- p.router.Any(listenPath, handler, def.middleware...)
+ p.router.Any(listenPath, handler.ServeHTTP, def.middleware...)
} else {
- p.router.Handle(strings.ToUpper(method), listenPath, handler, def.middleware...)
+ p.router.Handle(strings.ToUpper(method), listenPath, handler.ServeHTTP, def.middleware...)
}
}
}
