Documentation ¶
Overview ¶
Package httplog provides http request and response transaction logging.
Index ¶
Constants ¶
const Available = true
Available indicates logging is supported.
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 ¶
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.