Documentation
¶
Overview ¶
Package httpxxray adds AWS X-Ray support to the httpx library's robust HTTP client. See https://github.com/gogama/httpx.
Use the OnClient function to install X-Ray support in any httpx.Client:
cl := &httpx.Client{} // Create robust HTTP client httpxxray.OnClient(cl, nil) // Install X-Ray plugin
When creating a request plan for the client to execute, use an X-Ray aware context, for example the aws.Context passed to a Lambda function handler.
pl := request.NewPlanWithContext( // Make plan using X-Ray aware context xrayAwareContext, "GET", "https://www.example.com/things/123", nil, ) e, err := cl.Do(pl) // Send request and read response // If the context is sampled by X-Ray, the X-Ray trace for the HTTP // request has now been emitted.
Use the OnHandlers function to install X-Ray support directly onto an httpx.HandlerGroup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnClient ¶
OnClient installs AWS X-Ray support onto an httpx Client.
If client's current handler group is nil, OnClient creates a new handler group, sets it as client's current handler group, and proceeds to install X-Ray support into the handler group. If the handler group is not nil, OnClient adds X-Ray support into the existing handler group. (Be aware of this behavior if you are sharing a handler group among multiple clients.)
Logger is used to log errors encountered by the plugin. The plugin does not produce any log messages in the ordinary course of operation and the logger is intended as a "just in case" debugging aid. To ignore errors, pass NopLogger (or nil, which is interpreted as NopLogger). However if you are using the plugin in a production system it is always prudent to use a viable logger.
func OnHandlers ¶
func OnHandlers(handlers *httpx.HandlerGroup, logger Logger) *httpx.HandlerGroup
OnHandlers installs AWS X-Ray support onto an httpx HandlerGroup.
The handler group may not be nil - if it is, a panic will ensue.
Logger is used to log errors encountered by the plugin. The plugin does not produce any log messages in the ordinary course of operation and the logger is intended as a "just in case" debugging aid. To ignore errors, pass NopLogger (or nil, which is interpreted as NopLogger). However if you are using the plugin in a production system it is always prudent to use a viable logger.
Types ¶
type Logger ¶
type Logger interface { // Printf prints a message to the logger. Arguments are handled in // the manner of fmt.Printf. Printf(format string, v ...interface{}) }
Logger allows the X-Ray plugin to log issues it has encountered. The interface is compatible with the Go standard log.Logger.
Implementations of Logger must be safe for concurrent use by multiple goroutines.