Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions middleware/http_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
)

// Tracer is a middleware which traces incoming requests.
type Tracer struct{}
type Tracer struct {

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Options []nethttp.MWOption
}

// Wrap implements Interface
func (t Tracer) Wrap(next http.Handler) http.Handler {
traceHandler := nethttp.Middleware(opentracing.GlobalTracer(), next)
traceHandler := nethttp.Middleware(opentracing.GlobalTracer(), next, t.Options...)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var maybeTracer http.Handler
// Don't try and trace websocket requests because nethttp.Middleware
Expand Down
7 changes: 6 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
_ "net/http/pprof" // anonymous import to get the pprof handler registered
"time"

"github.com/opentracing-contrib/go-stdlib/nethttp"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
"github.com/mwitkow/go-grpc-middleware"
Expand Down Expand Up @@ -42,6 +44,7 @@ type Config struct {
GRPCMiddleware []grpc.UnaryServerInterceptor
GRPCStreamMiddleware []grpc.StreamServerInterceptor
HTTPMiddleware []middleware.Interface
OpentracingOptions []nethttp.MWOption

This comment was marked as abuse.


LogLevel logging.Level
Log logging.Interface
Expand Down Expand Up @@ -139,7 +142,9 @@ func New(cfg Config) (*Server, error) {
RegisterInstrumentation(router)
}
httpMiddleware := []middleware.Interface{
middleware.Tracer{},
middleware.Tracer{
Options: cfg.OpentracingOptions,

This comment was marked as abuse.

This comment was marked as abuse.

},
middleware.Log{
Log: log,
},
Expand Down