Module: Tinymon::EventBuilder
- Defined in:
- lib/tinymon/event_builder.rb
Overview
Pure construction of a wire-format event from a Ruby Exception. Mirrors packages/browser/src/eventBuilder.ts and packages/python/…/event_builder.py.
Constant Summary collapse
- SENSITIVE =
/password|token|secret|auth|card|cvv|ssn/i.freeze
Class Method Summary collapse
- .build(exception, release: nil, environment: nil, user: nil, tags: nil, breadcrumbs: nil, url: nil) ⇒ Object
- .scrub(tags) ⇒ Object
Class Method Details
.build(exception, release: nil, environment: nil, user: nil, tags: nil, breadcrumbs: nil, url: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tinymon/event_builder.rb', line 15 def build(exception, release: nil, environment: nil, user: nil, tags: nil, breadcrumbs: nil, url: nil) event = { "event_id" => SecureRandom.uuid, "timestamp" => Time.now.to_f, "platform" => "ruby", "level" => "error", "sdk" => { "name" => SDK_NAME, "version" => VERSION }, "exception" => { "type" => exception.class.name.to_s, "value" => exception..to_s, "stacktrace" => { "frames" => Stacktrace.parse(exception) }, }, "breadcrumbs" => ( || []).dup, "user" => (user || {}).dup, "tags" => scrub( || {}), } event["release"] = release if release event["environment"] = environment if environment event["request"] = { "url" => url } if url event end |
.scrub(tags) ⇒ Object
37 38 39 40 41 |
# File 'lib/tinymon/event_builder.rb', line 37 def scrub() .each_with_object({}) do |(k, v), out| out[k.to_s] = SENSITIVE.match?(k.to_s) ? "[redacted]" : v end end |