Refactor debug/trace ready for Jaeger

This commit is contained in:
Micro
2020-01-29 15:45:11 +00:00
parent 1108cc5e91
commit 62c067adcd
10 changed files with 130 additions and 36 deletions

View File

@@ -15,7 +15,6 @@ 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,17 +35,14 @@ 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)
options.Client = wrapper.TraceCall(serviceName, options.Server.Options().Tracer, options.Client)
// wrap the server to provide handler stats
options.Server.Init(
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTrace)),
server.WrapHandler(wrapper.TraceHandler(options.Server.Options().Tracer)),
)
return &service{
opts: options,
}