Skip to content

Build a lifecycle event once, then consume it in stdout and OTLP #1744

Description

Problem

A lifecycle event is emitted twice today, once to stdout and once over OTLP:

slog.LogAttrs(ctx, slog.LevelInfo, actorevent.StateChangedBody, attrs...)
actorevent.Emit(ctx, actorevent.StateChanged, attrs)

The attrs slice is shared and the body comes from a shared constant, so those can't drift. Two things still can:

  • Severity. slog.LevelInfo lives at the call site, log.SeverityInfo lives on the Event.
  • The pairing. Nothing makes you call Emit at all. Add a third record with only slog.LogAttrs and it has no OTLP copy, and no test fails.

Proposal

Have actorevent own one emission helper that takes the event and the attrs and produces both outputs, with the slog level derived from Event.Severity rather than stored twice. One call per record, nothing left to keep in sync by hand.

From Jeff Luo (@JeffLuoo)'s review on #1658.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/observabilitykind/designDesign discussion, investigation, or research required before implementation

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions