Class: ForgeOpsTracker::EventBuilder
- Inherits:
-
Object
- Object
- ForgeOpsTracker::EventBuilder
- Defined in:
- lib/forge_ops_tracker/event_builder.rb
Overview
Turns a raised exception into the JSON-able payload shape the ingestion
API expects. Backtrace parsing is a simple regex, not a full parser --
good enough for standard MRI backtrace lines across Ruby versions
(both the older in \method'and newerin 'method'` quoting styles).
Constant Summary collapse
- LINE_PATTERN =
/\A(?<file>.+?):(?<line>\d+)(?::in\s+(?<method>.+))?\z/- MAX_FRAMES =
500
Instance Method Summary collapse
- #build(error, context: {}) ⇒ Object
-
#initialize(configuration) ⇒ EventBuilder
constructor
A new instance of EventBuilder.
Constructor Details
#initialize(configuration) ⇒ EventBuilder
Returns a new instance of EventBuilder.
12 13 14 |
# File 'lib/forge_ops_tracker/event_builder.rb', line 12 def initialize(configuration) @configuration = configuration end |
Instance Method Details
#build(error, context: {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/forge_ops_tracker/event_builder.rb', line 16 def build(error, context: {}) payload = { exception_class: error.class.name, message: error..to_s, backtrace: backtrace_frames(error), occurred_at: Time.now.utc.iso8601, environment: configuration.environment.to_s, release: configuration.release, server_name: configuration.server_name, context: context || {}, tags: {} } scrub(payload) end |