Skip to content

Conversation

@et
Copy link
Contributor

@et et commented Apr 26, 2023

Summary

This PR adds the ability to filter sessions that do not have an error.

The frontend for this PR adds a new project filter setting that works similar to how we filter Chrome extension errors (see #4890 and #4921).

Screenshot_2023-05-01_at_10_56_43_AM

The backend for this PR introduces a new table, project_filter_settings for storing various filter settings going forward (currently, they're just stuffed on the project model).

The actual filtering works exactly how #5158 describes by simply checking to see if the session has an error.

How did you test this change?

Without setting checked, verified that all sessions are visible regardless if they have an error.

With setting checked

  • session is excluded
  • session is visible when an error is thrown

Are there any deployment considerations?

@et et linked an issue Apr 26, 2023 that may be closed by this pull request
@render
Copy link

render bot commented Apr 26, 2023

Copy link
Member

@Vadman97 Vadman97 left a comment

Choose a reason for hiding this comment

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

could we update ProcessPayload to determine whether a session should be un-excluded on events pushed based on the FilterSessionsWithoutError setting? that way, we won't show the live session in the feed until there is an error

doUpdate := sessionObj.PayloadUpdatedAt == nil ||
now.Sub(*sessionObj.PayloadUpdatedAt) > 15*time.Second ||
beaconTime != nil ||
hasSessionUnloaded != sessionObj.HasUnloaded ||
(sessionObj.Processed != nil && *sessionObj.Processed) ||
(sessionObj.ObjectStorageEnabled != nil && *sessionObj.ObjectStorageEnabled) ||
(sessionObj.Chunked != nil && *sessionObj.Chunked) ||
(sessionObj.Excluded != nil && *sessionObj.Excluded) ||
(sessionHasErrors && (sessionObj.HasErrors == nil || !*sessionObj.HasErrors))
if doUpdate {
fieldsToUpdate := model.Session{
PayloadUpdatedAt: &now, BeaconTime: beaconTime, HasUnloaded: hasSessionUnloaded, Processed: &model.F, ObjectStorageEnabled: &model.F, DirectDownloadEnabled: false, Chunked: &model.F, Excluded: &model.F,
}
// We only want to update the `HasErrors` field if the session has errors.
if sessionHasErrors {
fieldsToUpdate.HasErrors = &model.T
if err := r.DB.Model(&model.Session{Model: model.Model{ID: sessionID}}).
Select("PayloadUpdatedAt", "BeaconTime", "HasUnloaded", "Processed", "ObjectStorageEnabled", "Chunked", "DirectDownloadEnabled", "Excluded", "HasErrors").
Updates(&fieldsToUpdate).Error; err != nil {
log.WithContext(ctx).Error(e.Wrap(err, "error updating session payload time and beacon time with errors"))
return err
}
} else {
if err := r.DB.Model(&model.Session{Model: model.Model{ID: sessionID}}).
Select("PayloadUpdatedAt", "BeaconTime", "HasUnloaded", "Processed", "ObjectStorageEnabled", "Chunked", "DirectDownloadEnabled", "Excluded").
Updates(&fieldsToUpdate).Error; err != nil {
log.WithContext(ctx).Error(e.Wrap(err, "error updating session payload time and beacon time"))
return err
}
}
}

@et et force-pushed the 4980-emsr-only-record-sessions-that-have-errors branch from 34a5686 to a340ef2 Compare May 1, 2023 15:59
@et et changed the title set up project filter settings Filter sessions without an error setting May 1, 2023
@et et marked this pull request as ready for review May 1, 2023 17:06
@et et requested review from a team and ccschmitz and removed request for a team May 1, 2023 17:06
@et et requested review from Vadman97 and removed request for ccschmitz May 4, 2023 21:42
Copy link
Member

@Vadman97 Vadman97 left a comment

Choose a reason for hiding this comment

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

looks good overall! 🚢

@et et enabled auto-merge (squash) May 5, 2023 16:07
@et et merged commit 49f2470 into main May 5, 2023
@et et deleted the 4980-emsr-only-record-sessions-that-have-errors branch May 5, 2023 17:46
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.

EM/SR: only record sessions that have errors

3 participants