trace

package
v0.0.0-...-b9a86dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(writer io.Writer)

Init init the trace, must set a trace writer and id generator.

func NewContext

func NewContext(c context.Context, t *Trace) context.Context

NewContext return a copy of the parent context and associates it with a trace.

func SetRatio

func SetRatio(ratio float32)

SetRatio set the trace ratio.

func Stop

func Stop()

Stop stop the trace.

Types

type Trace

type Trace struct {
	ID       string `json:"id"`
	SpanID   string `json:"span_id"`
	ParentID string `json:"parent_id"`
	Sampled  bool   `json:"sampled"`
}

Trace is server and client called trace info.

func FromContext

func FromContext(c context.Context) (*Trace, bool)

FromContext returns the trace bound to the context, if any.

func InheritTrace

func InheritTrace(id, spanID, parentID string, sampled bool) *Trace

InheritTrace fork a child trace from current trace.

func NewTrace

func NewTrace() *Trace

NewTrace a root trace.

func WithHTTP

func WithHTTP(req *http.Request) *Trace

WithHTTP init trace from http request.

func (*Trace) ClientReceive

func (t *Trace) ClientReceive()

ClientReceive record the trace with a event ClientReceive and called it when the call end.

func (*Trace) ClientStart

func (t *Trace) ClientStart(module, name, env string)

ClientStart record the trace with a event ClientStart and called it when the call start.

func (*Trace) Fork

func (t *Trace) Fork() *Trace

Fork fork a trace with different id.

func (*Trace) Log

func (t *Trace) Log(module, name, env string)

Log record the trace with a event UserDefine and called it when you want more info.

func (*Trace) ServerReceive

func (t *Trace) ServerReceive(module, name, env string)

ServerReceive record the trace with a event ServerReceive and called it when the call end.

func (*Trace) ServerSend

func (t *Trace) ServerSend()

ServerSend record the trace with a event ServerSend and called it when the call start.

func (*Trace) SetHTTP

func (t *Trace) SetHTTP(req *http.Request)

SetHTTP set trace id into http request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL