zipkintracer

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 13 Imported by: 364

README

zipkin-go-opentracing

Travis CI GoDoc Go Report Card Sourcegraph

OpenTracing bridge for the native Zipkin tracing implementation Zipkin Go.

Notes

This package is a simple bridge to allow OpenTracing API consumers to use Zipkin as their tracing backend. For details on how to work with spans and traces we suggest looking at the documentation and README from the OpenTracing API.

For developers interested in adding Zipkin tracing to their Go services we suggest looking at Go kit which is an excellent toolkit to instrument your distributed system with Zipkin and much more with clean separation of domains like transport, middleware / instrumentation and business logic.

Examples

Please check the zipkin-go package for information how to set-up the Zipkin Go native tracer. Once set-up you can simple call the Wrap function to create the OpenTracing compatible bridge.

import (
	"github.com/opentracing/opentracing-go"
	"github.com/openzipkin/zipkin-go"
	zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
	zipkinot "github.com/openzipkin-contrib/zipkin-go-opentracing"
)

func main() {
	// bootstrap your app...
  
	// zipkin / opentracing specific stuff
	{
		// set up a span reporter
		reporter := zipkinhttp.NewReporter("http://zipkinhost:9411/api/v2/spans")
		defer reporter.Close()
  
		// create our local service endpoint
		endpoint, err := zipkin.NewEndpoint("myService", "myservice.mydomain.com:80")
		if err != nil {
			log.Fatalf("unable to create local endpoint: %+v\n", err)
		}

		// initialize our tracer
		nativeTracer, err := zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(endpoint))
		if err != nil {
			log.Fatalf("unable to create tracer: %+v\n", err)
		}

		// use zipkin-go-opentracing to wrap our tracer
		tracer := zipkinot.Wrap(nativeTracer)
  
		// optionally set as Global OpenTracing tracer instance
		opentracing.SetGlobalTracer(tracer)
	}
  
	// do other bootstrapping stuff...
}

For more information on zipkin-go-opentracing, please see the documentation at go doc.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Delegator delegatorType

Delegator is the format to use for DelegatingCarrier.

Functions

func Wrap added in v0.4.0

func Wrap(tr *zipkin.Tracer, opts ...TracerOption) opentracing.Tracer

Wrap receives a zipkin tracer and returns an opentracing tracer

Types

type B3InjectOption added in v0.4.0

type B3InjectOption int

B3InjectOption type holds information on B3 injection style when using native OpenTracing HTTPHeadersCarrier.

const (
	B3InjectStandard B3InjectOption = iota
	B3InjectSingle
	B3InjectBoth
)

Available B3InjectOption values

type DelegatingCarrier

type DelegatingCarrier interface {
	State() (model.SpanContext, error)
	SetState(model.SpanContext) error
}

DelegatingCarrier is a flexible carrier interface which can be implemented by types which have a means of storing the trace metadata and already know how to serialize themselves

type FinisherWithDuration added in v0.4.0

type FinisherWithDuration interface {
	FinishedWithDuration(d time.Duration)
}

FinisherWithDuration allows to finish span with given duration

type SpanContext

type SpanContext model.SpanContext

SpanContext holds the basic Span metadata.

func (SpanContext) ForeachBaggageItem

func (c SpanContext) ForeachBaggageItem(handler func(k, v string) bool)

ForeachBaggageItem belongs to the opentracing.SpanContext interface

type TracerOption

type TracerOption func(opts *TracerOptions)

TracerOption allows for functional options. See: http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

func WithB3InjectOption added in v0.4.0

func WithB3InjectOption(b3InjectOption B3InjectOption) TracerOption

WithB3InjectOption sets the B3 injection style if using the native OpenTracing HTTPHeadersCarrier

func WithObserver added in v0.3.0

func WithObserver(observer otobserver.Observer) TracerOption

WithObserver assigns an initialized observer to opts.observer

type TracerOptions

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

TracerOptions allows creating a customized Tracer.

Jump to

Keyboard shortcuts

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