zipkin

package module
v0.0.0-...-4468e7c Latest Latest
Warning

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

Go to latest
Published: May 26, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

Build Status

Zipkin library for Go

This library focus is to provide maximum flexibility for creating Zipkin traces inside the distributed application. The library presumes the user is familiar with basic Zipkin concepts like annotations, spans, services, etc. Zipkin spans are composed in a stateless fashion. It is up to you how to manage span entities inside the application. Kafka is used as a transport to transfer the completed spans to Zipkin collector.

Quickstart

// ...
import (
    "github.com/elodina/go-zipkin"
)

rate := 10 // tracing rate 1 of 10
brokerAddr := []string{"master:5000"} // Kafka broker endpoint

producer, err := zipkin.DefaultProducer(brokerAddr) if err != nil {
//...
}

tracer := zipkin.NewTracer("ServiceName", rate, producer, zipkin.LocalNetworkIP(), zipkin.DefaultPort(), zipkin.DefaultTopic())

//...
span := tracer.NewSpan("span_name")
span.ServerReceive()
// do work here
span.ServerSendAndCollect()
//...

Examples

You may see the complete end-to-end example here: https://github.com/aShevc/go-zipkin-sample

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPort

func DefaultPort() int16

func DefaultProducer

func DefaultProducer(brokerList []string) (*producer.KafkaProducer, error)

func DefaultTopic

func DefaultTopic() string

func LocalNetworkIP

func LocalNetworkIP() string

func SerializeSpan

func SerializeSpan(s *zipkincore.Span) ([]byte, error)

Types

type Collector

type Collector interface {
	Collect([]byte)
}

type KafkaCollector

type KafkaCollector struct {
	// contains filtered or unexported fields
}

func (*KafkaCollector) Collect

func (kc *KafkaCollector) Collect(bytes []byte)

type Span

type Span struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Span) Annotate

func (s *Span) Annotate(value string)

func (*Span) ClientReceive

func (s *Span) ClientReceive()

func (*Span) ClientReceiveAndCollect

func (s *Span) ClientReceiveAndCollect()

func (*Span) ClientSend

func (s *Span) ClientSend()

func (*Span) ClientSendAndCollect

func (s *Span) ClientSendAndCollect()

func (*Span) Collect

func (s *Span) Collect() error

func (*Span) GetAvroTraceInfo

func (s *Span) GetAvroTraceInfo() *avro.GenericRecord

func (*Span) ID

func (s *Span) ID() int64

func (*Span) NewChild

func (s *Span) NewChild(name string) *Span

func (*Span) ParentID

func (s *Span) ParentID() *int64

func (*Span) Sampled

func (s *Span) Sampled() bool

func (*Span) ServerReceive

func (s *Span) ServerReceive()

func (*Span) ServerReceiveAndCollect

func (s *Span) ServerReceiveAndCollect()

func (*Span) ServerSend

func (s *Span) ServerSend()

func (*Span) ServerSendAndCollect

func (s *Span) ServerSendAndCollect()

func (*Span) TraceID

func (s *Span) TraceID() int64

type TraceInfo

type TraceInfo struct {
	SpanId       int64
	TraceId      int64
	ParentSpanId interface{}
	Sampled      bool
}

func NewTraceInfo

func NewTraceInfo() *TraceInfo

func (*TraceInfo) Schema

func (this *TraceInfo) Schema() avro.Schema

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

func NewTracer

func NewTracer(serviceName string, rate int, producer *producer.KafkaProducer, ip string, port int16, topic string) *Tracer

func (*Tracer) NewSpan

func (t *Tracer) NewSpan(name string) *Span

func (*Tracer) NewSpanFromAvro

func (t *Tracer) NewSpanFromAvro(name string, traceInfo interface{}) *Span

func (*Tracer) NewSpanFromRequest

func (t *Tracer) NewSpanFromRequest(name string, traceId *int64, spanId *int64, parentId *int64, sampled *bool) *Span

Directories

Path Synopsis
gen-go

Jump to

Keyboard shortcuts

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