Module: ActiveJob::Temporal::AuditLog
Constant Summary collapse
- SENSITIVE_ATTRIBUTE_NAMES =
%w[ arguments args cause error error_message exception message payload result target ].freeze
Instance Method Summary collapse
- #activity_attributes_from_payload(payload) ⇒ Object
- #cancelled_error?(error) ⇒ Boolean
- #elapsed_milliseconds(started_at) ⇒ Object
- #error_attributes(error) ⇒ Object
- #job_attributes_from_payload(payload) ⇒ Object
- #monotonic_time ⇒ Object
- #record(event_name, attributes = {}) ⇒ Object
Instance Method Details
#activity_attributes_from_payload(payload) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/activejob/temporal/audit_log.rb', line 44 def activity_attributes_from_payload(payload) job_attributes_from_payload(payload) .merge(activity_context_attributes) .merge(worker_id: ActiveJob::Temporal.config.identity) .compact end |
#cancelled_error?(error) ⇒ Boolean
58 59 60 |
# File 'lib/activejob/temporal/audit_log.rb', line 58 def cancelled_error?(error) defined?(Temporalio::Error::CanceledError) && error.is_a?(Temporalio::Error::CanceledError) end |
#elapsed_milliseconds(started_at) ⇒ Object
62 63 64 |
# File 'lib/activejob/temporal/audit_log.rb', line 62 def elapsed_milliseconds(started_at) ((monotonic_time - started_at) * 1000).round(2) end |
#error_attributes(error) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/activejob/temporal/audit_log.rb', line 51 def error_attributes(error) { error_class: error.class.name, error_fingerprint: error_fingerprint(error) }.compact end |
#job_attributes_from_payload(payload) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/activejob/temporal/audit_log.rb', line 31 def job_attributes_from_payload(payload) payload = payload.to_h attributes = { job_class: value_from(payload, :job_class), job_id: value_from(payload, :job_id), queue: value_from(payload, :queue_name), executions: value_from(payload, :executions), scheduled_at: value_from(payload, :scheduled_at) } attributes.compact end |
#monotonic_time ⇒ Object
66 67 68 |
# File 'lib/activejob/temporal/audit_log.rb', line 66 def monotonic_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
#record(event_name, attributes = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/activejob/temporal/audit_log.rb', line 23 def record(event_name, attributes = {}) config = ActiveJob::Temporal.config return unless config.audit_log logger = config.audit_logger || config.logger Logger.log_to(logger, :info, event_name, sanitized_attributes(attributes)) end |