Documentation
¶
Overview ¶
Package span provides small helpers for running functions inside OpenTelemetry spans.
Index ¶
- Variables
- func Call[T any](ctx context.Context, tracer trace.Tracer, name string, f Func1[T], ...) (ret T, err error)
- func Call2[T, U any](ctx context.Context, tracer trace.Tracer, name string, f Func2[T, U], ...) (ret T, ret2 U, err error)
- func Run(ctx context.Context, tracer trace.Tracer, name string, f Func, opts ...Option) (err error)
- type Func
- type Func1
- type Func2
- type Option
- type PanicError
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNilFunc = errors.New("xtrace: nil span function")
Functions ¶
func Call ¶
func Call[T any](ctx context.Context, tracer trace.Tracer, name string, f Func1[T], opts ...Option) (ret T, err error)
Call is Run with one return value.
Types ¶
type Option ¶
type Option func(*options)
Option configures span helper behavior.
func WithErrorFilter ¶
WithErrorFilter decides which returned errors should be recorded on the span.
func WithRecoverPanics ¶
func WithRecoverPanics() Option
WithRecoverPanics converts a panic into a PanicError return value after recording it on the span. Without this option panics are recorded and re-panicked.
func WithSpanOptions ¶
func WithSpanOptions(opts ...trace.SpanStartOption) Option
WithSpanOptions appends OpenTelemetry span start options.
func WithoutErrorStatus ¶
func WithoutErrorStatus() Option
WithoutErrorStatus prevents setting span status to Error for returned errors.
func WithoutRecordError ¶
func WithoutRecordError() Option
WithoutRecordError prevents RecordError calls for returned errors.
type PanicError ¶
type PanicError struct {
Value any
}
PanicError is returned when WithRecoverPanics catches a panic.
func (PanicError) Error ¶
func (e PanicError) Error() string
Click to show internal directories.
Click to hide internal directories.