Documentation
¶
Overview ¶
Package span provides the Span type for representing units of work with timing information and hierarchical structure.
A Span records when an operation started and ended, maintains parent-child relationships with other spans, and can hold attributes and events. Spans are thread-safe for concurrent access.
Use this package when you need to create and manipulate spans directly. For context-based span propagation, use the parent trace package.
Index ¶
- type Option
- type Span
- func (s *Span) AddEvent(e *event.Event)
- func (s *Span) Attributes() []*attribute.Attribute
- func (s *Span) Children() []*Span
- func (s *Span) Duration() time.Duration
- func (s *Span) End()
- func (s *Span) EndTime() time.Time
- func (s *Span) Events() []*event.Event
- func (s *Span) Name() string
- func (s *Span) Parent() *Span
- func (s *Span) RecordError(err error)
- func (s *Span) SetAttributes(attrs ...*attribute.Attribute)
- func (s *Span) SetStatusCode(code status.Code)
- func (s *Span) SpanID() string
- func (s *Span) StartTime() time.Time
- func (s *Span) StatusCode() status.Code
- func (s *Span) TraceID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(opts *spanOptions)
Option configures a spanOptions instance.
func WithEndCallback ¶
WithEndCallback provides an Option to set a callback that is invoked when the span ends.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span represents a unit of work with timing information and hierarchical structure.
func New ¶
New creates a new span with the given name, trace ID, and optional parent. If a parent is provided, the new span is added as a child of the parent.
func (*Span) Attributes ¶
Attributes returns a copy of all attributes on the span.
func (*Span) End ¶
func (s *Span) End()
End marks the span as complete by recording the end time. Only the first call has any effect; subsequent calls are ignored.
func (*Span) RecordError ¶
RecordError records an error on the span by setting the status to Error and adding an error event.
func (*Span) SetAttributes ¶
SetAttributes sets attributes on the span.
func (*Span) SetStatusCode ¶
SetStatusCode sets the status code on the span.
func (*Span) SpanID ¶
SpanID returns the unique identifier for this span within its hierarchy. This should NOT be used as a globally unique identifier. A unique identifier for a span is a combination of an application ID, a TraceID, and a SpanID.
func (*Span) StatusCode ¶
StatusCode returns the status code of the span.