http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: ISC Imports: 14 Imported by: 0

README

Go Doc

HTTP Telemetry

This package can be used for building observable HTTP servers and clients. It provides middleware for wrapping http handlers and a drop-in http client to report logs, metrics, and traces out-of-the-box.

Quick Start

You can find basic examples here.

Documentation

Overview

Package http is used for building observable HTTP servers and clients that automatically report logs, metrics, and traces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a drop-in replacement for the standard http.Client. It is an observable http client with logging, metrics, and tracing.

func NewClient

func NewClient(client *http.Client, probe telemetry.Probe, opts Options) *Client

NewClient creates a new observable http client.

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

CloseIdleConnections is the observable counterpart of standard http Client.CloseIdleConnections.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do is the observable counterpart of standard http Client.Do.

func (*Client) Get

func (c *Client) Get(url string) (resp *http.Response, err error)

Get is the observable counterpart of standard http Client.Get. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.

func (*Client) Head

func (c *Client) Head(url string) (resp *http.Response, err error)

Head is the observable counterpart of standard http Client.Head. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.

func (*Client) Post

func (c *Client) Post(url, contentType string, body io.Reader) (resp *http.Response, err error)

Post is the observable counterpart of standard http Client.Post. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.

func (*Client) PostForm

func (c *Client) PostForm(url string, data url.Values) (resp *http.Response, err error)

PostForm is the observable counterpart of standard http Client.PostForm. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.

type Middleware

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

Middleware creates observable http handlers with logging, metrics, and tracing.

func NewMiddleware

func NewMiddleware(probe telemetry.Probe, opts Options) *Middleware

NewMiddleware creates a new observable http middleware.

func (*Middleware) Wrap

func (m *Middleware) Wrap(next http.HandlerFunc) http.HandlerFunc

Wrap wraps an existing http handler function and returns a new observable handler function. This can be used for making http handlers observable via logging, metrics, tracing, etc. It also observes and recovers panics that happened inside the inner http handler.

type Options

type Options struct {
	IDRegexp *regexp.Regexp
}

Options are optional configurations for middleware and clients.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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