Documentation
¶
Index ¶
- Variables
- func DefaultURI(r *http.Request) string
- func NewClient(ca []byte, opts ...Option) *http.Client
- func UpdateClient(c *http.Client, opts ...Option) *http.Client
- type Checker
- type Middleware
- type Option
- func WithDumpPayloadOnError(enable bool) Option
- func WithDumpRequest(enable bool) Option
- func WithDumpResponse(enable bool) Option
- func WithFilter(f ...otelhttp.Filter) Option
- func WithHeaders(enable bool) Option
- func WithOperation(name string) Option
- func WithOtelOpts(opts ...otelhttp.Option) Option
- func WithPathExtractor(in PathExtractor) Option
- func WithTel(t *tel.Telemetry) Option
- type PathExtractor
- type TracedServeMux
Constants ¶
This section is empty.
Variables ¶
var ( DefaultSpanNameFormatter = func(_ string, r *http.Request) string { var b strings.Builder b.WriteString(r.Method) b.WriteString(":") b.WriteString(decreasePathCardinality(r.URL.Path)) return b.String() } DefaultFilter = func(r *http.Request) bool { if k, ok := r.Header["Upgrade"]; ok { for _, v := range k { if v == "websocket" { return false } } } return !(r.Method == http.MethodGet && strings.HasPrefix(r.URL.RequestURI(), "/health")) } )
Functions ¶
func DefaultURI ¶
Types ¶
type Checker ¶ added in v1.2.0
func NewChecker ¶ added in v1.2.0
func NewDomainWithTimeout ¶ added in v1.2.0
type Middleware ¶
func ServerMiddleware ¶
func ServerMiddleware(opts ...Option) Middleware
ServerMiddleware perform: * telemetry log injection * measure execution time * recovery
func ServerMiddlewareAll ¶
func ServerMiddlewareAll(opts ...Option) Middleware
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
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option interface used for setting optional config properties.
func WithDumpPayloadOnError ¶ added in v1.2.2
WithDumpPayloadOnError write dump request and response on faults
Default: true
func WithDumpRequest ¶ added in v1.2.0
WithDumpRequest dump request as plain text to log and trace i guess we can go further and perform option with encoding requests
func WithDumpResponse ¶ added in v1.2.0
WithDumpResponse dump response as plain text to log and trace
func WithHeaders ¶ added in v1.2.0
WithHeaders explicitly set possibility to write http headers
func WithOperation ¶
func WithOtelOpts ¶
func WithPathExtractor ¶
func WithPathExtractor(in PathExtractor) Option
type PathExtractor ¶
type TracedServeMux ¶
type TracedServeMux struct {
// contains filtered or unexported fields
}
TracedServeMux is a wrapper around http.ServeMux that instruments handlers for tracing.
func NewServeMux ¶
func NewServeMux(opts ...Option) *TracedServeMux
NewServeMux creates a new TracedServeMux.
func (*TracedServeMux) Handle ¶
func (tm *TracedServeMux) Handle(pattern string, handler http.Handler)
Handle implements http.ServeMux#Handle
func (*TracedServeMux) ServeHTTP ¶
func (tm *TracedServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.ServeMux#ServeHTTP