httpclient

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 5 Imported by: 0

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

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 an instrumented HTTP client that dispatches events for APM monitoring

func New

func New(opts ...Option) *Client

New creates a new instrumented HTTP client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, url string) (*http.Response, error)

Delete performs a DELETE request

func (*Client) Do

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

Do sends an HTTP request and returns an HTTP response, dispatching APM events

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (*http.Response, error)

Get performs a GET request

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

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)

Post performs a POST request

func (*Client) Put

func (c *Client) Put(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)

Put performs a PUT request

func (*Client) SetEventDispatcher added in v0.9.11

func (c *Client) SetEventDispatcher(fn func(event interface{}) error)

SetEventDispatcher sets the function used to dispatch events.

type Option

type Option func(*Client)

Option configures a Client

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets a base URL for all requests

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom http.Client

func WithTimeout

func WithTimeout(timeout time.Duration) Option

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

func (*RequestFailed) Name

func (e *RequestFailed) Name() string

Name returns the event name

type RequestSent

type RequestSent struct {
	Context      context.Context
	Method       string
	URL          string
	StatusCode   int
	DurationMs   int64
	RequestSize  int64
	ResponseSize int64
	TraceID      string
	SpanID       string
	ParentID     string
}

RequestSent is dispatched after an HTTP request completes successfully

func (*RequestSent) Name

func (e *RequestSent) Name() string

Name returns the event name

Jump to

Keyboard shortcuts

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