Skip to content

(chore): Write both copies of an actor lifecycle event from one call - #1771

Merged
Krisztian F (krisztianfekete) merged 2 commits into
agent-substrate:mainfrom
krisztianfekete:follow-up/lifecycle-event-single-emit
Sep 21, 2026
Merged

Krisztian F (krisztianfekete) merged 2 commits into
agent-substrate:mainfrom
krisztianfekete:follow-up/lifecycle-event-single-emit

Conversation

@krisztianfekete

@krisztianfekete Krisztian F (krisztianfekete) commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

An actor lifecycle record went to stdout and to OTLP in two separate calls. The attributes were shared, but the severity was not, so the slog level sat at the call site and the OTel severity sat on the Event. Nothing made a caller write both copies either, so a new record could reach stdout only and no test would notice.

Since this PR actorevent.Log now writes both copies. The level comes from Event.Severity, so it is stored once. The OTLP only Emit and the exported body constants are gone, so the dual write is the only way out of the package.

Also normalizes ate.actor.operation.name on the crash event, which the state change event already did.

Fixes #1744

Testing

  • Unit tests for the level mapping, the dual write, and the registry check.

  • End to end on a fresh kind cluster. Both event names arrive with the right severity (9 and 17), the right attributes, and trace context on the record fields. The stdout copies match record for record.

  • Tests pass

  • Appropriate changes to documentation are included in the PR

Comment on lines +165 to +168
func (e *Emitter) Log(ctx context.Context, ev Event, attrs []slog.Attr) {
slog.LogAttrs(ctx, ev.Level(), ev.Body, attrs...)
e.emit(ctx, ev, attrs)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two copies still take two different timestamps. slog.LogAttrs stamps the stdout record with its own time.Now(), and emit calls time.Now() again at BuildRecord.

The package comment now says that nothing about a record is kept in step by hand, but a consumer that joins the stdout copy to the OTLP copy on an exact timestamp finds no match, because the two differ by microseconds.

Let's also align on the timestamps.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now done.

@krisztianfekete
Krisztian F (krisztianfekete) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into agent-substrate:main with commit f75e626 Sep 21, 2026
11 checks passed
@krisztianfekete
Krisztian F (krisztianfekete) deleted the follow-up/lifecycle-event-single-emit branch September 22, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants