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.
Problem
A lifecycle event is emitted twice today, once to stdout and once over OTLP:
The attrs slice is shared and the body comes from a shared constant, so those can't drift. Two things still can:
slog.LevelInfolives at the call site,log.SeverityInfolives on theEvent.Emitat all. Add a third record with onlyslog.LogAttrsand it has no OTLP copy, and no test fails.Proposal
Have
actoreventown 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.