diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/error_tracking | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'lib/error_tracking')
-rw-r--r-- | lib/error_tracking/sentry_client.rb | 10 | ||||
-rw-r--r-- | lib/error_tracking/sentry_client/event.rb | 6 | ||||
-rw-r--r-- | lib/error_tracking/sentry_client/issue.rb | 13 | ||||
-rw-r--r-- | lib/error_tracking/sentry_client/pagination_parser.rb | 2 | ||||
-rw-r--r-- | lib/error_tracking/sentry_client/projects.rb | 4 | ||||
-rw-r--r-- | lib/error_tracking/sentry_client/repo.rb | 2 |
6 files changed, 16 insertions, 21 deletions
diff --git a/lib/error_tracking/sentry_client.rb b/lib/error_tracking/sentry_client.rb index 8d1bcec032d..6a341ddbe86 100644 --- a/lib/error_tracking/sentry_client.rb +++ b/lib/error_tracking/sentry_client.rb @@ -59,10 +59,8 @@ module ErrorTracking end end - def http_request - response = handle_request_exceptions do - yield - end + def http_request(&block) + response = handle_request_exceptions(&block) handle_response(response) end @@ -86,9 +84,7 @@ module ErrorTracking end def handle_response(response) - unless response.code.between?(200, 204) - raise_error "Sentry response status code: #{response.code}" - end + raise_error "Sentry response status code: #{response.code}" unless response.code.between?(200, 204) { body: response.parsed_response, headers: response.headers } end diff --git a/lib/error_tracking/sentry_client/event.rb b/lib/error_tracking/sentry_client/event.rb index 93449344d6c..5343eb7df57 100644 --- a/lib/error_tracking/sentry_client/event.rb +++ b/lib/error_tracking/sentry_client/event.rb @@ -15,14 +15,14 @@ module ErrorTracking stack_trace = parse_stack_trace(event) Gitlab::ErrorTracking::ErrorEvent.new( - issue_id: event.dig('groupID'), - date_received: event.dig('dateReceived'), + issue_id: event['groupID'], + date_received: event['dateReceived'], stack_trace_entries: stack_trace ) end def parse_stack_trace(event) - exception_entry = event.dig('entries')&.detect { |h| h['type'] == 'exception' } + exception_entry = event['entries']&.detect { |h| h['type'] == 'exception' } return [] unless exception_entry exception_values = exception_entry.dig('data', 'values') diff --git a/lib/error_tracking/sentry_client/issue.rb b/lib/error_tracking/sentry_client/issue.rb index 65da072ef8d..d0e6bd783f3 100644 --- a/lib/error_tracking/sentry_client/issue.rb +++ b/lib/error_tracking/sentry_client/issue.rb @@ -54,9 +54,7 @@ module ErrorTracking end def list_issue_sentry_query(issue_status:, limit:, sort: nil, search_term: '', cursor: nil) - unless SENTRY_API_SORT_VALUE_MAP.key?(sort) - raise BadRequestError, 'Invalid value for sort param' - end + raise BadRequestError, 'Invalid value for sort param' unless SENTRY_API_SORT_VALUE_MAP.key?(sort) { query: "is:#{issue_status} #{search_term}".strip, @@ -69,7 +67,8 @@ module ErrorTracking def validate_size(issues) return if Gitlab::Utils::DeepSize.new(issues).valid? - raise ResponseInvalidSizeError, "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}." + message = "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}." + raise ResponseInvalidSizeError, message end def get_issue(issue_id:) @@ -117,7 +116,7 @@ module ErrorTracking end def map_to_errors(issues) - issues.map(&method(:map_to_error)) + issues.map { map_to_error(_1) } end def map_to_error(issue) @@ -142,7 +141,7 @@ module ErrorTracking end def map_to_detailed_error(issue) - Gitlab::ErrorTracking::DetailedError.new({ + Gitlab::ErrorTracking::DetailedError.new( id: issue.fetch('id'), first_seen: issue.fetch('firstSeen', nil), last_seen: issue.fetch('lastSeen', nil), @@ -169,7 +168,7 @@ module ErrorTracking last_release_short_version: issue.dig('lastRelease', 'shortVersion'), last_release_version: issue.dig('lastRelease', 'version'), integrated: false - }) + ) end def extract_tags(issue) diff --git a/lib/error_tracking/sentry_client/pagination_parser.rb b/lib/error_tracking/sentry_client/pagination_parser.rb index 362a5d098f7..c6a42a6def2 100644 --- a/lib/error_tracking/sentry_client/pagination_parser.rb +++ b/lib/error_tracking/sentry_client/pagination_parser.rb @@ -3,7 +3,7 @@ module ErrorTracking class SentryClient module PaginationParser - PATTERN = /rel=\"(?<direction>\w+)\";\sresults=\"(?<results>\w+)\";\scursor=\"(?<cursor>.+)\"/.freeze + PATTERN = /rel="(?<direction>\w+)";\sresults="(?<results>\w+)";\scursor="(?<cursor>.+)"/.freeze def self.parse(headers) links = headers['link'].to_s.split(',') diff --git a/lib/error_tracking/sentry_client/projects.rb b/lib/error_tracking/sentry_client/projects.rb index 9b8daa226b0..a06b44cf29d 100644 --- a/lib/error_tracking/sentry_client/projects.rb +++ b/lib/error_tracking/sentry_client/projects.rb @@ -18,7 +18,7 @@ module ErrorTracking end def map_to_projects(projects) - projects.map(&method(:map_to_project)) + projects.map { map_to_project(_1) } end def map_to_project(project) @@ -28,7 +28,7 @@ module ErrorTracking id: project.fetch('id', nil), name: project.fetch('name'), slug: project.fetch('slug'), - status: project.dig('status'), + status: project['status'], organization_name: organization.fetch('name'), organization_id: organization.fetch('id', nil), organization_slug: organization.fetch('slug') diff --git a/lib/error_tracking/sentry_client/repo.rb b/lib/error_tracking/sentry_client/repo.rb index 3baa7e69be6..4333ca9b3d9 100644 --- a/lib/error_tracking/sentry_client/repo.rb +++ b/lib/error_tracking/sentry_client/repo.rb @@ -23,7 +23,7 @@ module ErrorTracking end def map_to_repos(repos) - repos.map(&method(:map_to_repo)) + repos.map { map_to_repo(_1) } end def map_to_repo(repo) |