Documentation ¶
Index ¶
- func NewMiddleware(options ...MiddlewareOption) (func(http.Handler) http.Handler, xstats.XStater, error)
- func NewTransport(options ...TransportOption) func(http.RoundTripper) http.RoundTripper
- type Middleware
- type MiddlewareOption
- func MiddlewareOptionBytesInName(name string) MiddlewareOption
- func MiddlewareOptionBytesOutName(name string) MiddlewareOption
- func MiddlewareOptionBytesTotalName(name string) MiddlewareOption
- func MiddlewareOptionRequestTag(tagger func(*http.Request) (string, string)) MiddlewareOption
- func MiddlewareOptionRequestTimeName(name string) MiddlewareOption
- func MiddlewareOptionTag(tagName string, tagValue string) MiddlewareOption
- func MiddlewareOptionUDPGlobalRollupSender(host string, maxPacketSize int, flushInterval time.Duration, prefix string, ...) MiddlewareOption
- func MiddlewareOptionUDPSender(host string, maxPacketSize int, flushInterval time.Duration, prefix string) MiddlewareOption
- type Transport
- type TransportOption
- func TransportOptionBytesInName(name string) TransportOption
- func TransportOptionBytesOutName(name string) TransportOption
- func TransportOptionBytesTotalName(name string) TransportOption
- func TransportOptionConnectionIdleName(name string) TransportOption
- func TransportOptionDNSName(name string) TransportOption
- func TransportOptionFirstResponseByteName(name string) TransportOption
- func TransportOptionGotConnectionName(name string) TransportOption
- func TransportOptionPutIdleName(name string) TransportOption
- func TransportOptionRequestTag(tagger func(*http.Request) (string, string)) TransportOption
- func TransportOptionRequestTimeName(name string) TransportOption
- func TransportOptionTLSName(name string) TransportOption
- func TransportOptionTag(tagName string, tagValue string) TransportOption
- func TransportOptionWroteHeadersName(name string) TransportOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
func NewMiddleware(options ...MiddlewareOption) (func(http.Handler) http.Handler, xstats.XStater, error)
NewMiddleware configures and constructs a stat emitting HTTP middleware along with a stat client that can be used to generate metrics outside the scope of an HTTP request.
func NewTransport ¶
func NewTransport(options ...TransportOption) func(http.RoundTripper) http.RoundTripper
NewTransport configures and returns an HTTP Transport middleware.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is an http.Handler wrapper that instruments HTTP servers with the standard SecDev metrics.
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MiddlewareOption ¶
type MiddlewareOption func(*Middleware) (*Middleware, error)
MiddlewareOption is used to configure the HTTP server middleware.
func MiddlewareOptionBytesInName ¶
func MiddlewareOptionBytesInName(name string) MiddlewareOption
MiddlewareOptionBytesInName sets the metric name used to identity the number of bytes read from an incoming HTTP request. The default value is service_bytes_received
func MiddlewareOptionBytesOutName ¶
func MiddlewareOptionBytesOutName(name string) MiddlewareOption
MiddlewareOptionBytesOutName sets the metric name used to identify the number of bytes written as the result of a request. The default value is service_bytes_sent
func MiddlewareOptionBytesTotalName ¶
func MiddlewareOptionBytesTotalName(name string) MiddlewareOption
MiddlewareOptionBytesTotalName sets the metric name used to identify the total number of bytes read or written as the result of handling a request. The default value is service_bytes_total
func MiddlewareOptionRequestTag ¶
func MiddlewareOptionRequestTag(tagger func(*http.Request) (string, string)) MiddlewareOption
MiddlewareOptionRequestTag is a function that is run on every incoming request. The resulting key/value pair emitted is added to the stat sender such that all stats emitted during the lifetime of the request will have the annotations.
func MiddlewareOptionRequestTimeName ¶
func MiddlewareOptionRequestTimeName(name string) MiddlewareOption
MiddlewareOptionRequestTimeName sets the metric name used to indentify the duration of handling requests. The default value is service_time.
func MiddlewareOptionTag ¶
func MiddlewareOptionTag(tagName string, tagValue string) MiddlewareOption
MiddlewareOptionTag applies a static key/value pair to all metrics.
func MiddlewareOptionUDPGlobalRollupSender ¶
func MiddlewareOptionUDPGlobalRollupSender(host string, maxPacketSize int, flushInterval time.Duration, prefix string, rollupTags []string) MiddlewareOption
MiddlewareOptionUDPGlobalRollupSender enables datadog style statsd emissions over UDP but specifically for timers and percentiles which might need global aggregation to prevent host outliers from skewing percentiles.
func MiddlewareOptionUDPSender ¶
func MiddlewareOptionUDPSender(host string, maxPacketSize int, flushInterval time.Duration, prefix string) MiddlewareOption
MiddlewareOptionUDPSender enables datadog style statsd emissions over UDP
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an http.RoundTripper wrapper that instruments HTTP clients with the standard SecDev metrics.
type TransportOption ¶
TransportOption is used to configure the HTTP transport middleware.
func TransportOptionBytesInName ¶
func TransportOptionBytesInName(name string) TransportOption
TransportOptionBytesInName sets the name of the metric used to track the number of bytes read as part of the HTTP response from a request. The default value is client_request_bytes_received.
func TransportOptionBytesOutName ¶
func TransportOptionBytesOutName(name string) TransportOption
TransportOptionBytesOutName sets the name of the metric used to track the number of bytes written as part of the HTTP request body. The default value is client_request_bytes_sent.
func TransportOptionBytesTotalName ¶
func TransportOptionBytesTotalName(name string) TransportOption
TransportOptionBytesTotalName sets the name of the metric used to track the number of bytes written and read as part of the HTTP request. The default value is client_request_bytes_total.
func TransportOptionConnectionIdleName ¶
func TransportOptionConnectionIdleName(name string) TransportOption
TransportOptionConnectionIdleName sets the name of the metric used to track the duration a TCP connection spent in the idle pool. The default value is client_connection_idle.
func TransportOptionDNSName ¶
func TransportOptionDNSName(name string) TransportOption
TransportOptionDNSName sets the name of the metric used to track the duration of resolving the target DNS name of hte request. The default value is client_dns.
func TransportOptionFirstResponseByteName ¶
func TransportOptionFirstResponseByteName(name string) TransportOption
TransportOptionFirstResponseByteName sets the name of the metric used to track the duration between the time when the request headers are written to the stream and the first byte of the response being read back. The default value is client_first_response_byte.
func TransportOptionGotConnectionName ¶
func TransportOptionGotConnectionName(name string) TransportOption
TransportOptionGotConnectionName sets the name of the metric used to track the duration of the creating/fetching a TCP connection. The default value is client_got_connection.
func TransportOptionPutIdleName ¶
func TransportOptionPutIdleName(name string) TransportOption
TransportOptionPutIdleName sets the name of the metric used to count the number of connections that are placed in the idle pool. The default value is client_put_idle.
func TransportOptionRequestTag ¶
func TransportOptionRequestTag(tagger func(*http.Request) (string, string)) TransportOption
TransportOptionRequestTag is called on each round trip with the request instance. The key/value pair returned by this function will be used to annotate all metrics emitted by the transport middleware.
func TransportOptionRequestTimeName ¶
func TransportOptionRequestTimeName(name string) TransportOption
TransportOptionRequestTimeName sets the name of the metric used to track the duration of the HTTP request. The default value is client_request_time.
func TransportOptionTLSName ¶
func TransportOptionTLSName(name string) TransportOption
TransportOptionTLSName sets the name of the metric used to track the duration of performing the TLS handshake with the remote server. The default value is client_tls.
func TransportOptionTag ¶
func TransportOptionTag(tagName string, tagValue string) TransportOption
TransportOptionTag adds a static key/value annotation to all metrics emitted by the middleware.
func TransportOptionWroteHeadersName ¶
func TransportOptionWroteHeadersName(name string) TransportOption
TransportOptionWroteHeadersName sets the name of the metric used to track the duration between the time to get a TCP connection and when the request headers are written to the stream. The default value is client_wrote_headers.