zipkin

package
v0.0.0-...-6080588 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientSend is the annotation value used to mark a client sending a
	// request to a server.
	ClientSend = "cs"

	// ServerReceive is the annotation value used to mark a server's receipt
	// of a request from a client.
	ServerReceive = "sr"

	// ServerSend is the annotation value used to mark a server's completion
	// of a request and response to a client.
	ServerSend = "ss"

	// ClientReceive is the annotation value used to mark a client's receipt
	// of a completed request from a server.
	ClientReceive = "cr"
)

Variables

Log is used to report diagnostic information. To enable it, swap in your application's logger.

View Source
var (
	// SpanContextKey represents the Span in the request context.
	SpanContextKey = "Zipkin-Span"
)

Functions

func AnnotateClient

func AnnotateClient(newSpan NewSpanFunc, c Collector) endpoint.Middleware

AnnotateClient returns a middleware that extracts a parent span from the context, produces a client (child) span from it, adds client-send and client-receive annotations at the boundaries, and submits the span to the collector. If no span is found in the context, a new span is generated and inserted.

func AnnotateServer

func AnnotateServer(newSpan NewSpanFunc, c Collector) endpoint.Middleware

AnnotateServer returns a server.Middleware that extracts a span from the context, adds server-receive and server-send annotations at the boundaries, and submits the span to the collector. If no span is found in the context, a new span is generated and inserted.

func ToContext

func ToContext(newSpan NewSpanFunc) func(ctx context.Context, r *http.Request) context.Context

ToContext returns a function that satisfies transport/http.BeforeFunc. It takes a Zipkin span from the incoming HTTP request, and saves it in the request context. It's designed to be wired into a server's HTTP transport Before stack.

func ToRequest

func ToRequest(newSpan NewSpanFunc) func(ctx context.Context, r *http.Request) context.Context

ToRequest returns a function that satisfies transport/http.BeforeFunc. It takes a Zipkin span from the context, and injects it into the HTTP request. It's designed to be wired into a client's HTTP transport Before stack. It's expected that AnnotateClient has already ensured the span in the context is a child/client span.

Types

type Collector

type Collector interface {
	Collect(*Span) error
}

Collector represents a Zipkin trace collector, which is probably a set of remote endpoints.

func NewScribeCollector

func NewScribeCollector(addr string, timeout time.Duration, batchSize int, batchInterval time.Duration) (Collector, error)

NewScribeCollector returns a new Scribe-backed Collector, ready for use.

type MultiCollector

type MultiCollector []Collector

MultiCollector implements Collector by sending spans to all collectors.

func (MultiCollector) Collect

func (c MultiCollector) Collect(s *Span) error

Collect implements Collector.

type NewSpanFunc

type NewSpanFunc func(traceID, spanID, parentSpanID int64) *Span

NewSpanFunc takes trace, span, & parent span IDs to produce a Span object.

func MakeNewSpanFunc

func MakeNewSpanFunc(hostport, serviceName, methodName string) NewSpanFunc

MakeNewSpanFunc returns a function that generates a new Zipkin span.

type NopCollector

type NopCollector struct{}

NopCollector implements Collector but performs no work.

func (NopCollector) Collect

func (NopCollector) Collect(*Span) error

Collect implements Collector.

type ScribeCollector

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

ScribeCollector implements Collector by forwarding spans to a Scribe service, in batches.

func (*ScribeCollector) Collect

func (c *ScribeCollector) Collect(s *Span) error

Collect implements Collector.

type Span

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

A Span is a named collection of annotations. It represents meaningful information about a single method call, i.e. a single request against a service. Clients should annotate the span, and submit it when the request that generated it is complete.

func NewSpan

func NewSpan(hostport, serviceName, methodName string, traceID, spanID, parentSpanID int64) *Span

NewSpan returns a new Span object ready for use.

func (*Span) Annotate

func (s *Span) Annotate(value string)

Annotate annotates the span with the given value.

func (*Span) AnnotateDuration

func (s *Span) AnnotateDuration(value string, duration time.Duration)

AnnotateDuration annotates the span with the given value and duration.

func (*Span) Encode

func (s *Span) Encode() *zipkincore.Span

Encode creates a Thrift Span from the gokit Span.

func (*Span) ParentSpanID

func (s *Span) ParentSpanID() int64

ParentSpanID returns the ID of the span which invoked this span. It may be zero.

func (*Span) SpanID

func (s *Span) SpanID() int64

SpanID returns the ID of this span.

func (*Span) TraceID

func (s *Span) TraceID() int64

TraceID returns the ID of the trace that this span is a member of.

Jump to

Keyboard shortcuts

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