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

package chi

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

Package chi provides tracing functions for tracing the go-chi/chi package (https://github.com/go-chi/chi).

Code:

// Start the tracer
tracer.Start()
defer tracer.Stop()

// Create a chi Router
router := chi.NewRouter()

// Use the tracer middleware with the default service name "chi.router".
router.Use(chitrace.Middleware())

// Set up some endpoints.
router.Get("/", handler)

// And start gathering request traces
http.ListenAndServe(":8080", router)

Code:

// Start the tracer
tracer.Start()
defer tracer.Stop()

// Create a chi Router
router := chi.NewRouter()

// Use the tracer middleware with your desired service name.
router.Use(chitrace.Middleware(chitrace.WithServiceName("chi-server")))

// Set up some endpoints.
router.Get("/", handler)

// And start gathering request traces
http.ListenAndServe(":8080", router)

Index

Examples

Package Files

chi.go option.go

func Middleware Uses

func Middleware(opts ...Option) func(next http.Handler) http.Handler

Middleware returns middleware that will trace incoming requests.

type Option Uses

type Option func(*config)

Option represents an option that can be passed to NewRouter.

func WithAnalytics Uses

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) Option

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

func WithServiceName Uses

func WithServiceName(name string) Option

WithServiceName sets the given service name for the router.

func WithSpanOptions Uses

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

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

Package chi imports 11 packages (graph). Updated 2020-09-01. Refresh now. Tools for package owners.