Module: Tinymon

Defined in:
lib/tinymonrb.rb,
lib/tinymon/rack.rb,
lib/tinymon/scope.rb,
lib/tinymon/scrub.rb,
lib/tinymon/client.rb,
lib/tinymon/railtie.rb,
lib/tinymon/version.rb,
lib/tinymon/transport.rb,
lib/tinymon/stacktrace.rb,
lib/tinymon/integrations.rb,
lib/tinymon/event_builder.rb

Overview

Default PII scrub. Identical semantics to the JS SDK and the server. Runs BEFORE before_send so user hooks can both relax and tighten the defaults.

Defined Under Namespace

Modules: EventBuilder, Integrations, Scrub, Stacktrace Classes: Client, Rack, Railtie, Scope, Transport

Constant Summary collapse

SCOPE =

Singleton instance — mirrors the JS/Python SDKs’ module-level scope.

Scope.new
VERSION =
"0.4.0"
SDK_NAME =
"tinymon.ruby"

Class Method Summary collapse

Class Method Details

._build_event(exception, **kwargs) ⇒ Object

Exposed for the cross-language contract test in test/test_contract.rb.



88
89
90
# File 'lib/tinymonrb.rb', line 88

def _build_event(exception, **kwargs)
  EventBuilder.build(exception, **kwargs)
end

.add_breadcrumb(crumb) ⇒ Object



83
84
85
# File 'lib/tinymonrb.rb', line 83

def add_breadcrumb(crumb)
  SCOPE.add_breadcrumb(crumb)
end

.capture_exception(exception) ⇒ Object



55
56
57
# File 'lib/tinymonrb.rb', line 55

def capture_exception(exception)
  @client&.capture_exception(exception)
end

.capture_exception_with_context(exception, request: nil, user: nil, tags: nil) ⇒ Object

Per-event context capture. Use from Rack middleware; do NOT use set_user/set_tag for per-request data (they race under concurrency).



61
62
63
# File 'lib/tinymonrb.rb', line 61

def capture_exception_with_context(exception, request: nil, user: nil, tags: nil)
  @client&.capture_exception_with_context(exception, request: request, user: user, tags: tags)
end

.capture_message(message, level: "info") ⇒ Object



65
66
67
# File 'lib/tinymonrb.rb', line 65

def capture_message(message, level: "info")
  @client&.capture_message(message, level: level)
end

.flush(timeout = 2.0) ⇒ Object

Block until queued events are delivered (or timeout). Call before a short-lived process exits so events aren’t dropped.



71
72
73
# File 'lib/tinymonrb.rb', line 71

def flush(timeout = 2.0)
  @client&.flush(timeout)
end

.init(dsn:, endpoint: nil, environment: nil, release: nil, sample_rate: 1.0, before_send: nil, scrub_url_query: true, scrub_patterns: nil, send_default_pii: false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tinymonrb.rb', line 29

def init(
  dsn:,
  endpoint: nil,
  environment: nil,
  release: nil,
  sample_rate: 1.0,
  before_send: nil,
  scrub_url_query: true,
  scrub_patterns: nil,
  send_default_pii: false
)
  @client = Client.new(
    dsn: dsn,
    endpoint: endpoint,
    environment: environment,
    release: release,
    sample_rate: sample_rate,
    before_send: before_send,
    scrub_url_query: scrub_url_query,
    scrub_patterns: scrub_patterns,
    send_default_pii: send_default_pii,
  )
  Integrations.install(@client)
  @client
end

.set_tag(key, value) ⇒ Object



79
80
81
# File 'lib/tinymonrb.rb', line 79

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

.set_user(user) ⇒ Object



75
76
77
# File 'lib/tinymonrb.rb', line 75

def set_user(user)
  SCOPE.set_user(user)
end