Skip to content

Inline telemetry lifecycle event calls#197

Open
carole-lavillonniere wants to merge 1 commit intomainfrom
refact-pr-127
Open

Inline telemetry lifecycle event calls#197
carole-lavillonniere wants to merge 1 commit intomainfrom
refact-pr-127

Conversation

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere commented Apr 23, 2026

Summary

Refactoring addressing suggested improvement #1 from @thrau in this comment #127 (review)

The goal is to make reading the code easier, be more explicit and idiomatic go.

Changes

Move nil safety for *telemetry.Client from call-site guards into nil receiver methods, and inline the two private helpers emitEmulatorStartError / emitEmulatorStartSuccess.

@carole-lavillonniere carole-lavillonniere changed the title inline telemetry lifecycle event calls Inline telemetry lifecycle event calls Apr 23, 2026
Copy link
Copy Markdown
Contributor

@anisaoshafi anisaoshafi left a comment

Choose a reason for hiding this comment

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

Valid changes IMO, looks good 💅🏼

Copy link
Copy Markdown
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

Thanks @carole-lavillonniere! Looks like a simple refactoring that makes everything a bit tidier! The code now constructs the event structs in-place at the call site, which is much more readable than the previous multi-argument helper functions 👍

Given the goal is to reduce functional over-engineering, one change we can still make in start.go to advance that goal is to remove tel as an argument in all functions that are passed opts StartOptions as arguments, given that the telemetry client is a value of StartOptions.

In the future (outside the scope of this PR), we should further encapsulate Start, Stop and similar container commands into a common struct (like a ContainerService class), and make stable dependencies (like the the ContainerRuntime, TelemetryClient, etc...) part of the struct.

})
}

func validateLicense(ctx context.Context, sink output.Sink, opts StartOptions, tel *telemetry.Client, containerConfig runtime.ContainerConfig, token, licenseFilePath string) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

example where tel can be removed.

Comment on lines +39 to +41
if c == nil {
return
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

q: under what circumstances could c be nil?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants