Documentation
¶
Overview ¶
Package obs provides structured logging and lead-level tracing.
Spans are persisted to the same database as everything else rather than exported to an OTel collector. That is a deliberate M0 choice: `mole trace <session>` has to work offline, on a user's laptop, with no extra service running. An OTel bridge can be added later without changing call sites.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
func NewLogger(o LogOptions) *slog.Logger
NewLogger builds a slog.Logger. JSON is the right default for the daemon (logs get grepped and shipped); text is friendlier for the CLI.
Types ¶
type LogOptions ¶
type LogOptions struct {
Level string // debug | info | warn | error
Format string // text | json
Out io.Writer
}
LogOptions configures the process logger.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span is an in-flight trace record.
func FromContext ¶
FromContext returns the active span, if any.
type SpanOption ¶
SpanOption customizes a span at creation.
func WithAttrs ¶
func WithAttrs(attrs map[string]string) SpanOption
func WithLead ¶
func WithLead(leadID string) SpanOption
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer records spans.
func (*Tracer) Start ¶
func (t *Tracer) Start(ctx context.Context, sessionID, name string, opts ...SpanOption) (context.Context, *Span)
Start opens a span and returns a context carrying it, so a nested Start automatically attaches as a child.
A failure to persist a span is logged, never returned: observability must not be able to fail the work it is observing.