httptrace

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package httptrace contains OpenCensus tracing integrations with net/http.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(base http.Handler, format ...propagation.HTTPFormat) http.Handler

NewHandler returns a http.Handler from the given handler that is aware of the incoming request's span. The span can be extracted from the incoming request in handler functions from incoming request's context:

span := trace.FromContext(r.Context())

The span will be automatically ended by the handler.

Incoming propagation mechanism is determined by the given HTTP propagators.

Types

type Transport

type Transport struct {
	// Base represents the underlying roundtripper that does the actual requests.
	// If none is given, http.DefaultTransport is used.
	//
	// If base HTTP roundtripper implements CancelRequest,
	// the returned round tripper will be cancelable.
	Base http.RoundTripper

	// Formats are the mechanisms that propagate
	// the outgoing trace in an HTTP request.
	Formats []propagation.HTTPFormat
}

Transport is an http.RoundTripper that traces the outgoing requests.

Use NewTransport to create new transports.

func NewTransport

func NewTransport(format ...propagation.HTTPFormat) *Transport

NewTransport returns an http.RoundTripper that traces the outgoing requests.

Traces are propagated via the provided HTTP propagation mechanisms.

func (*Transport) CancelRequest

func (t *Transport) CancelRequest(req *http.Request)

CancelRequest cancels an in-flight request by closing its connection.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip creates a trace.Span and inserts it into the outgoing request's headers. The created span can follow a parent span, if a parent is presented in the request's context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL