httplog

package
v1.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httplog provides http request and response transaction logging.

Index

Constants

View Source
const TraceIDKey = contextKey("trace.id")

TraceIDKey is key used to add a trace.id value to the context of HTTP requests. The value will be logged by LoggingRoundTripper.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoggingRoundTripper

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

LoggingRoundTripper is an http.RoundTripper that logs requests and responses.

func NewLoggingRoundTripper

func NewLoggingRoundTripper(next http.RoundTripper, maxBodyLen int) *LoggingRoundTripper

NewLoggingRoundTripper returns a LoggingRoundTripper that logs requests and responses to stderr. Transaction creation is logged to log.

func (*LoggingRoundTripper) RoundTrip

func (rt *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface, logging the request and response to the underlying logger.

Fields logged in requests:

url.original
url.scheme
url.path
url.domain
url.port
url.query
http.request
user_agent.original
http.request.body.content
http.request.body.truncated
http.request.body.bytes
http.request.mime_type
event.original (the request without body from httputil.DumpRequestOut)

Fields logged in responses:

http.response.status_code
http.response.body.content
http.response.body.truncated
http.response.body.bytes
http.response.mime_type
event.original (the response without body from httputil.DumpResponse)

func (*LoggingRoundTripper) TxID

func (rt *LoggingRoundTripper) TxID() string

TxID returns the current transaction.id value. If rt is nil, the empty string is returned.

Jump to

Keyboard shortcuts

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