diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-15 15:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-15 15:09:01 +0300 |
commit | 01d2d6c8695d03440d68b262806f709b57da63b4 (patch) | |
tree | 2c01be0f6bc018df88062107b42d4b9a6289f8de /app/services/error_tracking | |
parent | 32e53ae7d739e9457ef81ba4a441a3acb4446240 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/error_tracking')
-rw-r--r-- | app/services/error_tracking/collect_error_service.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/services/error_tracking/collect_error_service.rb b/app/services/error_tracking/collect_error_service.rb new file mode 100644 index 00000000000..bc1f238d81f --- /dev/null +++ b/app/services/error_tracking/collect_error_service.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module ErrorTracking + class CollectErrorService < ::BaseService + def execute + # Error is a way to group events based on common data like name or cause + # of exception. We need to keep a sane balance here between taking too little + # and too much data into group logic. + error = project.error_tracking_errors.report_error( + name: exception['type'], # Example: ActionView::MissingTemplate + description: exception['value'], # Example: Missing template posts/show in... + actor: event['transaction'], # Example: PostsController#show + platform: event['platform'], # Example: ruby + timestamp: event['timestamp'] + ) + + # The payload field contains all the data on error including stacktrace in jsonb. + # Together with occured_at these are 2 main attributes that we need to save here. + error.events.create!( + environment: event['environment'], + description: exception['type'], + level: event['level'], + occurred_at: event['timestamp'], + payload: event + ) + end + + private + + def event + params[:event] + end + + def exception + event['exception']['values'].first + end + end +end |