trace

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

View Source
const (
	NoopProviderType = iota
	ConsoleProviderType
	JaegerProviderType
)

Valid values for TracerProviderType

View Source
const (
	SetGlobalProvider     = true
	DontSetGlobalProvider = false
)

Boolean flags for indicating whether a TracerProvider should be set as the global TracerProvider

View Source
const Version = "0.0.1"

Variables

This section is empty.

Functions

func NewOtelTracer

func NewOtelTracer(tracerOtel traceotel.Tracer) otelTracer

Types

type Span

type Span interface {
	// End completes the Span. The Span is considered complete and ready to be
	// delivered through the rest of the telemetry pipeline after this method
	// is called. Therefore, updates to the Span are not allowed after this
	// method has been called.
	End()

	// RecordError will record err as an exception span event for this span. An
	// additional call to SetStatus is required if the Status of the Span should
	// be set to Error, as this method does not change the Span status. If this
	// span is not being recorded or err is nil then this method does nothing.
	RecordError(err error)

	// SetStatus sets the status of the Span in the form of a code and a
	// description, overriding previous values set. The description is only
	// included in a status when the code is for an error.
	SetStatus(code codes.Code, description string)

	// SetAttributes sets kv as attributes of the Span. If a key from kv
	// already exists for an attribute of the Span it will be overwritten with
	// the value contained in kv.
	SetAttributes(kv ...attribute.KeyValue)

	// Record an error and set the status for a Span.
	RecordErrorAndSetStatus(err error)
}

Span represents a single operation within a trace.

type Tracer

type Tracer interface {
	// Start creates a span and a context.Context containing the newly-created
	// span.
	//
	// If the context.Context provided in `ctx` contains a Span then the
	// newly-created Span will be a child of that span, otherwise it will be a
	// root span.
	Start(ctx context.Context, spanName string) (context.Context, Span)
}

Tracer is responsible for creating trace Spans.

func GlobalTracer

func GlobalTracer(tracerName string) Tracer

GlobalTracer returns a Tracer using the registered global trace provider.

type TracerProvider

type TracerProvider interface {
	// Tracer creates an implementation of the Tracer interface.
	Tracer(tracerName string) Tracer
	// Shutdown and flush telemetry.
	Shutdown(ctx context.Context) error
	SetGlobalTracerProvider()
}

TracerProvider provides access to Tracers, which in turn allow for creation of trace Spans.

func NewTracerProvider

func NewTracerProvider(
	providerType TracerProviderType,
	setGlobalProvider bool,
	config TracerProviderConfig) (TracerProvider, error)

NewTracerProvider creates a TracerProvider of a given type, and optionally sets the new TracerProvider as the global TracerProvider.

type TracerProviderConfig

type TracerProviderConfig struct {
	// Name of the tracer
	TracerName string
	// Service to be traced
	TracerService string
	// Execution environment such as "production" or "development"
	TracerEnvironment string
	// Unique ID of the tracer
	TracerID int64
	// URL of the collector when using Jaeger
	CollectorURL string
	// Writer to use for the console tracer
	ConsoleWriter io.Writer
}

type TracerProviderType

type TracerProviderType int64

TracerProviderType represents a type of TracerProvider

Jump to

Keyboard shortcuts

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