Class: Sentry::Hub
- Includes:
- ArgumentCheckingHelper
- Defined in:
- lib/sentry/hub.rb
Defined Under Namespace
Classes: Layer
Instance Attribute Summary collapse
-
#last_event_id ⇒ Object
readonly
Returns the value of attribute last_event_id.
Instance Method Summary collapse
- #add_breadcrumb(breadcrumb, hint: {}) ⇒ Object
- #bind_client(client) ⇒ Object
- #capture_event(event, **options, &block) ⇒ Object
- #capture_exception(exception, **options, &block) ⇒ Object
- #capture_message(message, **options, &block) ⇒ Object
- #clone ⇒ Object
- #configure_scope(&block) ⇒ Object
- #current_client ⇒ Object
- #current_scope ⇒ Object
-
#initialize(client, scope) ⇒ Hub
constructor
A new instance of Hub.
- #new_from_top ⇒ Object
- #pop_scope ⇒ Object
- #push_scope ⇒ Object
- #start_transaction(transaction: nil, **options) ⇒ Object
- #with_scope(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#last_event_id ⇒ Object (readonly)
Returns the value of attribute last_event_id.
8 9 10 |
# File 'lib/sentry/hub.rb', line 8 def last_event_id @last_event_id end |
Instance Method Details
#add_breadcrumb(breadcrumb, hint: {}) ⇒ Object
123 124 125 126 127 128 129 130 131 |
# File 'lib/sentry/hub.rb', line 123 def (, hint: {}) if = current_client.configuration. = .call(, hint) end return unless current_scope.() end |
#bind_client(client) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/sentry/hub.rb', line 38 def bind_client(client) layer = current_layer if layer layer.client = client end end |
#capture_event(event, **options, &block) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/sentry/hub.rb', line 101 def capture_event(event, **, &block) return unless current_client check_argument_type!(event, Sentry::Event) hint = .delete(:hint) || {} scope = current_scope.dup if block block.call(scope) elsif custom_scope = [:scope] scope.update_from_scope(custom_scope) elsif !.empty? scope.(**) end event = current_client.capture_event(event, scope, hint) @last_event_id = event&.event_id event end |
#capture_exception(exception, **options, &block) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/sentry/hub.rb', line 78 def capture_exception(exception, **, &block) return unless current_client check_argument_type!(exception, ::Exception) [:hint] ||= {} [:hint][:exception] = exception event = current_client.event_from_exception(exception, [:hint]) return unless event capture_event(event, **, &block) end |
#capture_message(message, **options, &block) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/sentry/hub.rb', line 92 def (, **, &block) return unless current_client [:hint] ||= {} [:hint][:message] = event = current_client.(, [:hint]) capture_event(event, **, &block) end |
#clone ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/sentry/hub.rb', line 28 def clone layer = current_layer if layer scope = layer.scope&.dup Hub.new(layer.client, scope) end end |
#configure_scope(&block) ⇒ Object
46 47 48 |
# File 'lib/sentry/hub.rb', line 46 def configure_scope(&block) block.call(current_scope) end |
#current_client ⇒ Object
20 21 22 |
# File 'lib/sentry/hub.rb', line 20 def current_client current_layer&.client end |
#current_scope ⇒ Object
24 25 26 |
# File 'lib/sentry/hub.rb', line 24 def current_scope current_layer&.scope end |
#new_from_top ⇒ Object
16 17 18 |
# File 'lib/sentry/hub.rb', line 16 def new_from_top Hub.new(current_client, current_scope) end |
#pop_scope ⇒ Object
68 69 70 |
# File 'lib/sentry/hub.rb', line 68 def pop_scope @stack.pop end |
#push_scope ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sentry/hub.rb', line 57 def push_scope new_scope = if current_scope current_scope.dup else Scope.new end @stack << Layer.new(current_client, new_scope) end |
#start_transaction(transaction: nil, **options) ⇒ Object
72 73 74 75 76 |
# File 'lib/sentry/hub.rb', line 72 def start_transaction(transaction: nil, **) transaction ||= Transaction.new(**) transaction.set_initial_sample_desicion transaction end |
#with_scope(&block) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/sentry/hub.rb', line 50 def with_scope(&block) push_scope yield(current_scope) ensure pop_scope end |