Documentation ¶
Overview ¶
This package is a reduced version of the go trace implementations
Index ¶
- func HexToSpanID(hexString string) (spanID, error)
- func HexToTraceID(hexString string) (traceID, error)
- func InjectHeaders(ctx context.Context, req *http.Request) *http.Request
- func InjectInCtx(ctx context.Context, trace *TracerContext) context.Context
- func InjectInRequest(r *http.Request, trace *TracerContext) *http.Request
- func TraceMiddleware() func(next http.Handler) http.Handler
- type Propagator
- type TraceField
- type TracerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HexToSpanID ¶
HexToSpanID convert string to spanID.
func HexToTraceID ¶
HexToTraceID convert string to traceID.
func InjectHeaders ¶
InjectHeaders injects the trace information in the request headers. The intention is that it will be used in API clients for internal calls.
func InjectInCtx ¶
func InjectInCtx(ctx context.Context, trace *TracerContext) context.Context
InjectInCtx injects the trace information in the context.
func InjectInRequest ¶
func InjectInRequest(r *http.Request, trace *TracerContext) *http.Request
InjectInRequest the trace information in the request context.
Types ¶
type Propagator ¶
type Propagator interface { // Inject the trace context in the http.Request context and the http.ResponseWriter Propagate(r *http.Request, w http.ResponseWriter) (*http.Request, http.ResponseWriter) // Return a sanitized version of the TracerContext Sanitize() TraceField // contains filtered or unexported methods }
Propagator implements the logic to be propagated in the request.
func ExtractFromCtx ¶
func ExtractFromCtx(ctx context.Context) Propagator
ExtractFromCtx extracts the trace information from the context. In case the middleware is not loaded the the function returns an empty propagator.
func ExtractFromRequest ¶
func ExtractFromRequest(r *http.Request) Propagator
ExtractFromRequest extracts the trace information from the request headers.
type TraceField ¶
TraceField is the sanitized version of the TracerContext in case that the TracerContext will be returned as data structure.
type TracerContext ¶
type TracerContext struct { http.ResponseWriter Span spanID Trace traceID Flag traceFlag // contains filtered or unexported fields }
TracerContext store the trace context to be propagated. This wraps the http.ResponseWriter, injecting the trace headers in the various end point responses.
func NewTracerContext ¶
func NewTracerContext() *TracerContext
NewTracerContext creates a new TracerContext.
func (*TracerContext) IsValid ¶
func (tc *TracerContext) IsValid() bool
IsValid returns true if the Trace and Span are valid.
func (*TracerContext) Propagate ¶
func (tc *TracerContext) Propagate(r *http.Request, w http.ResponseWriter) (*http.Request, http.ResponseWriter)
Propagate injects the TracerContext into http.Request and http.ResponseWriter.
func (*TracerContext) Sanitize ¶
func (tc *TracerContext) Sanitize() TraceField
func (*TracerContext) String ¶
func (tc *TracerContext) String() string
func (*TracerContext) WriteHeader ¶
func (tc *TracerContext) WriteHeader(statusCode int)