httpclient

package module
v0.0.0-...-ac6f71b Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package httpclient provides utilities for collect http metrics context into the outbound request headers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

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

Transport implements the http.RoundTripper interface and wraps outbound HTTP(S) requests with a meter.

func NewTransport

func NewTransport(base http.RoundTripper) *Transport

NewTransport wraps the provided http.RoundTripper with one that and includes http metrics context into the outbound request headers.

If the provided http.RoundTripper is nil, http.DefaultTransport will be used as the base http.RoundTripper. It allows for collecting metrics, specifically measuring outbound request durations in seconds, for HTTP client requests made using the wrapped RoundTripper.

base: The base http.RoundTripper to be wrapped. If nil, http.DefaultTransport
      is used as the default base RoundTripper.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip creates a Span and propagates its context via the provided request's headers before handing the request to the configured base RoundTripper. The created span will end when the response body is closed or when a read from the body returns io.EOF.

Directories

Path Synopsis
Package semconv provides utilities for working with OpenTelemetry semantic conventions related to HTTP and network operations.
Package semconv provides utilities for working with OpenTelemetry semantic conventions related to HTTP and network operations.

Jump to

Keyboard shortcuts

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