Documentation
¶
Index ¶
- Constants
- func ContextFromHeaders(r *http.Request) context.Context
- func CurrentTimeSecond() float64
- func GetCauseFromHTTPStatus(status int) string
- func GetClientIP(req *http.Request) string
- func GetContentLength(res *http.Response) (int, error)
- func GetIDsFromContext(ctx context.Context) (rootID, parentID, sampled string)
- func GetenvOrDefault(key string, def string) string
- type Sampler
Constants ¶
const ( // ErrorType represents a 4XX status code ErrorType = "error" // FaultType represents a 5XX status code FaultType = "fault" )
const (
// XRayHeader represents an AWS X-Ray trace HTTP header key.
XRayHeader = "X-Amzn-Trace-Id"
)
Variables ¶
This section is empty.
Functions ¶
func ContextFromHeaders ¶
ContextFromHeaders parses the root ID, parent ID, and whether the request was sampled based on the HTTP request X-Ray header and returns a new context containing the metadata.
func CurrentTimeSecond ¶
func CurrentTimeSecond() float64
CurrentTimeSecond returns a float64 representation of the current Unix time with sub-second decimal accuracy.
func GetCauseFromHTTPStatus ¶
GetCauseFromHTTPStatus returns a string representing an error, fault, or no cause based on HTTP response status codes
func GetClientIP ¶
GetClientIP returns the IP address of a request from an X-Forwarded-For header or remote address
func GetContentLength ¶
GetContentLength returns the content length of a response if provided as a header.
func GetIDsFromContext ¶
GetIDsFromContext returns the root ID, parent ID, and whether the request was sampled based on context metadata.
func GetenvOrDefault ¶
GetenvOrDefault returns an environment variable value if not empty, otherwise it returns the default value.
Types ¶
type Sampler ¶
Sampler represents a sampler instance, which keeps track of the number of traces per second to be sampled and fallback rate for additional sampling. Additionally, a sampler instance determines whether a given trace should be sampled based on 'fixedTarget' and 'fallbackRate' settings.
func NewSampler ¶
NewSampler creates a new sampler with the specified configuration.