Skip to content

improve slog component setting#1124

Merged
leftwo merged 1 commit intomasterfrom
alan/each-log-to-its-own
Apr 24, 2026
Merged

improve slog component setting#1124
leftwo merged 1 commit intomasterfrom
alan/each-log-to-its-own

Conversation

@leftwo
Copy link
Copy Markdown
Contributor

@leftwo leftwo commented Apr 23, 2026

In slog, you can set multiple values for the same key, and slog will just append them on to the end of the log record.
However, when the log is printed, we only show the first key and value and ignore the rest.

In propolis we had pretty early set:

log.new(slog::o!("component" => "vm_state_driver"));

We pass that log down to a bunch of other places, some of which we try to set component again:

slog::o!("component" => format!("crucible-{cru_id}")),

These later settings get dropped, so we end up with most of the logs having the component vm_state_driver.

Improving things a bit with this change, we can hold on to the base log and pass that down to children whom
will set their own component while sending the vm_state_driver log along for the places that are children
of it. At least that was my best guess for where to split things out. There could be more here to do, but this
at least got the problem I was trying to solve (crucible logs) and a few others as well

new component types that I did not see before:

21:59:33.211Z INFO propolis-server (vcpu_tasks): Starting vCPU thread vcpu = 0
21:59:33.205Z INFO propolis-server (attestation-server): attestation server created (sled-agent addr [fd9a:daae:107d:104::1]:12345 
21:59:33.325Z INFO propolis-server (oximeter-producer): listening
21:59:33.326Z INFO propolis-server (request_queue): enqueued external request
21:59:33.325Z INFO propolis-server (serial task): Entered serial task

These were all hidden behind the vm_state_driver

We only get the first slog "component =" setting.
Pass the base log a bit further down the call stack so
things that want to set their own component will get a chance to.
@leftwo leftwo requested a review from iximeow April 23, 2026 23:20
@leftwo
Copy link
Copy Markdown
Contributor Author

leftwo commented Apr 23, 2026

I've attached a sample instance boot logs from before (where it's all vm_state_driver) and after

before.log
after.log

Copy link
Copy Markdown
Member

@iximeow iximeow left a comment

Choose a reason for hiding this comment

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

well that is intensely awkward, thanks for chasing this down!

@leftwo leftwo merged commit 96e772a into master Apr 24, 2026
14 checks passed
@leftwo leftwo deleted the alan/each-log-to-its-own branch April 24, 2026 00:12
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.

2 participants