Skip to content

Add nil check to OTel bootup #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add nil check to OTel bootup #1091

wants to merge 1 commit into from

Conversation

aphralG
Copy link
Contributor

@aphralG aphralG commented May 27, 2025

Proposed changes

Added nil check to otel collector bootup to check service isnt nill before calling Run

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@aphralG aphralG self-assigned this May 27, 2025
@aphralG aphralG requested a review from a team as a code owner May 27, 2025 13:50
@github-actions github-actions bot added the chore Pull requests for routine tasks label May 27, 2025
@dhurley dhurley changed the title Add Nil Check to Otel bootup Add nil check to OTel bootup May 27, 2025
@dhurley dhurley added the v3.x Issues and Pull Requests related to the major version v3 label May 27, 2025
func (oc *Collector) bootup(ctx context.Context) error {
slog.InfoContext(ctx, "Starting OTel collector")
errChan := make(chan error)

go func() {
if oc.service == nil {
errChan <- fmt.Errorf("unable to start OTel collector: service is nil")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to add a return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't think it was needed as the errChan will return the error

case err := <-errChan:
			return err

@aphralG aphralG closed this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks v3.x Issues and Pull Requests related to the major version v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants