Class: Bugstack::Client
- Inherits:
-
Object
- Object
- Bugstack::Client
- Defined in:
- lib/bugstack/client.rb
Overview
Core client for capturing and reporting errors to BugStack. Thread-safe. Handles deduplication, filtering, and transport.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#capture_exception(exception, request: nil, metadata: nil) ⇒ Boolean
Capture an exception and send it to BugStack.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
-
#shutdown ⇒ Object
Shut down the client and flush pending events.
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bugstack/client.rb', line 9 def initialize(config) @config = config @deduplicator = Deduplicator.new(window: config.deduplication_window) @transport = nil if config.enabled && !config.dry_run @transport = Transport.new( endpoint: config.endpoint, api_key: config.api_key, timeout: config.timeout, max_retries: config.max_retries, debug: config.debug ) end log_debug("Client initialized (endpoint=#{config.endpoint}, dry_run=#{config.dry_run})") end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/bugstack/client.rb', line 7 def config @config end |
Instance Method Details
#capture_exception(exception, request: nil, metadata: nil) ⇒ Boolean
Capture an exception and send it to BugStack.
33 34 35 36 37 38 |
# File 'lib/bugstack/client.rb', line 33 def capture_exception(exception, request: nil, metadata: nil) do_capture(exception, request: request, metadata: ) rescue => e log_debug("Error during capture: #{e.message}") false end |
#shutdown ⇒ Object
Shut down the client and flush pending events.
41 42 43 44 |
# File 'lib/bugstack/client.rb', line 41 def shutdown @transport&.shutdown @transport = nil end |