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

Telemetry should send the failure message #78

Closed
wants to merge 2 commits into from

Conversation

loreto
Copy link
Contributor

@loreto loreto commented Sep 7, 2022

Summary

Telemetry should send the failure message whenever there's an error. That will allow us to understand what the errors are and how to fix them.

How was it tested?

Development version of segment.

@loreto loreto requested review from gcurtis and Lagoja September 7, 2022 15:53
}
if runErr != nil {
evt.Failed = true
evt.FailedMsg = runErr.Error()
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be a good idea to only track a distinct error type so that we can redact errors for analytics. Otherwise I worry that we might return an error with sensitive info somewhere else in the code and accidentally log it.

Maybe something like this?

type RedactedError interface {
	Redact() string
}

func (m *telemetryMiddleware) postRun(cmd *cobra.Command, args []string, runErr error) {
	// ...

	if runErr != nil {
		evt.Failed = true
		if redactErr, ok := runErr.(RedactedError); ok {
			evt.FailedMsg = redactErr.Redact()
		}
	}
}

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 like the idea, but I'm also worried this means we will not capture a bunch of errors as a result. I'm trying to think if there's an in-between.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option is to do redacted format strings.

// Not sure on the naming or if it should go in a new package.
type SafeError struct {
	format string
	args   []any
}

func (e *SafeError) Redacted() string {
	// This is ugly. You could probably do something fancier by substituting
	// the args with something else of the same type. Or use a template string
	// instead of fmt.
	return format
}

func (e *SafeError) Error() string {
	return fmt.Sprintf(e.format, e.args...)
}

@Lagoja Lagoja added this to the 0.0.5 milestone Sep 9, 2022
@loreto loreto removed this from the 0.0.5 milestone Sep 13, 2022
@loreto
Copy link
Contributor Author

loreto commented Dec 2, 2022

Abandoning in favor of Lucille's Sentry implementation.

@loreto loreto closed this Dec 2, 2022
LucilleH added a commit that referenced this pull request Dec 3, 2022
## Summary
This replaces #78

This PR does the following:
1. logs error to sentry. Sentry has built in support for removing
sensitive data.
2. link the telemetry event to the sentry error event id

TODO: update github action environment variables

## How was it tested?
go build
devbox plan (on an invalid project config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants