trace

package module
v0.0.0-...-c4edcd9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Adds support for goroutine-based propagation of contexts to OpenTelemetry tracing.

This library is inspired by https://github.com/tylerb/gls and https://github.com/jtolds/gls.

Example

topCtx, top := tracer.Start(context.Background(), "top")

// two will be a child span of top
_, two := tracer.Start(topCtx, "two")

// three will be a chlid span of two
_, three := tracer.Start(trace.CurrentContext(), "three")

// four will be a child span of three
_, four := tracer.Continue("four")

Documentation

Overview

Package trace provides a wrapper around OpenTelemetry's trace API with support for goroutine-bound context propagation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentContext

func CurrentContext() context.Context

CurrentContext returns the current goroutine-local context, or context.Background() if there is no current context.

Types

type Tracer

type Tracer interface {
	trace.Tracer

	// Continue is like Start, but starts the new span using the context from CurrentContext().
	Continue(spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
}

Tracer wraps trace.Tracer to support goroutine-bound context propagation.

func NewTracer

func NewTracer(name string, opts ...trace.TracerOption) Tracer

Jump to

Keyboard shortcuts

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