actorevent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package actorevent emits the actor lifecycle events. Log writes both copies of a record, the stdout one and the OTLP one, from a single call, so nothing about a record is kept in step by hand. Ordinary component logs stay on stdout.

This is not an slog bridge. A bridge would put every component record on the wire, cannot set EventName, and would loop, because serverboot routes OTel SDK errors through slog.

serverboot.InitLogging pairs this with a batching processor. These records sit on the actor resume path, so exporting inside Log would put a blocking gRPC call there and make a slow collector look like control-plane latency.

Index

Constants

View Source
const ScopeName = "github.com/agent-substrate/substrate/internal/actorevent"

ScopeName is how a consumer selects this stream.

Variables

View Source
var (
	StateChanged = Event{
		Name:     "ate.actor.state_changed",
		Body:     "Actor state changed",
		Severity: log.SeverityInfo,
		Keys: append(append([]string{}, identityKeys...),
			string(ateattr.ActorOperationNameKey),
			string(ateattr.ActorStateKey)),
	}

	Crashed = Event{
		Name:     "ate.actor.crashed",
		Body:     "Actor crashed",
		Severity: log.SeverityError,
		Keys: append(append([]string{}, identityKeys...),
			string(ateattr.ActorOperationNameKey),
			string(ateattr.ActorStateKey)),
	}
)

Two names, because a crash has a different shape and severity. Only two, because ate.actor.state already says which transition happened.

Functions

func BuildRecord

func BuildRecord(ev Event, t time.Time, attrs []slog.Attr) log.Record

BuildRecord turns the stdout record into its OTLP form. Attributes carry everything machine-readable, so the body stays the display string.

It sets no trace context: the SDK lifts that from ctx onto the record's own TraceId/SpanId fields.

func Log

func Log(ctx context.Context, ev Event, attrs []slog.Attr)

Log records ev through the process-wide provider.

Types

type Emitter

type Emitter struct {
	// contains filtered or unexported fields
}

Emitter writes the OTLP copy through one log.Logger. Tests construct one directly, so emit needs no global provider and can run in parallel.

func NewEmitter

func NewEmitter(lp log.LoggerProvider) *Emitter

func (*Emitter) Log

func (e *Emitter) Log(ctx context.Context, ev Event, attrs []slog.Attr)

Log writes both copies of ev from one call, off one time.Now(), so a consumer can join them on an exact timestamp. That is why the stdout record is built here rather than through slog.LogAttrs, which would take its own reading.

--log-level=warn silences the stdout copy of an info event while the OTLP copy still ships.

type Event

type Event struct {
	Name     string
	Body     string
	Severity log.Severity
	Keys     []string
}

Event is one name in the closed vocabulary. Name is the LogRecord's own event name field, not an attribute. Body and Severity live here rather than at a call site, so the two copies of a record cannot differ.

Keys is the attribute set the name promises. An event name means a fixed shape, so the tests hold the two in step and a caller cannot widen the record.

func (Event) Level

func (ev Event) Level() slog.Level

Level is the stdout level for this event. slog has four levels to OTel's twenty-four, so a sub-level collapses onto the range it sits in.

Jump to

Keyboard shortcuts

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