mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: more context for error reporting on jobs fails
This commit is contained in:
@@ -119,6 +119,11 @@ module Jobs
|
|||||||
RailsMultisite::ConnectionManagement.all_dbs
|
RailsMultisite::ConnectionManagement.all_dbs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
logster_env = {}
|
||||||
|
Logster.add_to_env(logster_env, :current_db, 'default')
|
||||||
|
Logster.add_to_env(logster_env, :job, self.class.to_s)
|
||||||
|
Thread.current[Logster::Logger::LOGSTER_ENV] = logster_env
|
||||||
|
|
||||||
exceptions = []
|
exceptions = []
|
||||||
dbs.each do |db|
|
dbs.each do |db|
|
||||||
begin
|
begin
|
||||||
@@ -129,6 +134,7 @@ module Jobs
|
|||||||
I18n.locale = SiteSetting.default_locale || "en"
|
I18n.locale = SiteSetting.default_locale || "en"
|
||||||
I18n.ensure_all_loaded!
|
I18n.ensure_all_loaded!
|
||||||
begin
|
begin
|
||||||
|
Logster.add_to_env(logster_env, :db, db)
|
||||||
execute(opts)
|
execute(opts)
|
||||||
rescue => e
|
rescue => e
|
||||||
exception[:ex] = e
|
exception[:ex] = e
|
||||||
@@ -140,6 +146,7 @@ module Jobs
|
|||||||
exception[:other] = { problem_db: db }
|
exception[:other] = { problem_db: db }
|
||||||
ensure
|
ensure
|
||||||
total_db_time += Instrumenter.stats.duration_ms
|
total_db_time += Instrumenter.stats.duration_ms
|
||||||
|
Thread.current[Logster::Logger::LOGSTER_ENV] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -147,6 +154,8 @@ module Jobs
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Thread.current[Logster::Logger::LOGSTER_ENV] = nil
|
||||||
|
|
||||||
if exceptions.length > 0
|
if exceptions.length > 0
|
||||||
exceptions.each do |exception_hash|
|
exceptions.each do |exception_hash|
|
||||||
Discourse.handle_job_exception(exception_hash[:ex], error_context(opts, exception_hash[:code], exception_hash[:other]))
|
Discourse.handle_job_exception(exception_hash[:ex], error_context(opts, exception_hash[:code], exception_hash[:other]))
|
||||||
|
|||||||
Reference in New Issue
Block a user