opentracefasthttp

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

Build Status

opentracefasthttp

Opentracing carrier for fasthttp server. Gives possibility to use span extract/inject options

examples

client send with request's header

	req := fasthttp.AcquireRequest()
	...
	
	carrier := opentracefasthttp.New(&req.Header)
	err = opentracing.GlobalTracer().Inject(span.Context(), opentracing.HTTPHeaders, carrier)

server read from request's header

	func(ctx *fasthttp.RequestCtx) {
		carrier := opentracefasthttp.New(&ctx.Request.Header)
		clientContext, err := tr.Extract(opentracing.HTTPHeaders, carrier)
		if err != nil{
			...
		}
		span := trace.StartSpan("HTTP "+string(ctx.Method())+" "+ctx.Request.URI().String(), ext.RPCServerOption(clientContext))
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

func ContextWithSpan(ctx *fasthttp.RequestCtx, span opentracing.Span) *fasthttp.RequestCtx

ContextWithSpan returns a new `*fasthttp.RequestCtx` that holds a reference to the span. If span is nil, a new context without an active span is returned.

func SpanFromContext

func SpanFromContext(ctx *fasthttp.RequestCtx) opentracing.Span

SpanFromContext returns the `opentracing.Span` previously associated with `ctx`, or `nil` if no such `opentracing.Span` could be found.

Types

type Carrier

type Carrier struct {
	// contains filtered or unexported fields
}

Carrier satisfies both TextMapWriter and TextMapReader.

Example usage for server side:

carrier := opentracefasthttp.New(&ctx.Request.Header)
clientContext, err := tracer.Extract(opentracing.HTTPHeaders, carrier)

Example usage for client side:

carrier := opentracefasthttp.New(&req.Header)
err := tracer.Inject(
    span.Context(),
    opentracing.HTTPHeaders,
    carrier)

func New

func (Carrier) ForeachKey

func (c Carrier) ForeachKey(handler func(key, val string) error) (err error)

ForeachKey conforms to the TextMapReader interface.

func (Carrier) Set

func (c Carrier) Set(key, val string)

Set conforms to the TextMapWriter interface.

Jump to

Keyboard shortcuts

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