eventbus

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package eventbus is the adapter that connects the telemetry.BusEmitter seam to the events.EventBus. The adapter lives in its own package — neither `internal/telemetry` nor `internal/events` import the other, so the dependency edge passes through the wiring layer where it belongs.

Construction is straightforward; the canonical usage from `cmd/harbor` (or any future bootstrap site) is:

bus, _ := events.Open(ctx, cfg.Events, redactor)
logger, _ := telemetry.New(cfg.Telemetry, redactor,
    telemetry.WithBusEmitter(eventbus.New(bus)))

After this wiring, `Logger.Error(ctx, msg, attrs...)` emits both the slog record AND a `runtime.error` event onto the bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter satisfies telemetry.BusEmitter by publishing runtime.error events to the wrapped events.EventBus.

func New

func New(bus events.EventBus) *Adapter

New constructs an Adapter wrapping bus. nil bus returns a nil Adapter — callers that want a no-op emitter should omit telemetry.WithBusEmitter rather than passing nil through here.

func (*Adapter) EmitRuntimeError

func (a *Adapter) EmitRuntimeError(ctx context.Context, msg string, attrs []slog.Attr)

EmitRuntimeError converts the Logger.Error payload to a runtime.error event and publishes it. Best-effort: a publish failure (closed bus, redactor error, missing identity) does NOT propagate back into Logger.Error — the slog record has already been written, so the operator still sees the error.

Identity is recovered from ctx via identity.QuadrupleFrom (or identity.From if no Quadruple is present). The bus rejects publishes with a missing identity triple, so when ctx carries no identity at all the adapter quietly skips publishing — Logger already wrote the slog record.

Jump to

Keyboard shortcuts

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