oxy: github.com/vulcand/oxy/trace Index | Files

package trace

import "github.com/vulcand/oxy/trace"

Package trace implement structured logging of requests

Index

Package Files

trace.go

type Option Uses

type Option func(*Tracer) error

Option is a functional option setter for Tracer

func ErrorHandler Uses

func ErrorHandler(h utils.ErrorHandler) Option

ErrorHandler is a functional argument that sets error handler of the server

func Logger Uses

func Logger(l *log.Logger) Option

Logger defines the logger the tracer will use.

It defaults to logrus.StandardLogger(), the global logger used by logrus.

func RequestHeaders Uses

func RequestHeaders(headers ...string) Option

RequestHeaders adds request headers to capture

func ResponseHeaders Uses

func ResponseHeaders(headers ...string) Option

ResponseHeaders adds response headers to capture

type Record Uses

type Record struct {
    Request  Request  `json:"request"`
    Response Response `json:"response"`
}

Record represents a structured request and response record

type Request Uses

type Request struct {
    Method    string      `json:"method"`            // Method - request method
    BodyBytes int64       `json:"body_bytes"`        // BodyBytes - size of request body in bytes
    URL       string      `json:"url"`               // URL - Request URL
    Headers   http.Header `json:"headers,omitempty"` // Headers - optional request headers, will be recorded if configured
    TLS       *TLS        `json:"tls,omitempty"`     // TLS - optional TLS record, will be recorded if it's a TLS connection
}

Request contains information about an HTTP request

type Response Uses

type Response struct {
    Code      int         `json:"code"`              // Code - response status code
    Roundtrip float64     `json:"roundtrip"`         // Roundtrip - round trip time in milliseconds
    Headers   http.Header `json:"headers,omitempty"` // Headers - optional headers, will be recorded if configured
    BodyBytes int64       `json:"body_bytes"`        // BodyBytes - size of response body in bytes
}

Response contains information about HTTP response

type TLS Uses

type TLS struct {
    Version     string `json:"version"`      // Version - TLS version
    Resume      bool   `json:"resume"`       // Resume tells if the session has been re-used (session tickets)
    CipherSuite string `json:"cipher_suite"` // CipherSuite contains cipher suite used for this connection
    Server      string `json:"server"`       // Server contains server name used in SNI
}

TLS contains information about this TLS connection

type Tracer Uses

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

Tracer records request and response emitting JSON structured data to the output

func New Uses

func New(next http.Handler, writer io.Writer, opts ...Option) (*Tracer, error)

New creates a new Tracer middleware that emits all the request/response information in structured format to writer and passes the request to the next handler. It can optionally capture request and response headers, see RequestHeaders and ResponseHeaders options for details.

func (*Tracer) ServeHTTP Uses

func (t *Tracer) ServeHTTP(w http.ResponseWriter, req *http.Request)

Package trace imports 9 packages (graph) and is imported by 9 packages. Updated 2018-07-13. Refresh now. Tools for package owners.