Documentation ¶
Index ¶
- Constants
- func CreateSpan(r *http.Request, name string) opentracing.Span
- func Extract(tracer opentracing.Tracer, r *http.Request) (opentracing.SpanContext, error)
- func Global() opentracing.Tracer
- func InjectHeaders(span opentracing.Span, request *http.Request) error
- func NewClientTrace(span opentracing.Span) *httptrace.ClientTrace
- func Register(name string, r Factory) (err error)
- func SetIfContextError(span opentracing.Span, ctx context.Context)
- func SetIfError(span opentracing.Span, err error)
- type Cfg
- type Factory
- type HandlerFunc
- type RequestFunc
- type Span
- func NewSpan(ctx context.Context, sp opentracing.Span) *Span
- func NewSpanByHttpHeader(header *http.Header, name string) *Span
- func NewSpanByTraceId(traceId string, name string) *Span
- func RootSpan(name string, opts ...opentracing.StartSpanOption) *Span
- func StartSpan(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) Context() context.Context
- func (s *Span) CreateChild(name string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) CreateFollows(name string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) Finish()
- func (s *Span) GetHttpHeader() http.Header
- func (s *Span) GetTraceId() string
- func (s *Span) LogKV(alternatingKeyValues ...interface{})
- func (s *Span) SetBaggageItem(restrictedKey, value string) *Span
- func (s *Span) SetOperationName(name string) *Span
- func (s *Span) SetTag(key string, value interface{}) *Span
- func (s *Span) SpanContext() opentracing.SpanContext
- func (s *Span) Sub(name string) *Span
Constants ¶
const KeyContextErrorMessage = "context_error_msg"
const KeyErrorMessage = "error_msg"
error keys
const Name = "tracer"
const TraceId = "trace-id"
Variables ¶
This section is empty.
Functions ¶
func CreateSpan ¶
func CreateSpan(r *http.Request, name string) opentracing.Span
func Extract ¶
func Extract(tracer opentracing.Tracer, r *http.Request) (opentracing.SpanContext, error)
Extract extracts the inbound HTTP request to obtain the parent span's context to ensure correct propagation of span context throughout the trace.
func Global ¶
func Global() opentracing.Tracer
func InjectHeaders ¶
func InjectHeaders(span opentracing.Span, request *http.Request) error
InjectHeaders injects the outbound HTTP request with the given span's context to ensure correct propagation of span context throughout the trace.
func NewClientTrace ¶
func NewClientTrace(span opentracing.Span) *httptrace.ClientTrace
NewClientTrace Creates a New ClientTrace
func SetIfContextError ¶
func SetIfContextError(span opentracing.Span, ctx context.Context)
SetIfContextError record error
func SetIfError ¶
func SetIfError(span opentracing.Span, err error)
SetIfError add error info and flag for error
Types ¶
type Cfg ¶
type Cfg struct {
Driver string `json:"driver"`
}
func GetDefaultCfg ¶
func GetDefaultCfg() Cfg
type HandlerFunc ¶
HandlerFunc is a middleware function for incoming HTTP requests.
func FromHTTPRequest ¶
func FromHTTPRequest(tracer opentracing.Tracer, operationName string) HandlerFunc
FromHTTPRequest returns a Middleware HandlerFunc that tries to join with an OpenTracing trace found in the HTTP request headers and starts a new Span called `operationName`. If no trace could be found in the HTTP request headers, the Span will be a trace root. The Span is incorporated in the HTTP Context object and can be retrieved with opentracing.SpanFromContext(ctx).
type RequestFunc ¶
RequestFunc is a middleware function for outgoing HTTP requests.
func ToHTTPRequest ¶
func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc
ToHTTPRequest returns a RequestFunc that injects an OpenTracing Span found in context into the HTTP Headers. If no such Span can be found, the RequestFunc is a noop.
type Span ¶
func NewSpanByTraceId ¶
func (*Span) CreateChild ¶
func (*Span) CreateFollows ¶
func (*Span) GetHttpHeader ¶
func (*Span) GetTraceId ¶
func (*Span) SetBaggageItem ¶
func (*Span) SetOperationName ¶
func (*Span) SpanContext ¶
func (s *Span) SpanContext() opentracing.SpanContext