Class: Watchforge::Client
- Inherits:
-
Object
- Object
- Watchforge::Client
- Defined in:
- lib/watchforge/client.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #capture_check_in(monitor_slug:, status: "ok", monitor_config: nil, check_in_id: nil, environment: nil) ⇒ Object
- #capture_exception(error, extra: nil) ⇒ Object
- #capture_message(message, level: "info", extra: nil) ⇒ Object
-
#initialize(dsn:, environment: "production", release: nil, debug: false) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(dsn:, environment: "production", release: nil, debug: false) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 |
# File 'lib/watchforge/client.rb', line 10 def initialize(dsn:, environment: "production", release: nil, debug: false) @dsn = dsn @environment = environment @release = release @debug = debug @transport = Transport.new(dsn, debug: debug) @context = Context.new end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/watchforge/client.rb', line 8 def context @context end |
Instance Method Details
#capture_check_in(monitor_slug:, status: "ok", monitor_config: nil, check_in_id: nil, environment: nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/watchforge/client.rb', line 34 def capture_check_in(monitor_slug:, status: "ok", monitor_config: nil, check_in_id: nil, environment: nil) check_in_id ||= SecureRandom.uuid if status == "in_progress" payload = { monitor_slug: monitor_slug, status: status, environment: environment || @environment } payload[:monitor_config] = monitor_config if monitor_config payload[:check_in_id] = check_in_id if check_in_id @transport.send_monitor_check_in(payload) check_in_id end |
#capture_exception(error, extra: nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/watchforge/client.rb', line 19 def capture_exception(error, extra: nil) payload = base_event("error", error.) payload[:exception_type] = error.class.name payload[:exception_value] = error. payload[:stacktrace] = { frames: [{ filename: "unknown", function: error.class.name, lineno: 0, in_app: true }] } merge_extra(payload, extra) @transport.send_event(payload) end |
#capture_message(message, level: "info", extra: nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/watchforge/client.rb', line 28 def (, level: "info", extra: nil) payload = base_event(level, ) merge_extra(payload, extra) @transport.send_event(payload) end |