Documentation ¶
Index ¶
- func DisableTracing()
- func EnableTracing()
- func GetXRayHeader(req *http.Request, headerName ...string) *header.Header
- func GetXRayHttpRequestName(req *http.Request, segNamer ...xray.SegmentNamer) string
- func Init(daemonAddr string, serviceVersion string) error
- func SetXRayServiceOff()
- func SetXRayServiceOn()
- func XRayServiceOn() bool
- type XRayParentSegment
- type XSegment
- func (x *XSegment) Capture(traceName string, executeFunc func() error, traceData ...*XTraceData)
- func (x *XSegment) CaptureAsync(traceName string, executeFunc func() error, traceData ...*XTraceData)
- func (x *XSegment) Close()
- func (x *XSegment) NewSubSegment(subSegmentName string) *XSegment
- func (x *XSegment) Ready() bool
- func (x *XSegment) SetParentSegment(parentID string, traceID string)
- type XTraceData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetXRayHeader ¶
GetXRayHeader gets header from http.request, if headerName is not specified, defaults to x-amzn-trace-id
func GetXRayHttpRequestName ¶
func GetXRayHttpRequestName(req *http.Request, segNamer ...xray.SegmentNamer) string
GetXRayHttpRequestName returns the segment name based on http request method and path, or if segmentNamer is defined, gets the name from http request host
func SetXRayServiceOff ¶
func SetXRayServiceOff()
SetXRayServiceOff turns off xray service for new objects, so that wrappers and code supporting xray will not start using xray for tracing when it is init, connect or open, existing objects are not affected by this function action
func SetXRayServiceOn ¶
func SetXRayServiceOn()
SetXRayServiceOn turns on xray service for new objects, so that wrappers and code supporting xray will start using xray for tracing, the service is set to on during its init, open, or connect etc actions, existing objects are not affected by this function action
func XRayServiceOn ¶
func XRayServiceOn() bool
XRayServiceOn returns whether xray tracing service is on or off
Types ¶
type XRayParentSegment ¶
type XSegment ¶
type XSegment struct { Ctx context.Context Seg *xray.Segment // contains filtered or unexported fields }
XSegment struct provides wrapper function for xray segment, subsegment, context, and related actions
always use NewSegment() to create XSegment object ptr
func NewSegment ¶
func NewSegment(serviceNameOrUrl string, parentSegment ...*XRayParentSegment) *XSegment
NewSegment begins a new segment for a named service or url, the context.Background() is used as the base context when creating a new segment
NOTE = ALWAYS CALL CLOSE() to End Segment After Tracing of Segment is Complete
func NewSegmentFromHeader ¶
NewSegmentFromHeader begins a new segment for a named service or url based on http request, the http.Request Context is used as the base context when creating a new segment
NOTE = ALWAYS CALL CLOSE() to End Segment After Tracing of Segment is Complete
func NewSegmentNullable ¶
func NewSegmentNullable(serviceNameOrUrl string, parentSegment ...*XRayParentSegment) *XSegment
NewSegmentNullable returns a new segment for the named service or url, if _xrayServiceOn = true, otherwise, nil is returned for *XSegment.
func (*XSegment) Capture ¶
func (x *XSegment) Capture(traceName string, executeFunc func() error, traceData ...*XTraceData)
Capture wraps xray.Capture, by beginning and closing a subsegment with traceName, and synchronously executes the provided executeFunc which contains source application's logic
traceName = descriptive name for the tracing session being tracked executeFunc = custom logic to execute within capture tracing context (context is segment context) traceData = optional additional data to add to the trace (meta, annotation, error)
func (*XSegment) CaptureAsync ¶
func (x *XSegment) CaptureAsync(traceName string, executeFunc func() error, traceData ...*XTraceData)
CaptureAsync wraps xray.CaptureAsync, by beginning and closing a subsegment with traceName, and Asynchronously executes the provided executeFunc which contains source application's logic note = use CaptureAsync when tracing goroutine (rather than Capture) note = do not manually call Capture within goroutine to ensure segment is flushed properly
traceName = descriptive name for the tracing session being tracked executeFunc = custom logic to execute within capture tracing context (context is segment context) traceData = optional additional data to add to the trace (meta, annotation, error)
func (*XSegment) Close ¶
func (x *XSegment) Close()
Close will close a segment (or subsegment), always close subsegments first before closing its parent segment
func (*XSegment) NewSubSegment ¶
NewSubSegment begins a new subsegment under the parent segment context, the subSegmentName defines a descriptive name of this sub segment for tracing, subsegment.Close(nil) should be called before its parent segment Close is called
NOTE = ALWAYS CALL CLOSE() to End Segment After Tracing of Segment is Complete
func (*XSegment) SetParentSegment ¶
SetParentSegment sets segment's ParentID and TraceID as indicated by input parameters
type XTraceData ¶
type XTraceData struct { Meta map[string]interface{} Annotations map[string]interface{} Errors map[string]error }
XTraceData contains maps of data to add during trace activity
func (*XTraceData) AddAnnotation ¶
func (t *XTraceData) AddAnnotation(key string, data interface{})
AddAnnotation adds xray annotation to trace, each trace limits to 50 annotations, annotation = key value pair indexed for use with filter expression
func (*XTraceData) AddError ¶
func (t *XTraceData) AddError(key string, err error)
AddError adds xray error to trace, Error = client errors (4xx other than 429) Fault = server faults (5xx) Throttle = throttle errors (429 too many requests)
func (*XTraceData) AddMeta ¶
func (t *XTraceData) AddMeta(key string, data interface{})
AddMeta adds xray metadata to trace, metadata = key value pair with value of any type, including objects or lists, not indexed,
used to record data that need to be stored in the trace, but don't need to be indexed for searching