Documentation
¶
Overview ¶
Package tracing provides a minimal, zero-dependency tracing API used by Buffalo to instrument long-running build steps (proto compilation, dep fetch, cache lookups, etc.). It is intentionally compatible with the OpenTelemetry semantic model — Span, attributes, status — so that a future adapter can forward spans to an OTel SDK without touching call sites.
By default tracing is a no-op: the global tracer drops every span. Call SetTracer to install a real implementation (e.g. one bridging to go.opentelemetry.io/otel) when the dependency is acceptable for the build.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryTracer ¶
type MemoryTracer struct {
// contains filtered or unexported fields
}
MemoryTracer records spans in memory. Safe for tests; not for production.
func NewMemoryTracer ¶
func NewMemoryTracer() *MemoryTracer
NewMemoryTracer returns a fresh in-memory tracer.
func (*MemoryTracer) Spans ¶
func (m *MemoryTracer) Spans() []*RecordedSpan
Spans returns a snapshot of recorded spans.
func (*MemoryTracer) StartSpan ¶
func (m *MemoryTracer) StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span)
StartSpan implements Tracer.
type RecordedSpan ¶
type RecordedSpan struct {
Name string
StartTime time.Time
EndTime time.Time
Attributes map[string]any
Errors []error
StatusCode StatusCode
StatusDesc string
// contains filtered or unexported fields
}
RecordedSpan is a span captured by MemoryTracer.
func (*RecordedSpan) Duration ¶
func (s *RecordedSpan) Duration() time.Duration
Duration returns the wall-clock duration. Zero before End().
func (*RecordedSpan) RecordError ¶
func (s *RecordedSpan) RecordError(err error)
RecordError implements Span.
func (*RecordedSpan) SetAttribute ¶
func (s *RecordedSpan) SetAttribute(key string, value any)
SetAttribute implements Span.
func (*RecordedSpan) SetStatus ¶
func (s *RecordedSpan) SetStatus(code StatusCode, desc string)
SetStatus implements Span.
type Span ¶
type Span interface {
SetAttribute(key string, value any)
RecordError(err error)
SetStatus(code StatusCode, description string)
End()
}
Span represents an in-flight unit of work.
type SpanConfig ¶
SpanConfig is the materialized set of SpanOptions.
type SpanOption ¶
type SpanOption func(*SpanConfig)
SpanOption configures a span at creation time.
func WithAttributes ¶
func WithAttributes(attrs map[string]any) SpanOption
WithAttributes seeds the new span with key/value pairs.
type StatusCode ¶
type StatusCode int
StatusCode mirrors the OpenTelemetry status semantics.
const ( StatusUnset StatusCode = iota StatusOK StatusError )