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 "github.com/signalfx/signalfx-go-tracing/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 "github.com/signalfx/signalfx-go-tracing/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 ¶
- func WrapClient(c *http.Client, opts ...RoundTripperOption) *http.Client
- func WrapHandler(h http.Handler, service, resource string, opts ...Option) http.Handler
- func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper
- type MuxOption
- type Option
- type RoundTripperAfterFunc
- type RoundTripperBeforeFunc
- type RoundTripperOption
- type ServeMux
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapClient ¶
func WrapClient(c *http.Client, opts ...RoundTripperOption) *http.Client
WrapClient modifies the given client's transport to augment it with tracing and returns it.
func WrapHandler ¶
WrapHandler wraps an http.Handler with tracing using the given service and resource.
func WrapRoundTripper ¶
func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper
WrapRoundTripper returns a new RoundTripper which traces all requests sent over the transport.
Types ¶
type MuxOption ¶
type MuxOption func(*config)
MuxOption has been deprecated in favor of Option.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithServiceName ¶
WithServiceName sets the given service name for the returned ServeMux.
type Option ¶
type Option = MuxOption
Option represents an option that can be passed to NewServeMux or WrapHandler.
func WithSpanOptions ¶
func WithSpanOptions(opts ...ddtrace.StartSpanOption) Option
WithSpanOptions defines a set of additional ddtrace.StartSpanOption to be added to spans started by the integration.
type RoundTripperAfterFunc ¶
A RoundTripperAfterFunc can be used to modify a span after an http RoundTrip is made. It is possible for the http Response to be nil.
type RoundTripperBeforeFunc ¶
A RoundTripperBeforeFunc can be used to modify a span before an http RoundTrip is made.
type RoundTripperOption ¶
type RoundTripperOption func(*roundTripperConfig)
A RoundTripperOption represents an option that can be passed to WrapRoundTripper.
func RTWithAnalytics ¶
func RTWithAnalytics(on bool) RoundTripperOption
RTWithAnalytics enables Trace Analytics for all started spans.
func RTWithAnalyticsRate ¶
func RTWithAnalyticsRate(rate float64) RoundTripperOption
RTWithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithAfter ¶
func WithAfter(f RoundTripperAfterFunc) RoundTripperOption
WithAfter adds a RoundTripperAfterFunc to the RoundTripper config.
func WithBefore ¶
func WithBefore(f RoundTripperBeforeFunc) RoundTripperOption
WithBefore adds a RoundTripperBeforeFunc to the RoundTripper config.
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