Documentation ¶
Overview ¶
Package instracer contains helpers for opencesus tracer.
Example:
import ( "github.com/insolar/assured-ledger/ledger-core/configuration" "github.com/insolar/assured-ledger/ledger-core/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(span opentracing.Span, err error)
- func MakeBinarySpan(input []byte) []byte
- func MakeUintSpan(input []byte) uint64
- func MustSerialize(ctx context.Context) []byte
- func NewJaegerTracer(_ context.Context, serviceName string, nodeRef string, agentEndpoint string, ...) (opentracing.Tracer, io.Closer, error)
- func ParentSpanCtx(ctx context.Context) (jaeger.SpanContext, context.Context)
- func Serialize(ctx context.Context) ([]byte, error)
- func ShouldRegisterJaeger(ctx context.Context, serviceName string, nodeRef string, agentEndpoint string, ...) func()
- func StartSpan(ctx context.Context, name string, o ...opentracing.StartSpanOption) (context.Context, opentracing.Span)
- func StartSpanWithSpanID(ctx context.Context, name string, spanID uint64, ...) (context.Context, opentracing.Span)
- func WithParentSpan(ctx context.Context, pspan TraceSpan) context.Context
- type LoggingSpan
- 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 (m *TraceSpan) MarshalToSizedBuffer(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 ¶
var ( ErrInvalidLengthSpanData = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowSpanData = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupSpanData = fmt.Errorf("proto: unexpected end of group") )
var ErrJaegerConfigEmpty = errors.New("can't create jaeger exporter, config not provided")
ErrJaegerConfigEmpty is returned if jaeger configuration has empty endpoint values.
Functions ¶
func AddError ¶
func AddError(span opentracing.Span, err error)
AddError add error info to span and mark span as errored
func MakeBinarySpan ¶
func MakeUintSpan ¶
func MustSerialize ¶
MustSerialize encode baggage entries from bytes, panics on error.
func NewJaegerTracer ¶
func NewJaegerTracer( _ context.Context, serviceName string, nodeRef string, agentEndpoint string, collectorEndpoint string, probabilityRate float64, ) (opentracing.Tracer, io.Closer, error)
NewJaegerTracer 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, ) func()
ShouldRegisterJaeger calls NewJaegerTracer and returns flush function.
func StartSpan ¶
func StartSpan(ctx context.Context, name string, o ...opentracing.StartSpanOption) (context.Context, opentracing.Span)
StartSpan starts span with stored baggage and with parent span if find in context.
func StartSpanWithSpanID ¶
Types ¶
type LoggingSpan ¶
type LoggingSpan struct { opentracing.Span // contains filtered or unexported fields }
func InitWrapper ¶
func InitWrapper(ctx context.Context, span opentracing.Span, name string) *LoggingSpan
func (*LoggingSpan) Finish ¶
func (ls *LoggingSpan) Finish()
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 (*TraceSpan) Descriptor ¶
func (*TraceSpan) MarshalToSizedBuffer ¶
func (*TraceSpan) ProtoMessage ¶
func (*TraceSpan) ProtoMessage()
func (*TraceSpan) XXX_DiscardUnknown ¶
func (m *TraceSpan) XXX_DiscardUnknown()