代码拉取完成,页面将自动刷新
// Package datadog provides wrappers for Datadog ddtrace
package datadog
import (
"gitee.com/sasukebo/go-micro/v4/registry"
"context"
"gitee.com/sasukebo/go-micro/v4/client"
"gitee.com/sasukebo/go-micro/v4/server"
)
var noDebugStack = true
// SetNoDebugStack ...
func SetNoDebugStack(val bool) {
noDebugStack = val
}
type ddWrapper struct {
client.Client
}
func (d *ddWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) (err error) {
t := newRequestTracker(req, ClientProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err, noDebugStack)
}()
err = d.Client.Call(ctx, req, rsp, opts...)
return
}
func (d *ddWrapper) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) (err error) {
t := newEventTracker(p, ClientProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err, noDebugStack)
}()
err = d.Client.Publish(ctx, p, opts...)
return
}
// NewClientWrapper returns a Client wrapped in tracer
func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &ddWrapper{c}
}
}
// NewCallWrapper returns a Call Wrapper
func NewCallWrapper() client.CallWrapper {
return func(cf client.CallFunc) client.CallFunc {
return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
t := newRequestTracker(req, ClientProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(nil, noDebugStack)
}()
return cf(ctx, node, req, rsp, opts)
}
}
}
// NewHandlerWrapper returns a Handler Wrapper
func NewHandlerWrapper() server.HandlerWrapper {
return func(h server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
if req.Endpoint() != "Debug.Health" {
t := newRequestTracker(req, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err, noDebugStack)
}()
}
err = h(ctx, req, rsp)
return
}
}
}
// NewSubscriberWrapper returns a Subscriber Wrapper
func NewSubscriberWrapper() server.SubscriberWrapper {
return func(next server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, msg server.Message) (err error) {
t := newEventTracker(msg, ServerProfile)
ctx = t.StartSpanFromContext(ctx)
defer func() {
t.finishWithError(err, noDebugStack)
}()
err = next(ctx, msg)
return
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。