httplog

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package httplog provides http request and response transaction logging.

Index

Constants

View Source
const Available = true

Available indicates logging is supported.

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