add trace handler

This commit is contained in:
Asim Aslam 2020-01-24 22:02:35 +00:00
parent 4a6570a772
commit 1d00f2f771

View File

@ -15,6 +15,7 @@ import (
"github.com/micro/go-micro/debug/profile/pprof"
"github.com/micro/go-micro/debug/service/handler"
"github.com/micro/go-micro/debug/stats"
"github.com/micro/go-micro/debug/trace"
"github.com/micro/go-micro/plugin"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/util/log"
@ -36,8 +37,15 @@ func newService(opts ...Option) Service {
// wrap client to inject From-Service header on any calls
options.Client = wrapper.FromService(serviceName, options.Client)
// wrap client to inject From-Service header on any calls
options.Client = wrapper.TraceCall(serviceName, trace.DefaultTrace, options.Client)
// wrap the server to provide handler stats
options.Server.Init(server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)))
options.Server.Init(
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTrace)),
)
return &service{
opts: options,