instracer

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

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

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 AddError added in v0.9.0

func AddError(s *trace.Span, err error)

AddError add error info to span and mark span as errored

func MustSerialize

func MustSerialize(ctx context.Context) []byte

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 Serialize

func Serialize(ctx context.Context) ([]byte, error)

Serialize encode baggage entries to bytes.

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.

func StartSpan

func StartSpan(ctx context.Context, name string, o ...trace.StartOption) (context.Context, *trace.Span)

StartSpan starts span with stored baggage and with parent span if find in context.

func WithParentSpan

func WithParentSpan(ctx context.Context, pspan TraceSpan) context.Context

WithParentSpan returns new context with provided parent span.

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

func Deserialize(b []byte) (TraceSpan, error)

Deserialize decode baggage entries from bytes.

func MustDeserialize

func MustDeserialize(b []byte) TraceSpan

MustDeserialize decode baggage entries from bytes, panics on error.

func ParentSpan added in v0.9.0

func ParentSpan(ctx context.Context) (parentSpan TraceSpan, ok bool)

func (*TraceSpan) Descriptor added in v0.9.7

func (*TraceSpan) Descriptor() ([]byte, []int)

func (*TraceSpan) Equal added in v0.9.7

func (this *TraceSpan) Equal(that interface{}) bool

func (*TraceSpan) GoString added in v0.9.7

func (this *TraceSpan) GoString() string

func (*TraceSpan) Marshal added in v0.9.7

func (m *TraceSpan) Marshal() (dAtA []byte, err error)

func (*TraceSpan) MarshalTo added in v0.9.7

func (m *TraceSpan) MarshalTo(dAtA []byte) (int, error)

func (*TraceSpan) ProtoMessage added in v0.9.7

func (*TraceSpan) ProtoMessage()

func (*TraceSpan) Reset added in v0.9.7

func (m *TraceSpan) Reset()

func (TraceSpan) Serialize

func (ts TraceSpan) Serialize() ([]byte, error)

Serialize method encodes TraceSpan to bytes.

func (*TraceSpan) Size added in v0.9.7

func (m *TraceSpan) Size() (n int)

func (*TraceSpan) String added in v0.9.7

func (this *TraceSpan) String() string

func (*TraceSpan) Unmarshal added in v0.9.7

func (m *TraceSpan) Unmarshal(dAtA []byte) error

func (*TraceSpan) XXX_DiscardUnknown added in v0.9.7

func (m *TraceSpan) XXX_DiscardUnknown()

func (*TraceSpan) XXX_Marshal added in v0.9.7

func (m *TraceSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TraceSpan) XXX_Merge added in v0.9.7

func (m *TraceSpan) XXX_Merge(src proto.Message)

func (*TraceSpan) XXX_Size added in v0.9.7

func (m *TraceSpan) XXX_Size() int

func (*TraceSpan) XXX_Unmarshal added in v0.9.7

func (m *TraceSpan) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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