Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-09 12:07:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-09 12:07:51 +0300
commit5afd8575506372dd64c238203bd05b4826f3ae2e (patch)
treee167192fdc7d73fcc1aa5bd33b535b813120ec37 /lib/sentry/client.rb
parent8bda404e2919234c299f088b7d8d04f8449125de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sentry/client.rb')
-rw-r--r--lib/sentry/client.rb108
1 files changed, 0 insertions, 108 deletions
diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb
index e3b8305b664..40821e2b233 100644
--- a/lib/sentry/client.rb
+++ b/lib/sentry/client.rb
@@ -9,14 +9,6 @@ module Sentry
Error = Class.new(StandardError)
MissingKeysError = Class.new(StandardError)
ResponseInvalidSizeError = Class.new(StandardError)
- BadRequestError = Class.new(StandardError)
-
- SENTRY_API_SORT_VALUE_MAP = {
- # <accepted_by_client> => <accepted_by_sentry_api>
- 'frequency' => 'freq',
- 'first_seen' => 'new',
- 'last_seen' => nil
- }.freeze
attr_accessor :url, :token
@@ -25,30 +17,8 @@ module Sentry
@token = token
end
- def list_issues(**keyword_args)
- response = get_issues(keyword_args)
-
- issues = response[:issues]
- pagination = response[:pagination]
-
- validate_size(issues)
-
- handle_mapping_exceptions do
- {
- issues: map_to_errors(issues),
- pagination: pagination
- }
- end
- end
-
private
- 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}."
- end
-
def handle_mapping_exceptions(&block)
yield
rescue KeyError => e
@@ -85,31 +55,6 @@ module Sentry
handle_response(response)
end
- def get_issues(**keyword_args)
- response = http_get(
- issues_api_url,
- query: list_issue_sentry_query(keyword_args)
- )
-
- {
- issues: response[:body],
- pagination: Sentry::PaginationParser.parse(response[:headers])
- }
- 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
-
- {
- query: "is:#{issue_status} #{search_term}".strip,
- limit: limit,
- sort: SENTRY_API_SORT_VALUE_MAP[sort],
- cursor: cursor
- }.compact
- end
-
def handle_request_exceptions
yield
rescue Gitlab::HTTP::Error => e
@@ -139,58 +84,5 @@ module Sentry
def raise_error(message)
raise Client::Error, message
end
-
- def issues_api_url
- issues_url = URI(@url + '/issues/')
- issues_url.path.squeeze!('/')
-
- issues_url
- end
-
- def map_to_errors(issues)
- issues.map(&method(:map_to_error))
- end
-
- def issue_url(id)
- issues_url = @url + "/issues/#{id}"
-
- parse_sentry_url(issues_url)
- end
-
- def project_url
- parse_sentry_url(@url)
- end
-
- def parse_sentry_url(api_url)
- url = ErrorTracking::ProjectErrorTrackingSetting.extract_sentry_external_url(api_url)
-
- uri = URI(url)
- uri.path.squeeze!('/')
- # Remove trailing slash
- uri = uri.to_s.gsub(/\/\z/, '')
-
- uri
- end
-
- def map_to_error(issue)
- Gitlab::ErrorTracking::Error.new(
- id: issue.fetch('id'),
- first_seen: issue.fetch('firstSeen', nil),
- last_seen: issue.fetch('lastSeen', nil),
- title: issue.fetch('title', nil),
- type: issue.fetch('type', nil),
- user_count: issue.fetch('userCount', nil),
- count: issue.fetch('count', nil),
- message: issue.dig('metadata', 'value'),
- culprit: issue.fetch('culprit', nil),
- external_url: issue_url(issue.fetch('id')),
- short_id: issue.fetch('shortId', nil),
- status: issue.fetch('status', nil),
- frequency: issue.dig('stats', '24h'),
- project_id: issue.dig('project', 'id'),
- project_name: issue.dig('project', 'name'),
- project_slug: issue.dig('project', 'slug')
- )
- end
end
end