Documentation ¶
Overview ¶
Package instracer contains helpers for opencesus tracer.
Example:
import ( "github.com/insolar/insolar/configuration" "github.com/insolar/insolar/log" ) // on client side // entryvalue := "entryvalue" ctx := context.Background() jaegerflush = instracer.ShouldRegisterJaeger(ctx, "insolard", "localhost:6831", "") defer jaegerflush() // wait all trace data to send on jaeger server // serialize clientctx spanbindata := instracer.MustSerialize(ctx) // send spanbindata on wire with request // someSendMethod(ctxdata, request) // on server side // // deserialized from wire // spanbindata := someRecieverMethod() ctx := context.Background() instracer.MustDeserialize(spanbindata) ctx = instracer.WithParentSpan(ctx, parentspan) donefn := instracer.ShouldRegisterJaeger(ctx, "server", "localhost:6831", "") defer donefn() servctx, servspan := instracer.StartSpan(ctx, "server") defer servspan.End() // call subrequests with servctx, and use instracer.StartSpan
Hints:
Use environment variables for log level setup:
INSOLAR_TRACER_JAEGER_AGENTENDPOINT="localhost:6831"
How to run Jaeger locally:
docker run --rm --name jaeger \ -p 6831:6831/udp \ -p 16686:16686 \ jaegertracing/all-in-one:1.7 --log-level=debug
Index ¶
- Variables
- func AddError(s *trace.Span, err error)
- func MustSerialize(ctx context.Context) []byte
- func RegisterJaeger(servicename string, nodeRef string, agentendpoint string, ...) (*jaeger.Exporter, error)
- func Serialize(ctx context.Context) ([]byte, error)
- func ShouldRegisterJaeger(ctx context.Context, servicename string, nodeRef string, agentendpoint string, ...) (flusher func())
- func StartSpan(ctx context.Context, name string, o ...trace.StartOption) (context.Context, *trace.Span)
- func WithParentSpan(ctx context.Context, pspan TraceSpan) context.Context
- type TraceSpan
- func (*TraceSpan) Descriptor() ([]byte, []int)
- func (this *TraceSpan) Equal(that interface{}) bool
- func (this *TraceSpan) GoString() string
- func (m *TraceSpan) Marshal() (dAtA []byte, err error)
- func (m *TraceSpan) MarshalTo(dAtA []byte) (int, error)
- func (*TraceSpan) ProtoMessage()
- func (m *TraceSpan) Reset()
- func (ts TraceSpan) Serialize() ([]byte, error)
- func (m *TraceSpan) Size() (n int)
- func (this *TraceSpan) String() string
- func (m *TraceSpan) Unmarshal(dAtA []byte) error
- func (m *TraceSpan) XXX_DiscardUnknown()
- func (m *TraceSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TraceSpan) XXX_Merge(src proto.Message)
- func (m *TraceSpan) XXX_Size() int
- func (m *TraceSpan) XXX_Unmarshal(b []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidLengthSpanData = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowSpanData = fmt.Errorf("proto: integer overflow") )
View Source
var ErrJagerConfigEmpty = errors.New("can't create jaeger exporter, config not provided")
ErrJagerConfigEmpty is returned if jaeger configuration has empty endpoint values.
Functions ¶
func MustSerialize ¶
MustSerialize encode baggage entries from bytes, panics on error.
func RegisterJaeger ¶
func RegisterJaeger( servicename string, nodeRef string, agentendpoint string, collectorendpoint string, probabilityRate float64, ) (*jaeger.Exporter, error)
RegisterJaeger creates jaeger exporter and registers it in opencensus trace lib.
func ShouldRegisterJaeger ¶
func ShouldRegisterJaeger( ctx context.Context, servicename string, nodeRef string, agentendpoint string, collectorendpoint string, probabilityRate float64, ) (flusher func())
ShouldRegisterJaeger calls RegisterJaeger and returns flush function.
Types ¶
type TraceSpan ¶
type TraceSpan struct { TraceID []byte `protobuf:"bytes,20,opt,name=TraceID,proto3" json:"TraceID,omitempty"` SpanID []byte `protobuf:"bytes,21,opt,name=SpanID,proto3" json:"SpanID,omitempty"` }
func Deserialize ¶
Deserialize decode baggage entries from bytes.
func MustDeserialize ¶
MustDeserialize decode baggage entries from bytes, panics on error.
func ParentSpan ¶ added in v0.9.0
func (*TraceSpan) Descriptor ¶ added in v0.9.7
func (*TraceSpan) ProtoMessage ¶ added in v0.9.7
func (*TraceSpan) ProtoMessage()
func (*TraceSpan) XXX_DiscardUnknown ¶ added in v0.9.7
func (m *TraceSpan) XXX_DiscardUnknown()
func (*TraceSpan) XXX_Marshal ¶ added in v0.9.7
func (*TraceSpan) XXX_Unmarshal ¶ added in v0.9.7
Click to show internal directories.
Click to hide internal directories.