tracing/

directory
v0.0.0-...-fa06ddb Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2015 License: MIT

README

package tracing

package tracing provides Dapper-style request tracing to services. An implementation exists for Zipkin; Appdash support is planned.

Rationale

Request tracing is a fundamental building block for large distributed applications. It's instrumental in understanding request flows, identifying hot spots, and diagnosing errors. All microservice infrastructures will benefit from request tracing; sufficiently large infrastructures will require it.

Usage

Wrap a server- or client-side endpoint so that it emits traces to a Zipkin collector.

func main() {
	var (
		myHost        = "instance01.addsvc.internal.net"
		myMethod      = "ADD"
		scribeHost    = "scribe.internal.net"
		timeout       = 50 * time.Millisecond
		batchSize     = 100
		batchInterval = 5 * time.Second
	)
	spanFunc := zipkin.NewSpanFunc(myHost, myMethod)
	collector, _ := zipkin.NewScribeCollector(scribeHost, timeout, batchSize, batchInterval)

	// Server-side
	var server endpoint.Endpoint
	server = makeEndpoint() // for your service
	server = zipkin.AnnotateServer(spanFunc, collector)(server)
	go serveViaHTTP(server)

	// Client-side
	before := httptransport.ClientBefore(zipkin.ToRequest(spanFunc))
	var client endpoint.Endpoint
	client = httptransport.NewClient(addr, codec, factory, before)
	client = zipkin.AnnotateClient(spanFunc, collector)(client)
}

Jump to

Keyboard shortcuts

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