http

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSpanNameFormatter = func(_ string, r *http.Request) string {
		return fmt.Sprintf("%s: %s", r.Method, r.URL.Path)
	}
	DefaultFilter = func(r *http.Request) bool {
		return !(r.Method == http.MethodGet && strings.HasPrefix(r.URL.RequestURI(), "/health"))
	}
)

Functions

func DefaultURI added in v2.0.7

func DefaultURI(r *http.Request) string

func NewClient added in v2.0.4

func NewClient(ca []byte) *http.Client

NewClient with CA injection

func ServerMiddleware added in v2.0.4

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

ServerMiddleware perform: * telemetry log injection * measure execution time * recovery

func ServerMiddlewareAll added in v2.0.4

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

ServerMiddlewareAll represent all essential metrics Execution order:

  • opentracing injection via nethttp.Middleware
  • recovery + measure execution time + debug log via own ServerMiddleware
  • metrics via metrics.NewHTTPMiddlewareWithOption

func UpdateClient added in v2.0.4

func UpdateClient(c *http.Client, opts ...Option) *http.Client

UpdateClient inject tracer

Types

type Option added in v2.0.4

type Option interface {
	// contains filtered or unexported methods
}

Option interface used for setting optional config properties.

func WithOperation added in v2.0.4

func WithOperation(name string) Option

func WithOtelOpts added in v2.0.4

func WithOtelOpts(opts ...otelhttp.Option) Option

func WithPathExtractor added in v2.0.7

func WithPathExtractor(in PathExtractor) Option

func WithTel added in v2.0.4

func WithTel(t *tel.Telemetry) Option

WithTel also add options to pass own metric and trace provider

type PathExtractor added in v2.0.7

type PathExtractor func(r *http.Request) string

type TracedServeMux added in v2.0.7

type TracedServeMux struct {
	// contains filtered or unexported fields
}

TracedServeMux is a wrapper around http.ServeMux that instruments handlers for tracing.

func NewServeMux added in v2.0.7

func NewServeMux(opts ...Option) *TracedServeMux

NewServeMux creates a new TracedServeMux.

func (*TracedServeMux) Handle added in v2.0.7

func (tm *TracedServeMux) Handle(pattern string, handler http.Handler)

Handle implements http.ServeMux#Handle

func (*TracedServeMux) ServeHTTP added in v2.0.7

func (tm *TracedServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.ServeMux#ServeHTTP

Jump to

Keyboard shortcuts

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