Documentation
¶
Overview ¶
Package httpclient provides an instrumented HTTP client for APM monitoring. It wraps the standard http.Client and dispatches events for outgoing requests.
Index ¶
- Variables
- func Delete(ctx context.Context, url string) (*http.Response, error)
- func Get(ctx context.Context, url string) (*http.Response, error)
- func Patch(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func Put(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func SetEventDispatcher(fn func(event interface{}) error)
- type Client
- func (c *Client) Delete(ctx context.Context, url string) (*http.Response, error)
- func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, url string) (*http.Response, error)
- func (c *Client) Patch(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) Put(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- type Option
- type RequestFailed
- type RequestSent
Constants ¶
This section is empty.
Variables ¶
var Default = New()
Default is the default instrumented HTTP client
Functions ¶
func Patch ¶
func Patch(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
Patch performs a PATCH request using the default client
func Post ¶
func Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
Post performs a POST request using the default client
func Put ¶
func Put(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
Put performs a PUT request using the default client
func SetEventDispatcher ¶
func SetEventDispatcher(fn func(event interface{}) error)
SetEventDispatcher sets the function used to dispatch events. This is called by the events package to wire up event dispatching.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an instrumented HTTP client that dispatches events for APM monitoring
func (*Client) Patch ¶
func (c *Client) Patch(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
Patch performs a PATCH request
type Option ¶
type Option func(*Client)
Option configures a Client
func WithBaseURL ¶
WithBaseURL sets a base URL for all requests
func WithHTTPClient ¶
WithHTTPClient sets a custom http.Client
func WithTimeout ¶
WithTimeout sets the client timeout
type RequestFailed ¶
type RequestFailed struct {
Context context.Context
Method string
URL string
Error string
DurationMs int64
TraceID string
SpanID string
ParentID string
}
RequestFailed is dispatched when an HTTP request fails