dtracing

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagTraceId = "trace.traceid"
	TagSpanId  = "trace.spanid"
	TagSampled = "trace.sampled"
)

Variables

View Source
var (

	// NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
	NoopTags = &noopTags{}
)

Functions

func ClientAddContextTags

func ClientAddContextTags(ctx context.Context, tags opentracing.Tags) context.Context

ClientAddContextTags returns a context with specified opentracing tags, which are used by UnaryClientInterceptor/StreamClientInterceptor when creating a new span.

func GetTraceIDFromContext

func GetTraceIDFromContext(ctx context.Context) string

func GinTracing added in v0.7.0

func GinTracing() gin.HandlerFunc

GinTracing gin链路追踪中间件

func NewOutgoingContextWithTraceID added in v0.8.0

func NewOutgoingContextWithTraceID(ctx context.Context, traceID string) context.Context

func NewTraceContext added in v0.7.0

func NewTraceContext(c *gin.Context) context.Context

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

type FilterFunc func(ctx context.Context, fullMethodName string) bool

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

type NiceMD metadata.MD

NiceMD is a convenience wrapper definiting extra functions on the metadata.

func ExtractIncoming

func ExtractIncoming(ctx context.Context) NiceMD

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

func ExtractOutgoing(ctx context.Context) NiceMD

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

func (m NiceMD) Clone(copiedKeys ...string) NiceMD

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

func (m NiceMD) ToIncoming(ctx context.Context) context.Context

ToIncoming sets the given NiceMD as a server-side context for dispatching.

This is mostly useful in ServerInterceptors..

func (NiceMD) ToOutgoing

func (m NiceMD) ToOutgoing(ctx context.Context) context.Context

ToOutgoing sets the given NiceMD as a client-side context for dispatching.

type OpNameFunc

type OpNameFunc func(method string) string

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

func WithTraceHeaderName(name string) Option

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.

func Extract

func Extract(ctx context.Context) Tags

Extracts returns a pre-existing Tags object in the Context. If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL