tracing

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyErrMsg = "err_msg"
)
View Source
const Name = "tracing"

Variables

This section is empty.

Functions

func CreateSpanFromFast

func CreateSpanFromFast(r *fasthttp.Request, name string) opentracing.Span

func Extract

func Extract(tracer opentracing.Tracer, header http.Header) (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 FromCtxWith

func FromCtxWith(name string, ctx context.Context, cb func(span *Span))

FromCtxWith retrieves the current span from the context.

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 Register

func Register(name string, r Factory) (err error)

func SetIfCtxErr

func SetIfCtxErr(span opentracing.Span, ctx context.Context)

SetIfCtxErr record context error

func SetIfErr

func SetIfErr(span opentracing.Span, err error)

SetIfErr add error info

Types

type Cfg

type Cfg struct {
	Driver string `json:"driver"`
}

func GetDefaultCfg

func GetDefaultCfg() Cfg

func (Cfg) Build

func (cfg Cfg) Build() (err error)

type Factory

type Factory func(cfg map[string]interface{}) error

func Get

func Get(names ...string) Factory

type HandlerFunc

type HandlerFunc func(next http.Handler) http.Handler

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

type RequestFunc func(req *http.Request) *http.Request

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

type Span struct {
	opentracing.Span
}

func CreateChild

func CreateChild(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span

func FromCtx

func FromCtx(ctx context.Context) *Span

FromCtx retrieves the current span from the context.

func NewSpan

func NewSpan(sp opentracing.Span) *Span

func StartSpan

func StartSpan(operationName string, opts ...opentracing.StartSpanOption) *Span

func (*Span) CreateChild

func (s *Span) CreateChild(name string, opts ...opentracing.StartSpanOption) *Span

func (*Span) CreateFollows

func (s *Span) CreateFollows(name string, opts ...opentracing.StartSpanOption) *Span

func (*Span) GetHttpHeader

func (s *Span) GetHttpHeader() http.Header

func (*Span) SetBaggageItem

func (s *Span) SetBaggageItem(restrictedKey, value string) opentracing.Span

func (*Span) SetOperationName

func (s *Span) SetOperationName(name string) opentracing.Span

func (*Span) SetTag

func (s *Span) SetTag(key string, value interface{}) opentracing.Span

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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