Module: Condux

Defined in:
lib/condux.rb,
lib/condux/dsn.rb,
lib/condux/rack.rb,
lib/condux/level.rb,
lib/condux/scope.rb,
lib/condux/client.rb,
lib/condux/test_event.rb,
lib/condux/send_result.rb,
lib/condux/event_payload.rb,
lib/condux/event_transport.rb

Overview

Condux SDK for Ruby — report errors to a Condux relay.

Emits the Sentry "store" wire shape (event_id, timestamp, level, exception.values) so the relay normalizes it exactly like an official Sentry SDK: swap the DSN and it works. Delivery is resilient (429 / 5xx / network failures retry with backoff, honoring Retry-After) and never raises — a failed send returns a SendResult you can inspect. The transport and sleep are injectable so backoff is exercised with no real network or timers. Inspired by common SDK transports, implemented fresh.

Defined Under Namespace

Modules: EventPayload, Level, Rack, Scope, TestEvent Classes: Client, Dsn, EventTransport, SendResult

Class Method Summary collapse

Class Method Details

.add_breadcrumb(message, category: nil, level: nil, type: nil, data: nil, timestamp: nil) ⇒ Object

Record a breadcrumb; the trail (newest last, capped) rides every subsequent event.



58
59
60
61
# File 'lib/condux.rb', line 58

def add_breadcrumb(message, category: nil, level: nil, type: nil, data: nil, timestamp: nil)
  Scope.add_breadcrumb(message, category: category, level: level, type: type, data: data,
                                timestamp: timestamp)
end

.capture_exception(error, handled: true) ⇒ Object

Report an exception as an error-level event, with its stack trace. Never raises on delivery failure. Pass handled: false for an uncaught exception (a framework integration does this).



27
28
29
30
31
32
# File 'lib/condux.rb', line 27

def capture_exception(error, handled: true)
  client = active_client
  return not_initialized unless client

  client.capture_exception(error, handled: handled)
end

.capture_message(message, level: Level::INFO) ⇒ Object

Report a bare message event at the given level (default info).



35
36
37
38
39
40
# File 'lib/condux.rb', line 35

def capture_message(message, level: Level::INFO)
  client = active_client
  return not_initialized unless client

  client.capture_message(message, level)
end

.clear_scopeObject

Reset all ambient enrichment (tests, or a full sign-out).



64
65
66
# File 'lib/condux.rb', line 64

def clear_scope
  Scope.clear
end

.init(dsn:, environment: nil, release: nil, max_retries: Client::DEFAULT_MAX_RETRIES, transport: nil, sleep: nil, clock: nil) ⇒ Object

Configure the SDK with a project DSN (and optional testing hooks). Raises on a malformed DSN: setup runs once at developer time, so a typo is worth failing loudly for.



19
20
21
22
23
# File 'lib/condux.rb', line 19

def init(dsn:, environment: nil, release: nil, max_retries: Client::DEFAULT_MAX_RETRIES,
         transport: nil, sleep: nil, clock: nil)
  @client = Client.new(dsn: dsn, environment: environment, release: release,
                       max_retries: max_retries, transport: transport, sleep: sleep, clock: clock)
end

.set_context(name, context) ⇒ Object

Attach a named context object to subsequent events; nil removes it.



53
54
55
# File 'lib/condux.rb', line 53

def set_context(name, context)
  Scope.set_context(name, context)
end

.set_tag(key, value) ⇒ Object

Attach a tag to subsequent events; a nil value removes it.



48
49
50
# File 'lib/condux.rb', line 48

def set_tag(key, value)
  Scope.set_tag(key, value)
end

.set_user(user) ⇒ Object

Attach the signed-in user (id/email/username) to subsequent events; nil clears.



43
44
45
# File 'lib/condux.rb', line 43

def set_user(user)
  Scope.user = user
end