span

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attributes

func Attributes(ctx context.Context, attributes ...attribute.KeyValue)

Attributes sets attributes on the span extracted from the given context. If the context does not contain a span, this function has no effect.

Example:

span.Attributes(ctx, attribute.String("key", "value"), attribute.Int("count", 42))

func Error

func Error(ctx context.Context, err error) error

Error wraps the given error and records it as an error in the current OpenTelemetry span. If the provided error is nil, it returns nil.

func ErrorWithStack

func ErrorWithStack(ctx context.Context, err error) error

ErrorWithStack wraps the given error, records it as an error in the current OpenTelemetry span, and includes the stack trace information in the recorded error. If the provided error is nil, it returns nil.

func Event

func Event(ctx context.Context, name string, options ...trace.EventOption)

Event adds an event to the span associated with the provided context. The event is described by the given name and may include additional options.

Example:

ctx, end := span.Start(ctx)
defer end()
span.Event(ctx, "custom-event", trace.WithAttributes(attribute.Int("count", 42)))

Types

type EndFunc

type EndFunc func(options ...trace.SpanEndOption)

EndFunc is a function type that can be used to end an OpenTelemetry span.

func Start

func Start(ctx context.Context, options ...trace.SpanStartOption) (context.Context, EndFunc)

Start starts a new OpenTelemetry span using the provided context. It returns a new context containing the started span and a function to end the span.

Example:

ctx, end := span.Start(ctx)
defer end()

func StartWithName

func StartWithName(ctx context.Context, name string, options ...trace.SpanStartOption) (context.Context, EndFunc)

StartWithName starts a new OpenTelemetry span with the given name using the provided context. It returns a new context containing the started span and a function to end the span.

Jump to

Keyboard shortcuts

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