Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attributes ¶
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 ¶
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 ¶
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 ¶
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.