Class: Gitlab::ErrorTracking::ErrorRepository
- Inherits:
-
Object
- Object
- Gitlab::ErrorTracking::ErrorRepository
- Defined in:
- lib/gitlab/error_tracking/error_repository.rb,
lib/gitlab/error_tracking/error_repository/open_api_strategy.rb
Overview
Data access layer for errors and events related to Error Tracking feature.
Defined Under Namespace
Classes: OpenApiStrategy, Pagination
Constant Summary collapse
- DatabaseError =
Generic database error
Class.new(StandardError)
- RecordInvalidError =
Record was invalid
Class.new(DatabaseError)
Class Method Summary collapse
-
.build(project) ⇒ self
Builds an instance of error repository backed by a strategy.
Instance Method Summary collapse
- #dsn_url(public_key) ⇒ Object
-
#find_error(id) ⇒ Gitlab::ErrorTracking::DetailedError
Finds an error by
id
. -
#initialize(strategy) ⇒ ErrorRepository
constructor
A new instance of ErrorRepository.
-
#last_event_for(id) ⇒ Gitlab::ErrorTracking::ErrorEvent
Fetches last event for error
id
. -
#list_errors(sort: 'last_seen', filters: {}, query: nil, limit: 20, cursor: {}) ⇒ Array<Array<Gitlab::ErrorTracking::Error>, Pagination>
Lists errors.
-
#report_error(name:, description:, actor:, platform:, environment:, level:, occurred_at: Time.zone.now, payload: {}) ⇒ void
Stores an error and the related error event.
-
#update_error(id, status:) ⇒ true, false
Updates attributes of an error.
Constructor Details
#initialize(strategy) ⇒ ErrorRepository
Returns a new instance of ErrorRepository.
24 25 26 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 24 def initialize(strategy) @strategy = strategy end |
Class Method Details
.build(project) ⇒ self
Builds an instance of error repository backed by a strategy.
17 18 19 20 21 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 17 def self.build(project) strategy = OpenApiStrategy.new(project) new(strategy) end |
Instance Method Details
#dsn_url(public_key) ⇒ Object
109 110 111 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 109 def dsn_url(public_key) strategy.dsn_url(public_key) end |
#find_error(id) ⇒ Gitlab::ErrorTracking::DetailedError
Finds an error by id
.
66 67 68 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 66 def find_error(id) strategy.find_error(id) end |
#last_event_for(id) ⇒ Gitlab::ErrorTracking::ErrorEvent
Fetches last event for error id
.
93 94 95 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 93 def last_event_for(id) strategy.last_event_for(id) end |
#list_errors(sort: 'last_seen', filters: {}, query: nil, limit: 20, cursor: {}) ⇒ Array<Array<Gitlab::ErrorTracking::Error>, Pagination>
Lists errors.
80 81 82 83 84 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 80 def list_errors(sort: 'last_seen', filters: {}, query: nil, limit: 20, cursor: {}) limit = [limit.to_i, 100].min strategy.list_errors(filters: filters, query: query, sort: sort, limit: limit, cursor: cursor) end |
#report_error(name:, description:, actor:, platform:, environment:, level:, occurred_at: Time.zone.now, payload: {}) ⇒ void
This method returns an undefined value.
Stores an error and the related error event.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 43 def report_error( name:, description:, actor:, platform:, environment:, level:, occurred_at: Time.zone.now, payload: {} ) strategy.report_error( name: name, description: description, actor: actor, platform: platform, environment: environment, level: level, occurred_at: occurred_at, payload: payload ) nil end |
#update_error(id, status:) ⇒ true, false
Updates attributes of an error.
105 106 107 |
# File 'lib/gitlab/error_tracking/error_repository.rb', line 105 def update_error(id, status:) strategy.update_error(id, status: status) end |