Documentation ¶
Overview ¶
Package fasthttp provides functions to trace the valyala/fasthttp package (https://github.com/valyala/fasthttp)
Example ¶
package main import ( "fmt" fasthttptrace "github.com/DataDog/dd-trace-go/v2/contrib/valyala/fasthttp.v1" "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" "github.com/valyala/fasthttp" ) func fastHTTPHandler(ctx *fasthttp.RequestCtx) { fmt.Fprintf(ctx, "Hello World!") } func main() { // Start the tracer tracer.Start() defer tracer.Stop() // Start fasthttp server fasthttp.ListenAndServe(":8081", fasthttptrace.WrapHandler(fastHTTPHandler)) }
Output:
Example (WithServiceName) ¶
package main import ( "fmt" fasthttptrace "github.com/DataDog/dd-trace-go/v2/contrib/valyala/fasthttp.v1" "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" "github.com/valyala/fasthttp" ) func fastHTTPHandler(ctx *fasthttp.RequestCtx) { fmt.Fprintf(ctx, "Hello World!") } func main() { // Start the tracer tracer.Start() defer tracer.Stop() // Start fasthttp server fasthttp.ListenAndServe(":8081", fasthttptrace.WrapHandler(fastHTTPHandler, fasthttptrace.WithService("fasthttp-server"))) }
Output:
Index ¶
- func WrapHandler(h fasthttp.RequestHandler, opts ...Option) fasthttp.RequestHandler
- type Option
- type OptionFn
- func WithIgnoreRequest(f func(fctx *fasthttp.RequestCtx) bool) OptionFn
- func WithResourceNamer(fn func(fctx *fasthttp.RequestCtx) string) OptionFn
- func WithService(name string) OptionFn
- func WithSpanOptions(opts ...tracer.StartSpanOption) OptionFn
- func WithStatusCheck(fn func(statusCode int) bool) OptionFn
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapHandler ¶
func WrapHandler(h fasthttp.RequestHandler, opts ...Option) fasthttp.RequestHandler
WrapHandler wraps a fasthttp.RequestHandler with tracing middleware
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option describes options for the FastHTTP integration.
type OptionFn ¶
type OptionFn func(*config)
OptionFn represents options applicable to WrapHandler.
func WithIgnoreRequest ¶
func WithIgnoreRequest(f func(fctx *fasthttp.RequestCtx) bool) OptionFn
WithIgnoreRequest specifies a function to use for determining if the incoming HTTP request tracing should be skipped.
func WithResourceNamer ¶
func WithResourceNamer(fn func(fctx *fasthttp.RequestCtx) string) OptionFn
WithResourceNamer specifies a function which will be used to obtain the resource name for a given request
func WithService ¶
WithService sets the given service name for the router.
func WithSpanOptions ¶
func WithSpanOptions(opts ...tracer.StartSpanOption) OptionFn
WithSpanOptions applies the given set of options to the spans started by the router.
func WithStatusCheck ¶
WithStatusCheck allows customization over which status code(s) to consider "error"