Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Process is process name used when New or Continue create new Spans. Process string )
Functions ¶
func CurrentTraceId ¶
func CurrentTraceId() int64
CurrentTraceId returns the caller's current trace id.
func GenerateId ¶
GenerateId returns a probablistically unique 64-bit id. All id values returned by this function will be positive integers. This may be useful for callers that want to generate their own id values.
func Go ¶
func Go(s *Span, f func())
Go functions similarly to Run, except that f is run in a new goroutine.
Types ¶
type Handler ¶
type Handler struct { // Kind is the kind value used when starting new traces. Kind string // HeaderKey is the key used when ServeHTTP inserts an id header in requests or responses. HeaderKey string // HonorReqHeader determines whether or not ServeHTTP honors id headers in requests. HonorReqHeader bool // AddRespHeader determines whether or not ServeHTTP adds id headers to responses. AddRespHeader bool }
func NewHandler ¶
func NewHandler() *Handler
NewHandler creates a middleware handler that facilitates HTTP request tracing.
If the request contains an id header and HonorReqHeader is true, then the id values are used (allowing trace contexts to span services). Otherwise a new trace id is generated. An id header is optionally added to the response.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)
type Logger ¶
type Logger interface {
Println(v ...interface{})
}
Logger is an interface compatible with log.Logger.
type Span ¶
type Span struct { SpanId int64 `yaml:"span_id"` TraceId int64 `yaml:"trace_id"` ParentId int64 `yaml:"parent_id"` Process string `yaml:",omitempty"` Kind string `yaml:",omitempty"` Name string `yaml:",omitempty"` Start time.Time `yaml:"-"` StartStr string `yaml:"start,omitempty"` Finish time.Time `yaml:"-"` FinishStr string `yaml:"finish,omitempty"` DataMap map[string]interface{} `yaml:",omitempty,inline"` }
Span tracks a processing activity within a trace.
func Continue ¶
Continue continues an existing trace. If recording is active, a new Span instance is allocated and returned, otherwise no allocation occurs and nil is returned (along with an error).
func MaybeContinue ¶
MaybeContinue continues an existing trace but ignores errors.
func New ¶
New starts a new trace. If recording is active, a new Span is allocated and returned, otherwise no allocation occurs and nil is returned (along with an error).
As a caller convenience, if traceId is non-zero, then that value is used instead of generating a probablistically unique id. This may be useful for callers that want to generate their own id values.