Documentation ¶
Index ¶
- type Daemon
- type Decision
- type SamplingPolicy
- type Segment
- type SegmentHTTP
- type SegmentRequest
- type SegmentResponse
- type SegmentRoot
- type SegmentSQL
- type XRay
- func (svc *XRay) AddSegment(segments ...*Segment)
- func (svc *XRay) Errorf(format string, v ...interface{})
- func (svc *XRay) Infof(format string, v ...interface{})
- func (svc *XRay) NewSegment(name string) *Segment
- func (svc *XRay) NewSegmentFromRequest(r *http.Request) *Segment
- func (svc *XRay) PutTraceSegments(segments []*Segment) error
- func (svc *XRay) RunDaemon(size int, interval time.Duration)
- func (svc *XRay) SetLogger(logger log.Logger)
- func (svc *XRay) SetSamplingPolicy(fraction, qps float64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is background daemon for sending segments. This struct stores segments and sends segment to AWS X-Ray in each checkpoint timing.
func NewDaemon ¶
NewDaemon creates new Daemon. size is number of segments to send AWS API in single checkpoint. interval is the time of checkpoint interval. fn is function called in each checkpoint, to sends segments to AWS API.
func (*Daemon) Flush ¶
func (d *Daemon) Flush()
Flush gets segments from the internal spool and execute flushSegments function.
type Decision ¶
type Decision struct { Trace bool // Whether to trace the request. Policy string // Name of the sampling policy. Weight float64 // Sample weight to be used in statistical calculations. }
Decision is the value returned by a call to a SamplingPolicy's Sample method.
type SamplingPolicy ¶
type SamplingPolicy interface { // Sample returns a Decision. // If Trace is false in the returned Decision, then the Decision should be // the zero value. Sample() Decision CanSample() bool }
SamplingPolicy is policy to determine which data can send to AWS API or not, with rate limit function.
func NewLimitedSampler ¶
func NewLimitedSampler(fraction, maxqps float64) (SamplingPolicy, error)
NewLimitedSampler returns a sampling policy that randomly samples a given fraction of requests. It also enforces a limit on the number of traces per second. It tries to trace every request with a trace header, but will not exceed the qps limit to do it.
type Segment ¶
type Segment struct { Trace bool // Required TraceID string ID string Name string StartTime time.Time EndTime time.Time // Optional User string ParentID string Error string Annotations map[string]interface{} Request *http.Request ResponseStatus int ContentLength int // subsegments SQLQuery string // contains filtered or unexported fields }
Segment is span data for AWS X-Ray.
func NewEmptySegment ¶
func NewEmptySegment() *Segment
NewEmptySegment creates dummy segment. This data is created by sampling policy and does not send to AWS API.
func NewSegment ¶
NewSegment creates new segment with given name.
func NewSegmentFromRequest ¶
NewSegmentFromRequest creates new segment from *http.Request.
func (*Segment) Finish ¶
func (s *Segment) Finish()
Finish ends segment timer and add segment into daemon's spool.
type SegmentHTTP ¶
type SegmentHTTP struct { *SegmentRequest `json:"request,omitempty"` *SegmentResponse `json:"response,omitempty"` }
SegmentHTTP is segment data for http.
type SegmentRequest ¶
type SegmentRequest struct { URL string `json:"url,omitempty"` Method string `json:"method,omitempty"` UserAgent string `json:"user_agent,omitempty"` ClientIP string `json:"client_ip,omitempty"` XForwardedFor bool `json:"x_forwarded_for,omitempty"` }
SegmentRequest is segment data for http request.
func NewSegmentRequest ¶
func NewSegmentRequest(r *http.Request) *SegmentRequest
NewSegmentRequest creates SegmentRequest data from *http.Request.
type SegmentResponse ¶
type SegmentResponse struct { Status int `json:"status,omitempty"` ContentLength int `json:"content_length,omitempty"` }
SegmentResponse is segment data for http response.
func NewSegmentResponse ¶
func NewSegmentResponse(status, length int) *SegmentResponse
NewSegmentResponse creates SegmentResponse data from http status code and content length.
type SegmentRoot ¶
type SegmentRoot struct { // Required TraceID string `json:"trace_id,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` StartTime float64 `json:"start_time,omitempty"` EndTime float64 `json:"end_time,omitempty"` // Optional User string `json:"user,omitempty"` ParentID string `json:"parent_id,omitempty"` Error string `json:"error,omitempty"` Annotations map[string]interface{} `json:"annotations,omitempty"` *SegmentHTTP `json:"http,omitempty"` // subsegments SubSegments []*SegmentRoot `json:"subsegments,omitempty"` *SegmentSQL `json:"sql,omitempty"` }
SegmentRoot is root segment data for converting JSON as a X-Ray's specification.
type SegmentSQL ¶
type SegmentSQL struct {
SanitizedQuery string `json:"sanitized_query,omitempty"`
}
SegmentSQL is segment data for sql.
type XRay ¶
type XRay struct {
// contains filtered or unexported fields
}
XRay has XRay client.
func (*XRay) AddSegment ¶
AddSegment adds the segment dat into background daemon.
func (*XRay) NewSegment ¶
NewSegment creates new Segment data with given name.
func (*XRay) NewSegmentFromRequest ¶
NewSegmentFromRequest creates new Segment data from *http.Request.
func (*XRay) PutTraceSegments ¶
PutTraceSegments executes PutTraceSegments operation.
func (*XRay) SetSamplingPolicy ¶
SetSamplingPolicy sets sampling policy.