obs

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

func FromContext(ctx context.Context) *Span

FromContext returns the active span, if any.

func (*Span) Duration

func (s *Span) Duration() time.Duration

Duration reports elapsed time; for an open span, time so far.

func (*Span) End

func (s *Span) End(ctx context.Context, status string)

End closes the span. Calling End twice is a no-op.

func (*Span) ID

func (s *Span) ID() string

ID exposes the span identifier, for correlating log lines.

type SpanOption

type SpanOption func(*core.Span)

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 NewTracer

func NewTracer(st store.Store, log *slog.Logger) *Tracer

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL