Documentation ¶
Index ¶
- Constants
- Variables
- func ClientAddContextTags(ctx context.Context, tags opentracing.Tags) context.Context
- func GetTraceIDFromContext(ctx context.Context) string
- func GinTracing() gin.HandlerFunc
- func NewOutgoingContextWithTraceID(ctx context.Context, traceID string) context.Context
- func NewTraceContext(c *gin.Context) context.Context
- func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
- type FilterFunc
- type GormOpentracingPlugin
- type NiceMD
- type OpNameFunc
- type Option
- type Tags
- type UnaryRequestHandlerFunc
- type WrappedServerStream
Constants ¶
const ( TagTraceId = "trace.traceid" TagSpanId = "trace.spanid" TagSampled = "trace.sampled" )
Variables ¶
var (
// NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
NoopTags = &noopTags{}
)
Functions ¶
func ClientAddContextTags ¶
ClientAddContextTags returns a context with specified opentracing tags, which are used by UnaryClientInterceptor/StreamClientInterceptor when creating a new span.
func NewOutgoingContextWithTraceID ¶ added in v0.8.0
func NewTraceContext ¶ added in v0.7.0
NewTraceContext 生成新的请求链路追踪ctx
func StreamClientInterceptor ¶
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor returns a new streaming client interceptor for OpenTracing.
func StreamServerInterceptor ¶
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor for OpenTracing.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a new unary client interceptor for OpenTracing.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for OpenTracing.
Types ¶
type FilterFunc ¶
FilterFunc allows users to provide a function that filters out certain methods from being traced.
If it returns false, the given request will not be traced.
type GormOpentracingPlugin ¶ added in v0.7.0
type GormOpentracingPlugin struct{}
func (*GormOpentracingPlugin) Initialize ¶ added in v0.7.0
func (op *GormOpentracingPlugin) Initialize(db *gorm.DB) (err error)
func (*GormOpentracingPlugin) Name ¶ added in v0.7.0
func (op *GormOpentracingPlugin) Name() string
type NiceMD ¶
NiceMD is a convenience wrapper definiting extra functions on the metadata.
func ExtractIncoming ¶
ExtractIncoming extracts an inbound metadata from the server-side context.
This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns a new empty NiceMD.
func ExtractOutgoing ¶
ExtractOutgoing extracts an outbound metadata from the client-side context.
This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns a new empty NiceMD.
func (NiceMD) Clone ¶
Clone performs a *deep* copy of the metadata.MD.
You can specify the lower-case copiedKeys to only copy certain whitelisted keys. If no keys are explicitly whitelisted all keys get copied.
func (NiceMD) ToIncoming ¶
ToIncoming sets the given NiceMD as a server-side context for dispatching.
This is mostly useful in ServerInterceptors..
type OpNameFunc ¶
OpNameFunc is a func that allows custom operation names instead of the gRPC method.
type Option ¶
type Option func(*options)
func WithFilterFunc ¶
func WithFilterFunc(f FilterFunc) Option
WithFilterFunc customizes the function used for deciding whether a given call is traced or not.
func WithOpName ¶
func WithOpName(f OpNameFunc) Option
WithOpName customizes the trace Operation name
func WithTraceHeaderName ¶
WithTraceHeaderName customizes the trace header name where trace metadata passed with requests. Default one is `uber-trace-id`
func WithTracer ¶
func WithTracer(tracer opentracing.Tracer) Option
WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.
func WithUnaryRequestHandlerFunc ¶
func WithUnaryRequestHandlerFunc(f UnaryRequestHandlerFunc) Option
WithUnaryRequestHandlerFunc sets a custom handler for the request
type Tags ¶
type Tags interface { // Set sets the given key in the metadata tags. Set(key string, value interface{}) Tags // Has checks if the given key exists. Has(key string) bool // Values returns a map of key to values. // Do not modify the underlying map, please use Set instead. Values() map[string]interface{} }
Tags is the interface used for storing request tags between Context calls. The default implementation is *not* thread safe, and should be handled only in the context of the request.
type UnaryRequestHandlerFunc ¶
type UnaryRequestHandlerFunc func(span opentracing.Span, req interface{})
UnaryRequestHandlerFunc is a custom request handler
type WrappedServerStream ¶
type WrappedServerStream struct { grpc.ServerStream // WrappedContext is the wrapper's own Context. You can assign it. WrappedContext context.Context }
WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.
func (*WrappedServerStream) Context ¶
func (w *WrappedServerStream) Context() context.Context
Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()