mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-23 21:44:41 +02:00
strip wrappers for trace/stats
This commit is contained in:
27
service.go
27
service.go
@@ -9,15 +9,12 @@ import (
|
|||||||
|
|
||||||
"go-micro.dev/v4/client"
|
"go-micro.dev/v4/client"
|
||||||
"go-micro.dev/v4/debug/handler"
|
"go-micro.dev/v4/debug/handler"
|
||||||
"go-micro.dev/v4/debug/stats"
|
|
||||||
"go-micro.dev/v4/debug/trace"
|
|
||||||
"go-micro.dev/v4/logger"
|
"go-micro.dev/v4/logger"
|
||||||
plugin "go-micro.dev/v4/plugins"
|
plugin "go-micro.dev/v4/plugins"
|
||||||
"go-micro.dev/v4/server"
|
"go-micro.dev/v4/server"
|
||||||
"go-micro.dev/v4/store"
|
"go-micro.dev/v4/store"
|
||||||
"go-micro.dev/v4/util/cmd"
|
"go-micro.dev/v4/util/cmd"
|
||||||
signalutil "go-micro.dev/v4/util/signal"
|
signalutil "go-micro.dev/v4/util/signal"
|
||||||
"go-micro.dev/v4/util/wrapper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
@@ -27,29 +24,9 @@ type service struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newService(opts ...Option) Service {
|
func newService(opts ...Option) Service {
|
||||||
service := new(service)
|
return &service{
|
||||||
options := newOptions(opts...)
|
opts: newOptions(opts...),
|
||||||
|
|
||||||
// service name
|
|
||||||
serviceName := options.Server.Options().Name
|
|
||||||
|
|
||||||
// wrap client to inject From-Service header on any calls
|
|
||||||
options.Client = wrapper.FromService(serviceName, options.Client)
|
|
||||||
options.Client = wrapper.TraceCall(serviceName, trace.DefaultTracer, options.Client)
|
|
||||||
|
|
||||||
// wrap the server to provide handler stats
|
|
||||||
err := options.Server.Init(
|
|
||||||
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
|
||||||
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set opts
|
|
||||||
service.opts = options
|
|
||||||
|
|
||||||
return service
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Name() string {
|
func (s *service) Name() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user