Module: Gitlab::ErrorTracking
- Defined in:
- lib/gitlab/error_tracking.rb,
lib/gitlab/error_tracking/repo.rb,
lib/gitlab/error_tracking/error.rb,
lib/gitlab/error_tracking/logger.rb,
lib/gitlab/error_tracking/project.rb,
lib/gitlab/error_tracking/error_event.rb,
lib/gitlab/error_tracking/log_formatter.rb,
lib/gitlab/error_tracking/detailed_error.rb,
lib/gitlab/error_tracking/error_collection.rb,
lib/gitlab/error_tracking/error_repository.rb,
lib/gitlab/error_tracking/context_payload_generator.rb,
lib/gitlab/error_tracking/processor/sidekiq_processor.rb,
lib/gitlab/error_tracking/processor/sanitizer_processor.rb,
lib/gitlab/error_tracking/processor/grpc_error_processor.rb,
lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb,
lib/gitlab/error_tracking/error_repository/open_api_strategy.rb,
lib/gitlab/error_tracking/processor/context_payload_processor.rb,
lib/gitlab/error_tracking/processor/concerns/processes_exceptions.rb,
lib/gitlab/error_tracking/processor/sanitize_error_message_processor.rb
Defined Under Namespace
Modules: Processor, StackTraceHighlightDecorator Classes: ContextPayloadGenerator, DetailedError, Error, ErrorCollection, ErrorEvent, ErrorRepository, LogFormatter, Logger, Project, Repo
Constant Summary collapse
- CUSTOM_FINGERPRINTING =
Exceptions in this group will receive custom Sentry fingerprinting
%w[ Acme::Client::Error::BadNonce Acme::Client::Error::NotFound Acme::Client::Error::RateLimited Acme::Client::Error::Timeout Acme::Client::Error::UnsupportedOperation ActiveRecord::ConnectionTimeoutError Gitlab::RequestContext::RequestDeadlineExceeded GRPC::DeadlineExceeded JIRA::HTTPError Rack::Timeout::RequestTimeoutException ].freeze
- PROCESSORS =
[ ::Gitlab::ErrorTracking::Processor::SidekiqProcessor, ::Gitlab::ErrorTracking::Processor::GrpcErrorProcessor, ::Gitlab::ErrorTracking::Processor::ContextPayloadProcessor, ::Gitlab::ErrorTracking::Processor::SanitizeErrorMessageProcessor, # IMPORTANT: this processor must stay at the bottom, right before # sending the event to Sentry. ::Gitlab::ErrorTracking::Processor::SanitizerProcessor ].freeze
Class Method Summary collapse
- .configure ⇒ Object
-
.log_and_raise_exception(exception, extra = {}) ⇒ Object
This should be used when you want to log the exception and passthrough exception handling: rescue and raise to be catched in upper layers of the application.
-
.log_exception(exception, extra = {}) ⇒ Object
This should be used when you only want to log the exception, but not send it to Sentry or raise.
-
.track_and_raise_exception(exception, extra = {}, tags = {}) ⇒ Object
This should be used when you want to passthrough exception handling: rescue and raise to be caught in upper layers of the application.
-
.track_and_raise_for_dev_exception(exception, extra = {}, tags = {}) ⇒ Object
This can be used for investigating exceptions that can be recovered from in code.
-
.track_exception(exception, extra = {}, tags = {}) ⇒ Object
This should be used when you want to track the exception and not raise with the default trackers (Sentry and Logger).
Class Method Details
.configure ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gitlab/error_tracking.rb', line 30 def configure Sentry.init do |config| config.dsn = sentry_dsn config.release = Gitlab.revision config.environment = sentry_environment config.before_send = method(:before_send) config.background_worker_threads = 0 config.send_default_pii = true config.send_modules = false config.traces_sample_rate = 0.2 if Gitlab::Utils.to_boolean(ENV['ENABLE_SENTRY_PERFORMANCE_MONITORING']) # Reason for disabling the below configs https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150771#note_1881953691 config.metrics.enabled = false config.metrics.enable_code_locations = false config.propagate_traces = false config.trace_propagation_targets = [] config.enabled_patches = [:sidekiq_cron] config.enable_tracing = false yield config if block_given? end end |
.log_and_raise_exception(exception, extra = {}) ⇒ Object
This should be used when you want to log the exception and passthrough exception handling: rescue and raise to be catched in upper layers of the application.
If the exception implements the method sentry_extra_data and that method returns a Hash, then the return value of that method will be merged into extra. Exceptions can use this mechanism to provide structured data to sentry in addition to their message and back-trace.
115 116 117 118 119 |
# File 'lib/gitlab/error_tracking.rb', line 115 def log_and_raise_exception(exception, extra = {}) process_exception(exception, extra: extra, trackers: [Logger]) raise exception end |
.log_exception(exception, extra = {}) ⇒ Object
This should be used when you only want to log the exception, but not send it to Sentry or raise.
If the exception implements the method sentry_extra_data and that method returns a Hash, then the return value of that method will be merged into extra. Exceptions can use this mechanism to provide structured data to sentry in addition to their message and back-trace.
103 104 105 |
# File 'lib/gitlab/error_tracking.rb', line 103 def log_exception(exception, extra = {}) process_exception(exception, extra: extra, trackers: [Logger]) end |
.track_and_raise_exception(exception, extra = {}, tags = {}) ⇒ Object
This should be used when you want to passthrough exception handling: rescue and raise to be caught in upper layers of the application.
If the exception implements the method sentry_extra_data and that method returns a Hash, then the return value of that method will be merged into extra. Exceptions can use this mechanism to provide structured data to sentry in addition to their message and back-trace.
59 60 61 62 63 |
# File 'lib/gitlab/error_tracking.rb', line 59 def track_and_raise_exception(exception, extra = {}, = {}) process_exception(exception, extra: extra, tags: ) raise exception end |
.track_and_raise_for_dev_exception(exception, extra = {}, tags = {}) ⇒ Object
This can be used for investigating exceptions that can be recovered from in code. The exception will still be raised in development and test environments.
That way we can track down these exceptions with as much information as we need to resolve them.
If the exception implements the method sentry_extra_data and that method returns a Hash, then the return value of that method will be merged into extra. Exceptions can use this mechanism to provide structured data to sentry in addition to their message and back-trace.
Provide an issue URL for follow up. as ‘issue_url: ’gitlab.com/gitlab-org/gitlab/issues/111’‘
79 80 81 82 83 |
# File 'lib/gitlab/error_tracking.rb', line 79 def track_and_raise_for_dev_exception(exception, extra = {}, = {}) process_exception(exception, extra: extra, tags: ) raise exception if should_raise_for_dev? end |
.track_exception(exception, extra = {}, tags = {}) ⇒ Object
This should be used when you want to track the exception and not raise with the default trackers (Sentry and Logger).
If the exception implements the method sentry_extra_data and that method returns a Hash, then the return value of that method will be merged into extra. Exceptions can use this mechanism to provide structured data to sentry in addition to their message and back-trace.
92 93 94 |
# File 'lib/gitlab/error_tracking.rb', line 92 def track_exception(exception, extra = {}, = {}) process_exception(exception, extra: extra, tags: ) end |