Module: Logister::ActiveJobReporter
- Defined in:
- lib/logister/active_job_reporter.rb
Defined Under Namespace
Modules: Instrumentation
Class Method Summary collapse
- .build_job_error_context(job, started_at:) ⇒ Object
- .install! ⇒ Object
- .serialize_exception_executions(job) ⇒ Object
- .time_to_iso8601(value) ⇒ Object
Class Method Details
.build_job_error_context(job, started_at:) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/logister/active_job_reporter.rb', line 43 def build_job_error_context(job, started_at:) Logister::ContextHelpers.compact_deep( { job: { jobClass: job.class.name.to_s, jobId: job.job_id.to_s.presence, providerJobId: job.provider_job_id.to_s.presence, queue: job.queue_name.to_s.presence, priority: job.priority, executions: job.executions, exceptionExecutions: serialize_exception_executions(job), locale: job.locale.to_s.presence, timezone: (job.respond_to?(:timezone) ? job.timezone.to_s.presence : nil), enqueuedAt: (job.respond_to?(:enqueued_at) ? time_to_iso8601(job.enqueued_at) : nil), scheduledAt: time_to_iso8601(job.scheduled_at), arguments: Logister::ContextHelpers.filtered_job_arguments(job) }.compact, breadcrumbs: Logister::ContextStore..presence, dependencyCalls: Logister::ContextStore.dependencies.presence, runtime: Logister::ContextHelpers.runtime_context[:runtime], deployment: Logister::ContextHelpers.deployment_context[:deployment] } ) end |
.install! ⇒ Object
6 7 8 9 10 11 |
# File 'lib/logister/active_job_reporter.rb', line 6 def self.install! return unless defined?(ActiveJob::Base) return if ActiveJob::Base < Logister::ActiveJobReporter::Instrumentation ActiveJob::Base.include(Logister::ActiveJobReporter::Instrumentation) end |
.serialize_exception_executions(job) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/logister/active_job_reporter.rb', line 68 def serialize_exception_executions(job) raw = job.respond_to?(:exception_executions) ? job.exception_executions : nil return nil if raw.nil? raw.is_a?(Hash) ? raw.transform_keys(&:to_s) : raw end |
.time_to_iso8601(value) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/logister/active_job_reporter.rb', line 75 def time_to_iso8601(value) return nil unless value.respond_to?(:iso8601) value.iso8601 rescue StandardError nil end |