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

package http

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

Package http provides functions to trace the net/http package (https://golang.org/pkg/net/http).

Code:

mux := httptrace.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Hello World!\n"))
})
http.ListenAndServe(":8080", mux)

Code:

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)

Index

Examples

Package Files

http.go option.go roundtripper.go

func WrapClient Uses

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 Uses

func WrapHandler(h http.Handler, service, resource string, opts ...Option) http.Handler

WrapHandler wraps an http.Handler with tracing using the given service and resource.

func WrapRoundTripper Uses

func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper

WrapRoundTripper returns a new RoundTripper which traces all requests sent over the transport.

type MuxOption Uses

type MuxOption = Option

MuxOption has been deprecated in favor of Option.

func WithAnalytics Uses

func WithAnalytics(on bool) MuxOption

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) MuxOption

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

func WithServiceName Uses

func WithServiceName(name string) MuxOption

WithServiceName sets the given service name for the returned ServeMux.

type Option Uses

type Option func(*config)

Option represents an option that can be passed to NewServeMux or WrapHandler.

func WithSpanOptions Uses

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 Uses

type RoundTripperAfterFunc func(*http.Response, ddtrace.Span)

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 Uses

type RoundTripperBeforeFunc func(*http.Request, ddtrace.Span)

A RoundTripperBeforeFunc can be used to modify a span before an http RoundTrip is made.

type RoundTripperOption Uses

type RoundTripperOption func(*roundTripperConfig)

A RoundTripperOption represents an option that can be passed to WrapRoundTripper.

func RTWithAnalytics Uses

func RTWithAnalytics(on bool) RoundTripperOption

RTWithAnalytics enables Trace Analytics for all started spans.

func RTWithAnalyticsRate Uses

func RTWithAnalyticsRate(rate float64) RoundTripperOption

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

func RTWithServiceName Uses

func RTWithServiceName(name string) RoundTripperOption

RTWithServiceName sets the given service name for the RoundTripper.

func WithAfter Uses

func WithAfter(f RoundTripperAfterFunc) RoundTripperOption

WithAfter adds a RoundTripperAfterFunc to the RoundTripper config.

func WithBefore Uses

func WithBefore(f RoundTripperBeforeFunc) RoundTripperOption

WithBefore adds a RoundTripperBeforeFunc to the RoundTripper config.

type ServeMux Uses

type ServeMux struct {
    *http.ServeMux
    // contains filtered or unexported fields
}

ServeMux is an HTTP request multiplexer that traces all the incoming requests.

func NewServeMux Uses

func NewServeMux(opts ...Option) *ServeMux

NewServeMux allocates and returns an http.ServeMux augmented with the global tracer.

func (*ServeMux) ServeHTTP Uses

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

Package http imports 10 packages (graph) and is imported by 3 packages. Updated 2020-02-13. Refresh now. Tools for package owners.