trace

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 28

Documentation

Overview

Package trace is a shim to allow for easy migration from opencensus to opentelemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExporters added in v0.4.2

func AddExporters(exporters ...sdktrace.SpanExporter)

AddExporters adds the provided exporters to the global sdktrace.TracerProvider.

func ClearExporters added in v0.4.2

func ClearExporters() []sdktrace.SpanExporter

ClearExporters clears all span exporters that were previously added with AddExporters. It returns the removed exporters as a slice. It does not call sdktrace.SpanExporter.Shutdown on the removed exporters.

func GetProvider

func GetProvider() trace.TracerProvider

GetProvider returns the trace.TracerProvider configured by the last call to SetProvider.

func NewContext

func NewContext(ctx context.Context, span Span) context.Context

NewContext is a wrapper around trace.ContextWithSpan.

func RemoveExporters added in v0.4.2

func RemoveExporters(exporters ...sdktrace.SpanExporter) []sdktrace.SpanExporter

RemoveExporters any span exporters in exporters that were previously added with AddExporters. It returns the removed exporters as a slice. It does not call sdktrace.SpanExporter.Shutdown on the removed exporters.

func SetProvider added in v0.4.2

func SetProvider(ctx context.Context, opts ...sdktrace.TracerProviderOption) error

SetProvider creates a new sdktrace.TracerProvider and stores it + a tracer named "go.viam.com/utils/trace" in the global state. To dynamically configure exporters, do _not_ pass exporters with sdktrace.WithBatcher or similar here; instead use AddExporters.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown shuts down the global trace.TracerProvider created with SetProvider.

Types

type Span

type Span = trace.Span

Span is a type alias to trace.Span.

func FromContext

func FromContext(ctx context.Context) Span

FromContext is a wrapper around trace.FromContext.

func StartSpan

func StartSpan(ctx context.Context, name string, o ...trace.SpanStartOption) (context.Context, Span)

StartSpan is a wrapper around trace.Tracer.Start.

Jump to

Keyboard shortcuts

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