dd-trace-go.v1: gopkg.in/DataDog/dd-trace-go.v1/contrib/julienschmidt/httprouter Index | Examples | Files

package httprouter

import "gopkg.in/DataDog/dd-trace-go.v1/contrib/julienschmidt/httprouter"

Package httprouter provides functions to trace the julienschmidt/httprouter package (https://github.com/julienschmidt/httprouter).

Code:

router := httptrace.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)

log.Fatal(http.ListenAndServe(":8080", router))

Code:

router := httptrace.New(httptrace.WithServiceName("http.router"))
router.GET("/", Index)
router.GET("/hello/:name", Hello)

log.Fatal(http.ListenAndServe(":8080", router))

Code:

router := httptrace.New(
    httptrace.WithServiceName("http.router"),
    httptrace.WithSpanOptions(
        tracer.Tag(ext.SamplingPriority, ext.PriorityUserKeep),
    ),
)

router.GET("/", Index)
router.GET("/hello/:name", Hello)

log.Fatal(http.ListenAndServe(":8080", router))

Index

Examples

Package Files

httprouter.go option.go

type Router Uses

type Router struct {
    *httprouter.Router
    // contains filtered or unexported fields
}

Router is a traced version of httprouter.Router.

func New Uses

func New(opts ...RouterOption) *Router

New returns a new router augmented with tracing.

func (*Router) ServeHTTP Uses

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type RouterOption Uses

type RouterOption func(*routerConfig)

RouterOption represents an option that can be passed to New.

func WithAnalytics Uses

func WithAnalytics(on bool) RouterOption

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) RouterOption

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName Uses

func WithServiceName(name string) RouterOption

WithServiceName sets the given service name for the returned router.

func WithSpanOptions Uses

func WithSpanOptions(opts ...ddtrace.StartSpanOption) RouterOption

WithSpanOptions applies the given set of options to the span started by the router.

Package httprouter imports 10 packages (graph) and is imported by 1 packages. Updated 2020-08-08. Refresh now. Tools for package owners.