Categorygithub.com/loghole/tracing
repositorypackage
0.18.0
Repository: https://github.com/loghole/tracing.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Tracing

GoDoc Go Report Card Coverage Status

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