Documentation ¶
Overview ¶
Package http provides functions to trace the net/http package (https://golang.org/pkg/net/http).
Example ¶
package main import ( "net/http" httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" ) func main() { mux := httptrace.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World!\n")) }) http.ListenAndServe(":8080", mux) }
Output:
Example (WithServiceName) ¶
package main import ( "net/http" httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" ) func main() { mux := httptrace.NewServeMux(httptrace.WithServiceName("my-service")) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World!\n")) }) http.ListenAndServe(":8080", mux) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MuxOption ¶ added in v1.0.0
type MuxOption func(*muxConfig)
MuxOption represents an option that can be passed to NewServeMux.
func WithServiceName ¶ added in v1.0.0
WithServiceName sets the given service name for the returned ServeMux.
type ServeMux ¶
ServeMux is an HTTP request multiplexer that traces all the incoming requests.
func NewServeMux ¶
NewServeMux allocates and returns an http.ServeMux augmented with the global tracer.
func (*ServeMux) ServeHTTP ¶
func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP dispatches the request to the handler whose pattern most closely matches the request URL. We only need to rewrite this function to be able to trace all the incoming requests to the underlying multiplexer
Click to show internal directories.
Click to hide internal directories.