# README
Tracing
Tracing is a go.opentelemetry.io Tracer wrapper for instrumenting golang applications to collect traces in jaeger.
Install
go get github.com/loghole/tracing
Usage
package main
import (
"context"
"time"
"github.com/loghole/tracing"
)
func main() {
tracer, err := tracing.NewTracer(tracing.DefaultConfiguration("example", "udp://127.0.0.1:6831"))
if err != nil {
panic(err)
}
defer tracer.Close()
ctx, span := tracer.NewSpan().WithName("root").StartWithContext(context.Background())
defer span.End()
next(ctx)
}
func next(ctx context.Context) {
defer tracing.ChildSpan(&ctx).End()
// Some work...
time.Sleep(time.Second)
}
Examples
# Functions
ChildSpan starts new span and replace original context.
ContextWithoutCancel returns a context that is never canceled.
DefaultConfiguration returns base configuration with default params.
No description provided by the author
InjectHeaders set tracecontext from the Context into the http.Header carrier.
InjectMap set tracecontext from the Context into the map[string]string carrier.
NewNoopTracer returns a Tracer that performs no operations.
NewTracer returns initialized Tracer with jaeger exporter.
SpanContextFromContext returns the current Span's SpanContext.
SpanFromContext returns the current Span from ctx.
# Variables
No description provided by the author
# Structs
Configuration configures Tracer.
Span is wrapper for `trace.Span` interface.
SpanBuilder is a helper for creating a span through a chain of calls.
Tracer is the wrapper for `trace.Tracer` with span builder.