Skip to content

Add naming support to readiness probes for better logging#13

Closed
molon wants to merge 2 commits into
mainfrom
probe-name
Closed

Add naming support to readiness probes for better logging#13
molon wants to merge 2 commits into
mainfrom
probe-name

Conversation

@molon

@molon molon commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Provide context or links (Jira ticket, Slack thread) for both the reviewer and your future self:

  • Jira ticket:
  • Slack thread:

Copilot AI review requested due to automatic review settings January 2, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds naming support to readiness probes to improve logging and debugging capabilities. When probes are waited on during lifecycle startup, their names are now logged for better observability. If no name is set, probes are identified by their index (e.g., "probe[0]").

Key Changes

  • Added name field to ReadinessProbe with WithName and GetName methods for setting and retrieving probe names
  • Enhanced lifecycle startup logging to include probe names when waiting for readiness, signaling completion, or handling failures
  • Automatically propagate names to readiness probes when WithName is called on FuncActor or Lifecycle

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lifecycle/readiness.go Adds name field and accessor methods (WithName, GetName) to ReadinessProbe for identification in logs
lifecycle/lifecycle.go Adds debug and error logging with probe names during readiness probe waiting; updates Lifecycle.WithName to propagate name to its readiness probe
lifecycle/func.go Updates FuncActor.WithName to propagate name to its readiness probe when enabled; sets initial probe name in WithReadiness method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lifecycle/readiness.go
Comment on lines +52 to +58
func (rp *ReadinessProbe) WithName(name string) *ReadinessProbe {
rp.name = name
return rp
}

// GetName returns the name of the readiness probe.
func (rp *ReadinessProbe) GetName() string {

Copilot AI Jan 2, 2026

Copy link

Choose a reason for hiding this comment

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

The name field is accessed without mutex protection, which could lead to race conditions. The ReadinessProbe struct already has a sync.RWMutex to protect the err field. The name field should be similarly protected since WithName could be called concurrently with GetName. Consider acquiring the appropriate lock (write lock for WithName, read lock for GetName) to ensure thread-safe access.

Suggested change
func (rp *ReadinessProbe) WithName(name string) *ReadinessProbe {
rp.name = name
return rp
}
// GetName returns the name of the readiness probe.
func (rp *ReadinessProbe) GetName() string {
func (rp *ReadinessProbe) WithName(name string) *ReadinessProbe {
rp.mu.Lock()
rp.name = name
rp.mu.Unlock()
return rp
}
// GetName returns the name of the readiness probe.
func (rp *ReadinessProbe) GetName() string {
rp.mu.RLock()
defer rp.mu.RUnlock()

Copilot uses AI. Check for mistakes.
Comment thread lifecycle/readiness.go
Comment on lines +58 to +60
func (rp *ReadinessProbe) GetName() string {
return rp.name
}

Copilot AI Jan 2, 2026

Copy link

Choose a reason for hiding this comment

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

The name field access in GetName is not protected by a mutex, which could lead to race conditions when called concurrently with WithName. Consider acquiring a read lock before accessing the name field to ensure thread-safe access.

Copilot uses AI. Check for mistakes.
Comment thread lifecycle/readiness.go
Comment on lines +51 to +60
// WithName sets the name of the readiness probe for logging and debugging.
func (rp *ReadinessProbe) WithName(name string) *ReadinessProbe {
rp.name = name
return rp
}

// GetName returns the name of the readiness probe.
func (rp *ReadinessProbe) GetName() string {
return rp.name
}

Copilot AI Jan 2, 2026

Copy link

Choose a reason for hiding this comment

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

The new WithName and GetName methods lack test coverage. Since the readiness_test.go file has comprehensive test coverage for other ReadinessProbe methods, consider adding tests to verify that WithName correctly sets the name and GetName retrieves it, including edge cases like empty names and concurrent access.

Copilot uses AI. Check for mistakes.
@molon molon closed this Jan 3, 2026
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