Module: Gitlab::ExceptionLogFormatter
- Defined in:
- lib/gitlab/exception_log_formatter.rb
Class Method Summary collapse
- .find_gitaly_metadata(exception) ⇒ Object
- .find_sql(exception) ⇒ Object
- .format!(exception, payload) ⇒ Object
Class Method Details
.find_gitaly_metadata(exception) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/gitlab/exception_log_formatter.rb', line 42 def (exception) if exception.is_a?(::Gitlab::Git::BaseError) exception. elsif exception.is_a?(::GRPC::BadStatus) exception.[::Gitlab::Git::BaseError::METADATA_KEY] elsif exception.cause.present? (exception.cause) end end |
.find_sql(exception) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/exception_log_formatter.rb', line 33 def find_sql(exception) if exception.is_a?(ActiveRecord::StatementInvalid) # StatementInvalid may be caused by a statement timeout or a bad query normalize_query(exception.sql.to_s) elsif exception.cause.present? find_sql(exception.cause) end end |
.format!(exception, payload) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/exception_log_formatter.rb', line 6 def format!(exception, payload) return unless exception # Elasticsearch/Fluentd don't handle nested structures well. # Use periods to flatten the fields. payload.merge!( 'exception.class' => exception.class.name, 'exception.message' => (exception) ) if exception.backtrace payload['exception.backtrace'] = Rails.backtrace_cleaner.clean(exception.backtrace) end if exception.cause payload['exception.cause_class'] = exception.cause.class.name end if = (exception) payload['exception.gitaly'] = .to_s end if sql = find_sql(exception) payload['exception.sql'] = sql end end |