Skip to content
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

fix: don't pass context to segment telemetry #138

Closed
wants to merge 1 commit into from

Conversation

abuchanan-airbyte
Copy link
Collaborator

When a user cancels an install by pressing Ctrl+C, the Go Context created in main.go is canceled. That context was being passed to the Segment telemetry client, which was trying to send an HTTP request using the canceled context, which would always fail. That resulted in a surprisingly large number of 'running' events.

This change removes the context from the telemetry client calls so that this doesn't happen.

@abuchanan-airbyte abuchanan-airbyte requested a review from a team as a code owner October 25, 2024 14:17
@@ -150,7 +149,7 @@ func (s *SegmentClient) send(ctx context.Context, es EventState, et EventType, e
return fmt.Errorf("unable to create request body: %w", err)
}

req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewBuffer(data))
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(data))
Copy link
Member

Choose a reason for hiding this comment

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

What if we only made this change, but still passed the context through everything?

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking about this in a similar way that the go slog package handles cancelled contexts, in that they ignore them in certain cases; e.g.

The signature of Handle is
Handle(context.Context, Record) error

The context is provided to support applications that provide logging information along the call chain. In a break with usual Go practice, the Handle method should not treat a canceled context as a signal to stop work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, that's a good idea.

@abuchanan-airbyte
Copy link
Collaborator Author

Closed in favor of #139

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