Pragmatic and minimalistic module for collecting and exporting trace data from the Go code.

prometheus/client_golang but for Traces

NOTE: This project follows semver, but it is in experimental v0.x.y phase. API might change.


This library was born from the fact that the current state of Go clients for tracing are far from perfection.

The success of the Prometheus client_golang library (this package is used more than 51,000 repositories) was in some way thanks to the simplicity, stability and efficiency of that Go client for metrics. Strict compatibility, clear API and error semantics, no scope creep and single module are the things that enabled massive value to so many people and organizations in the community. The key is to make the best user (developer) experience possible.

The above learnings was what motivated the creation of


  • Manual span instrumentation with contextualized tracer and clear error semantics.
  • Export of traces to the desired tracing backend or collector:

At least for now, this project wraps multiple modules, (almost) fully hiding those from the public interface. Yet, if you import module you will transiently import OpenTelemetry modules.


First, create tracer with exporter(s) you want e.g. Jaeger HTTP Thrift.

// import ""
// import ""

tr, closeFn, err := tracing.NewTracer(
		// Further options.
if err != nil {
	// Handle err...

defer closeFn()

Then use it to create root span that also gives context that can be used to create more sub-spans. NOTE: Only context has power to create sub spans.

// import ""

ctx, root := tr.StartSpan("app")
defer root.End()

// ...
ctx, span := tracing.StartSpan(ctx, "dummy operation")
defer func() {
  span.SetAttributes("err", err)

Use DoInSpan if you want to do something in the dedicated span.

// import ""

tracing.DoInSpan(ctx, "sub operation1", func(ctx context.Context, span tracing.Span) {
    // ...
tracing.DoInSpan(ctx, "sub operation2", func(ctx context.Context, span tracing.Span) { 
	// ...

See (and run if you want) an example instrumented application using our docker based e2e suite.


  • Initial version of this library was written for @AnaisUrlichs and @bwplotka demo of monitoring Argo Rollout jobs
  • OpenTelemetry project for providing OTLP trace protocol and Go implementation for writing gRPC OTLP.


View Github