appsignal 4.5.17 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/CLAUDE.md +177 -0
- data/README.md +17 -0
- data/appsignal.gemspec +1 -0
- data/build_matrix.yml +29 -0
- data/lib/appsignal/auth_check.rb +3 -3
- data/lib/appsignal/check_in/cron.rb +1 -1
- data/lib/appsignal/check_in/event.rb +1 -1
- data/lib/appsignal/check_in/scheduler.rb +3 -1
- data/lib/appsignal/check_in.rb +9 -6
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/cli.rb +1 -1
- data/lib/appsignal/config.rb +231 -30
- data/lib/appsignal/custom_marker.rb +3 -3
- data/lib/appsignal/environment.rb +7 -1
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/rom/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/view_component/render_formatter.rb +1 -1
- data/lib/appsignal/event_formatter.rb +41 -3
- data/lib/appsignal/extension.rb +1 -1
- data/lib/appsignal/garbage_collection.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +82 -35
- data/lib/appsignal/helpers/metrics.rb +12 -9
- data/lib/appsignal/hooks/action_cable.rb +1 -1
- data/lib/appsignal/hooks/action_mailer.rb +1 -0
- data/lib/appsignal/hooks/active_job.rb +1 -1
- data/lib/appsignal/hooks/active_support_notifications.rb +1 -1
- data/lib/appsignal/hooks/at_exit.rb +1 -1
- data/lib/appsignal/hooks/celluloid.rb +1 -1
- data/lib/appsignal/hooks/data_mapper.rb +1 -1
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/dry_monitor.rb +1 -1
- data/lib/appsignal/hooks/excon.rb +1 -1
- data/lib/appsignal/hooks/gvl.rb +1 -1
- data/lib/appsignal/hooks/http.rb +1 -1
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/hooks/mri.rb +1 -1
- data/lib/appsignal/hooks/net_http.rb +1 -1
- data/lib/appsignal/hooks/ownership.rb +1 -1
- data/lib/appsignal/hooks/passenger.rb +1 -1
- data/lib/appsignal/hooks/puma.rb +1 -1
- data/lib/appsignal/hooks/que.rb +1 -1
- data/lib/appsignal/hooks/rake.rb +1 -1
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/redis_client.rb +1 -1
- data/lib/appsignal/hooks/resque.rb +1 -1
- data/lib/appsignal/hooks/sequel.rb +2 -1
- data/lib/appsignal/hooks/shoryuken.rb +1 -1
- data/lib/appsignal/hooks/sidekiq.rb +1 -0
- data/lib/appsignal/hooks/unicorn.rb +1 -1
- data/lib/appsignal/hooks/webmachine.rb +1 -1
- data/lib/appsignal/hooks.rb +5 -3
- data/lib/appsignal/integrations/action_cable.rb +1 -1
- data/lib/appsignal/integrations/active_support_notifications.rb +1 -1
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -1
- data/lib/appsignal/integrations/data_mapper.rb +1 -1
- data/lib/appsignal/integrations/delayed_job_plugin.rb +1 -1
- data/lib/appsignal/integrations/dry_monitor.rb +1 -1
- data/lib/appsignal/integrations/excon.rb +1 -1
- data/lib/appsignal/integrations/http.rb +1 -1
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/integrations/net_http.rb +1 -1
- data/lib/appsignal/integrations/object.rb +18 -2
- data/lib/appsignal/integrations/ownership.rb +1 -1
- data/lib/appsignal/integrations/puma.rb +1 -1
- data/lib/appsignal/integrations/que.rb +1 -1
- data/lib/appsignal/integrations/railtie.rb +2 -2
- data/lib/appsignal/integrations/rake.rb +2 -2
- data/lib/appsignal/integrations/redis.rb +1 -1
- data/lib/appsignal/integrations/redis_client.rb +1 -1
- data/lib/appsignal/integrations/resque.rb +2 -2
- data/lib/appsignal/integrations/shoryuken.rb +1 -1
- data/lib/appsignal/integrations/sidekiq.rb +3 -3
- data/lib/appsignal/integrations/unicorn.rb +1 -1
- data/lib/appsignal/integrations/webmachine.rb +1 -1
- data/lib/appsignal/internal_errors.rb +2 -2
- data/lib/appsignal/loaders.rb +1 -1
- data/lib/appsignal/logger.rb +36 -19
- data/lib/appsignal/marker.rb +1 -1
- data/lib/appsignal/probes/gvl.rb +4 -3
- data/lib/appsignal/probes/helpers.rb +1 -1
- data/lib/appsignal/probes/mri.rb +3 -3
- data/lib/appsignal/probes/sidekiq.rb +4 -3
- data/lib/appsignal/probes.rb +20 -15
- data/lib/appsignal/rack.rb +1 -1
- data/lib/appsignal/sample_data.rb +31 -12
- data/lib/appsignal/span.rb +1 -1
- data/lib/appsignal/system.rb +9 -8
- data/lib/appsignal/transaction.rb +72 -52
- data/lib/appsignal/transmitter.rb +1 -1
- data/lib/appsignal/utils.rb +1 -1
- data/lib/appsignal/version.rb +2 -1
- data/lib/appsignal.rb +22 -14
- data/lib/puma/plugin/appsignal.rb +1 -1
- data/sig/appsignal.rbi +2599 -0
- data/sig/appsignal.rbs +2420 -0
- metadata +20 -6
data/sig/appsignal.rbs
ADDED
@@ -0,0 +1,2420 @@
|
|
1
|
+
# AppSignal for Ruby gem's main module.
|
2
|
+
#
|
3
|
+
# Provides method to control the AppSignal instrumentation and the system
|
4
|
+
# agent. Also provides direct access to instrumentation helpers (from
|
5
|
+
# {Appsignal::Helpers::Instrumentation}) and metrics helpers (from
|
6
|
+
# {Appsignal::Helpers::Metrics}) for ease of use.
|
7
|
+
module Appsignal
|
8
|
+
extend Appsignal::Helpers::Metrics
|
9
|
+
extend Appsignal::Helpers::Instrumentation
|
10
|
+
VERSION: String
|
11
|
+
|
12
|
+
# Start the AppSignal integration.
|
13
|
+
#
|
14
|
+
# Starts AppSignal with the given configuration. If no configuration is set
|
15
|
+
# yet it will try to automatically load the configuration using the
|
16
|
+
# environment loaded from environment variables and the currently working
|
17
|
+
# directory.
|
18
|
+
#
|
19
|
+
# This is not required for the automatic integrations AppSignal offers, but
|
20
|
+
# this is required for all non-automatic integrations and pure Ruby
|
21
|
+
# applications. For more information, see our [integrations
|
22
|
+
# list](https://docs.appsignal.com/ruby/integrations/) and our [Integrating
|
23
|
+
# AppSignal](https://docs.appsignal.com/ruby/instrumentation/integrating-appsignal.html)
|
24
|
+
# guide.
|
25
|
+
#
|
26
|
+
# ```ruby
|
27
|
+
# Appsignal.start
|
28
|
+
# ```
|
29
|
+
#
|
30
|
+
# with custom loaded configuration
|
31
|
+
# ```ruby
|
32
|
+
# Appsignal.configure(:production) do |config|
|
33
|
+
# config.ignore_actions = ["My action"]
|
34
|
+
# end
|
35
|
+
# Appsignal.start
|
36
|
+
# ```
|
37
|
+
def self.start: () -> void
|
38
|
+
|
39
|
+
# Stop AppSignal's agent.
|
40
|
+
#
|
41
|
+
# Stops the AppSignal agent. Call this before the end of your program to
|
42
|
+
# make sure the agent is stopped as well.
|
43
|
+
#
|
44
|
+
# _@param_ `called_by` — Name of the thing that requested the agent to be stopped. Will be used in the AppSignal log file.
|
45
|
+
#
|
46
|
+
# ```ruby
|
47
|
+
# Appsignal.start
|
48
|
+
# # Run your application
|
49
|
+
# Appsignal.stop
|
50
|
+
# ```
|
51
|
+
def self.stop: (?String? called_by) -> void
|
52
|
+
|
53
|
+
# Configure the AppSignal Ruby gem using a DSL.
|
54
|
+
#
|
55
|
+
# Pass a block to the configure method to configure the Ruby gem.
|
56
|
+
#
|
57
|
+
# Each config option defined in our docs can be fetched, set and modified
|
58
|
+
# via a helper method in the given block.
|
59
|
+
#
|
60
|
+
# After AppSignal has started using {start}, the configuration can not be
|
61
|
+
# modified. Any calls to this helper will be ignored.
|
62
|
+
#
|
63
|
+
# This helper should not be used to configure multiple environments, like
|
64
|
+
# done in the YAML file. Configure the environment you want active when the
|
65
|
+
# application starts.
|
66
|
+
#
|
67
|
+
# _@param_ `env_param` — The environment to load.
|
68
|
+
#
|
69
|
+
# _@param_ `root_path` — The path to look the `config/appsignal.yml` config file in. Defaults to the current working directory.
|
70
|
+
#
|
71
|
+
# Configure AppSignal for the application
|
72
|
+
# ```ruby
|
73
|
+
# Appsignal.configure do |config|
|
74
|
+
# config.path = "/the/app/path"
|
75
|
+
# config.active = ENV["APP_ACTIVE"] == "true"
|
76
|
+
# config.push_api_key = File.read("appsignal_key.txt").chomp
|
77
|
+
# config.ignore_actions = ENDPOINTS.select { |e| e.public? }.map(&:name)
|
78
|
+
# config.request_headers << "MY_CUSTOM_HEADER"
|
79
|
+
# end
|
80
|
+
# ```
|
81
|
+
#
|
82
|
+
# Configure AppSignal for the application and select the environment
|
83
|
+
# ```ruby
|
84
|
+
# Appsignal.configure(:production) do |config|
|
85
|
+
# config.active = true
|
86
|
+
# end
|
87
|
+
# ```
|
88
|
+
#
|
89
|
+
# Automatically detects the app environment
|
90
|
+
# ```ruby
|
91
|
+
# # Tries to determine the app environment automatically from the
|
92
|
+
# # environment and the libraries it integrates with.
|
93
|
+
# ENV["RACK_ENV"] = "production"
|
94
|
+
#
|
95
|
+
# Appsignal.configure do |config|
|
96
|
+
# config.env # => "production"
|
97
|
+
# end
|
98
|
+
# ```
|
99
|
+
#
|
100
|
+
# Calling configure multiple times for different environments resets the configuration
|
101
|
+
# ```ruby
|
102
|
+
# Appsignal.configure(:development) do |config|
|
103
|
+
# config.ignore_actions = ["My action"]
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# Appsignal.configure(:production) do |config|
|
107
|
+
# config.ignore_actions # => []
|
108
|
+
# end
|
109
|
+
# ```
|
110
|
+
#
|
111
|
+
# Load config without a block
|
112
|
+
# ```ruby
|
113
|
+
# # This will require either ENV vars being set
|
114
|
+
# # or the config/appsignal.yml being present
|
115
|
+
# Appsignal.configure
|
116
|
+
# # Or for the environment given as an argument
|
117
|
+
# Appsignal.configure(:production)
|
118
|
+
# ```
|
119
|
+
#
|
120
|
+
# _@see_ `config`
|
121
|
+
#
|
122
|
+
# _@see_ `Config`
|
123
|
+
#
|
124
|
+
# _@see_ `https://docs.appsignal.com/ruby/configuration.html` — Configuration guide
|
125
|
+
#
|
126
|
+
# _@see_ `https://docs.appsignal.com/ruby/configuration/options.html` — Configuration options
|
127
|
+
def self.configure: (?(String | Symbol)? env_param, ?root_path: String?) ?{ (Appsignal::Config::ConfigDSL config_dsl) -> void } -> void
|
128
|
+
|
129
|
+
def self.forked: () -> void
|
130
|
+
|
131
|
+
# Load an AppSignal integration.
|
132
|
+
#
|
133
|
+
# Load one of the supported integrations via our loader system.
|
134
|
+
# This will set config defaults and integratie with the library if
|
135
|
+
# AppSignal is active upon start.
|
136
|
+
#
|
137
|
+
# _@param_ `integration_name` — Name of the integration to load.
|
138
|
+
#
|
139
|
+
# Load Sinatra integrations
|
140
|
+
# ```ruby
|
141
|
+
# # First load the integration
|
142
|
+
# Appsignal.load(:sinatra)
|
143
|
+
# # Start AppSignal
|
144
|
+
# Appsignal.start
|
145
|
+
# ```
|
146
|
+
#
|
147
|
+
# Load Sinatra integrations and define custom config
|
148
|
+
# ```ruby
|
149
|
+
# # First load the integration
|
150
|
+
# Appsignal.load(:sinatra)
|
151
|
+
#
|
152
|
+
# # Customize config
|
153
|
+
# Appsignal.configure do |config|
|
154
|
+
# config.ignore_actions = ["GET /ping"]
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# # Start AppSignal
|
158
|
+
# Appsignal.start
|
159
|
+
# ```
|
160
|
+
def self.load: ((String | Symbol) integration_name) -> void
|
161
|
+
|
162
|
+
# Returns if the C-extension was loaded properly.
|
163
|
+
#
|
164
|
+
# _@see_ `Extension`
|
165
|
+
def self.extension_loaded?: () -> bool
|
166
|
+
|
167
|
+
# Returns if {.start} has been called before with a valid config to start
|
168
|
+
# AppSignal.
|
169
|
+
#
|
170
|
+
# _@see_ `Extension`
|
171
|
+
def self.started?: () -> bool
|
172
|
+
|
173
|
+
# Returns the active state of the AppSignal integration.
|
174
|
+
#
|
175
|
+
# Conditions apply for AppSignal to be marked as active:
|
176
|
+
#
|
177
|
+
# - There is a config set on the {.config} attribute.
|
178
|
+
# - The set config is active {Config.active?}.
|
179
|
+
# - The AppSignal Extension is loaded {.extension_loaded?}.
|
180
|
+
#
|
181
|
+
# This logic is used within instrument helper such as {.instrument} so it's
|
182
|
+
# not necessary to wrap {.instrument} calls with this method.
|
183
|
+
#
|
184
|
+
# Do this
|
185
|
+
# ```ruby
|
186
|
+
# Appsignal.instrument(..) do
|
187
|
+
# # Do this
|
188
|
+
# end
|
189
|
+
# ```
|
190
|
+
#
|
191
|
+
# Don't do this
|
192
|
+
# ```ruby
|
193
|
+
# if Appsignal.active?
|
194
|
+
# Appsignal.instrument(..) do
|
195
|
+
# # Don't do this
|
196
|
+
# end
|
197
|
+
# end
|
198
|
+
# ```
|
199
|
+
def self.active?: () -> bool
|
200
|
+
|
201
|
+
# Check if the AppSignal Ruby gem has started successfully.
|
202
|
+
#
|
203
|
+
# If it has not (yet) started or encountered an error in the
|
204
|
+
# `config/appsignal.rb` config file during start up that prevented it from
|
205
|
+
# starting, it will raise a {Appsignal::NotStartedError}.
|
206
|
+
#
|
207
|
+
# If there an error raised from the config file, it will include it as the
|
208
|
+
# error cause of the raised error.
|
209
|
+
def self.check_if_started!: () -> void
|
210
|
+
|
211
|
+
# Report a gauge metric.
|
212
|
+
#
|
213
|
+
# _@param_ `name` — The name of the metric.
|
214
|
+
#
|
215
|
+
# _@param_ `value` — The value of the metric.
|
216
|
+
#
|
217
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
218
|
+
#
|
219
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
220
|
+
def self.set_gauge: ((String | Symbol) name, (Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
221
|
+
|
222
|
+
# Report a counter metric.
|
223
|
+
#
|
224
|
+
# _@param_ `name` — The name of the metric.
|
225
|
+
#
|
226
|
+
# _@param_ `value` — The value of the metric.
|
227
|
+
#
|
228
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
229
|
+
#
|
230
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
231
|
+
def self.increment_counter: ((String | Symbol) name, ?(Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
232
|
+
|
233
|
+
# Report a distribution metric.
|
234
|
+
#
|
235
|
+
# _@param_ `name` — The name of the metric.
|
236
|
+
#
|
237
|
+
# _@param_ `value` — The value of the metric.
|
238
|
+
#
|
239
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
240
|
+
#
|
241
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
242
|
+
def self.add_distribution_value: ((String | Symbol) name, (Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
243
|
+
|
244
|
+
# Monitor a block of code with AppSignal.
|
245
|
+
#
|
246
|
+
# This is a helper to create an AppSignal transaction, track any errors
|
247
|
+
# that may occur and complete the transaction.
|
248
|
+
#
|
249
|
+
# This helper is recommended to be used in Ruby scripts and parts of an
|
250
|
+
# app not already instrumented by AppSignal's automatic instrumentations.
|
251
|
+
#
|
252
|
+
# Use this helper in combination with our {.instrument} helper to track
|
253
|
+
# instrumentation events.
|
254
|
+
#
|
255
|
+
# If AppSignal is not active ({Appsignal.active?}) it will still execute
|
256
|
+
# the block, but not create a transaction for it.
|
257
|
+
#
|
258
|
+
# _@param_ `namespace` — The namespace to set on the new transaction. Defaults to the 'web' namespace. This will not update the active transaction's namespace if {.monitor} is called when another transaction is already active.
|
259
|
+
#
|
260
|
+
# _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
|
261
|
+
#
|
262
|
+
# _@return_ — The value of the given block is returned.
|
263
|
+
# Returns `nil` if there already is a transaction active and no block
|
264
|
+
# was given.
|
265
|
+
#
|
266
|
+
# Instrument a block of code
|
267
|
+
# ```ruby
|
268
|
+
# Appsignal.monitor(
|
269
|
+
# :namespace => "my_namespace",
|
270
|
+
# :action => "MyClass#my_method"
|
271
|
+
# ) do
|
272
|
+
# # Some code
|
273
|
+
# end
|
274
|
+
# ```
|
275
|
+
#
|
276
|
+
# Instrument a block of code using the default namespace
|
277
|
+
# ```ruby
|
278
|
+
# Appsignal.monitor(
|
279
|
+
# :action => "MyClass#my_method"
|
280
|
+
# ) do
|
281
|
+
# # Some code
|
282
|
+
# end
|
283
|
+
# ```
|
284
|
+
#
|
285
|
+
# Instrument a block of code with an instrumentation event
|
286
|
+
# ```ruby
|
287
|
+
# Appsignal.monitor(
|
288
|
+
# :namespace => "my_namespace",
|
289
|
+
# :action => "MyClass#my_method"
|
290
|
+
# ) do
|
291
|
+
# Appsignal.instrument("some_event.some_group") do
|
292
|
+
# # Some code
|
293
|
+
# end
|
294
|
+
# end
|
295
|
+
# ```
|
296
|
+
#
|
297
|
+
# Set the action name in the monitor block
|
298
|
+
# ```ruby
|
299
|
+
# Appsignal.monitor(
|
300
|
+
# :action => nil
|
301
|
+
# ) do
|
302
|
+
# # Some code
|
303
|
+
#
|
304
|
+
# Appsignal.set_action("GET /resource/:id")
|
305
|
+
# end
|
306
|
+
# ```
|
307
|
+
#
|
308
|
+
# Set the action name in the monitor block
|
309
|
+
# ```ruby
|
310
|
+
# Appsignal.monitor(
|
311
|
+
# :action => :set_later # Explicit placeholder
|
312
|
+
# ) do
|
313
|
+
# # Some code
|
314
|
+
#
|
315
|
+
# Appsignal.set_action("GET /resource/:id")
|
316
|
+
# end
|
317
|
+
# ```
|
318
|
+
#
|
319
|
+
# Set custom metadata on the transaction
|
320
|
+
# ```ruby
|
321
|
+
# Appsignal.monitor(
|
322
|
+
# :namespace => "my_namespace",
|
323
|
+
# :action => "MyClass#my_method"
|
324
|
+
# ) do
|
325
|
+
# # Some code
|
326
|
+
#
|
327
|
+
# Appsignal.add_tags(:tag1 => "value1", :tag2 => "value2")
|
328
|
+
# Appsignal.add_params(:param1 => "value1", :param2 => "value2")
|
329
|
+
# end
|
330
|
+
# ```
|
331
|
+
#
|
332
|
+
# Call monitor within monitor will do nothing
|
333
|
+
# ```ruby
|
334
|
+
# Appsignal.monitor(
|
335
|
+
# :namespace => "my_namespace",
|
336
|
+
# :action => "MyClass#my_method"
|
337
|
+
# ) do
|
338
|
+
# # This will _not_ update the namespace and action name
|
339
|
+
# Appsignal.monitor(
|
340
|
+
# :namespace => "my_other_namespace",
|
341
|
+
# :action => "MyOtherClass#my_other_method"
|
342
|
+
# ) do
|
343
|
+
# # Some code
|
344
|
+
#
|
345
|
+
# # The reported namespace will be "my_namespace"
|
346
|
+
# # The reported action will be "MyClass#my_method"
|
347
|
+
# end
|
348
|
+
# end
|
349
|
+
# ```
|
350
|
+
#
|
351
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
|
352
|
+
def self.monitor: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
|
353
|
+
|
354
|
+
# Instrument a block of code and stop AppSignal.
|
355
|
+
#
|
356
|
+
# Useful for cases such as one-off scripts where there is no long running
|
357
|
+
# process active and the data needs to be sent after the process exists.
|
358
|
+
#
|
359
|
+
# Acts the same way as {.monitor}. See that method for more
|
360
|
+
# documentation.
|
361
|
+
#
|
362
|
+
# _@param_ `namespace` — The namespace to set on the new transaction. Defaults to the 'web' namespace. This will not update the active transaction's namespace if {.monitor} is called when another transaction is already active.
|
363
|
+
#
|
364
|
+
# _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
|
365
|
+
#
|
366
|
+
# _@return_ — The value of the given block is returned.
|
367
|
+
#
|
368
|
+
# _@see_ `monitor`
|
369
|
+
def self.monitor_and_stop: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
|
370
|
+
|
371
|
+
# Send an error to AppSignal regardless of the context.
|
372
|
+
#
|
373
|
+
# **We recommend using the {#report_error} helper instead.**
|
374
|
+
#
|
375
|
+
# Records and send the exception to AppSignal.
|
376
|
+
#
|
377
|
+
# This instrumentation helper does not require a transaction to be
|
378
|
+
# active, it starts a new transaction by itself.
|
379
|
+
#
|
380
|
+
# Use {.set_error} if your want to add an exception to the current
|
381
|
+
# transaction.
|
382
|
+
#
|
383
|
+
# **Note**: Does not do anything if AppSignal is not active or when the
|
384
|
+
# "error" is not a class extended from Ruby's Exception class.
|
385
|
+
#
|
386
|
+
# _@param_ `error` — The error to send to AppSignal.
|
387
|
+
#
|
388
|
+
# Send an exception
|
389
|
+
# ```ruby
|
390
|
+
# begin
|
391
|
+
# raise "oh no!"
|
392
|
+
# rescue => e
|
393
|
+
# Appsignal.send_error(e)
|
394
|
+
# end
|
395
|
+
# ```
|
396
|
+
#
|
397
|
+
# Add more metadata to transaction
|
398
|
+
# ```ruby
|
399
|
+
# Appsignal.send_error(e) do
|
400
|
+
# Appsignal.set_namespace("my_namespace")
|
401
|
+
# Appsignal.set_action("my_action_name")
|
402
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
403
|
+
# Appsignal.add_tags(:key => "value")
|
404
|
+
# end
|
405
|
+
# ```
|
406
|
+
#
|
407
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
408
|
+
def self.send_error: (Exception error) ?{ (Transaction transaction) -> void } -> void
|
409
|
+
|
410
|
+
# Set an error on the current transaction.
|
411
|
+
#
|
412
|
+
# **We recommend using the {#report_error} helper instead.**
|
413
|
+
#
|
414
|
+
# **Note**: Does not do anything if AppSignal is not active, no
|
415
|
+
# transaction is currently active or when the "error" is not a class
|
416
|
+
# extended from Ruby's Exception class.
|
417
|
+
#
|
418
|
+
# _@param_ `exception` — The error to add to the current transaction.
|
419
|
+
#
|
420
|
+
# Manual instrumentation of set_error.
|
421
|
+
# ```ruby
|
422
|
+
# # Manually starting AppSignal here
|
423
|
+
# # Manually starting a transaction here.
|
424
|
+
# begin
|
425
|
+
# raise "oh no!"
|
426
|
+
# rescue => e
|
427
|
+
# Appsignal.set_error(e)
|
428
|
+
# end
|
429
|
+
# # Manually completing the transaction here.
|
430
|
+
# # Manually stopping AppSignal here
|
431
|
+
# ```
|
432
|
+
#
|
433
|
+
# In a Rails application
|
434
|
+
# ```ruby
|
435
|
+
# class SomeController < ApplicationController
|
436
|
+
# # The AppSignal transaction is created by our integration for you.
|
437
|
+
# def create
|
438
|
+
# # Do something that breaks
|
439
|
+
# rescue => e
|
440
|
+
# Appsignal.set_error(e)
|
441
|
+
# end
|
442
|
+
# end
|
443
|
+
# ```
|
444
|
+
#
|
445
|
+
# Add more metadata to transaction
|
446
|
+
# ```ruby
|
447
|
+
# Appsignal.set_error(e) do
|
448
|
+
# Appsignal.set_namespace("my_namespace")
|
449
|
+
# Appsignal.set_action("my_action_name")
|
450
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
451
|
+
# Appsignal.add_tags(:key => "value")
|
452
|
+
# end
|
453
|
+
# ```
|
454
|
+
#
|
455
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
456
|
+
def self.set_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
|
457
|
+
|
458
|
+
# Report an error to AppSignal.
|
459
|
+
#
|
460
|
+
# If a transaction is currently active, it will report the error on the
|
461
|
+
# current transaction. If no transaction is active, it will report the
|
462
|
+
# error on a new transaction.
|
463
|
+
#
|
464
|
+
# If a transaction is active and the transaction already has an error
|
465
|
+
# reported on it, it will report multiple errors, up to a maximum of 10
|
466
|
+
# errors.
|
467
|
+
#
|
468
|
+
# If a block is given to this method, the metadata set in this block will
|
469
|
+
# only be applied to the transaction created for the given error. The
|
470
|
+
# block will be called when the transaction is completed, which can be
|
471
|
+
# much later than when {#report_error} is called.
|
472
|
+
#
|
473
|
+
# **Note**: If AppSignal is not active, no error is reported.
|
474
|
+
#
|
475
|
+
# **Note**: If the given exception argument is not an Exception subclass,
|
476
|
+
# it will not be reported.
|
477
|
+
#
|
478
|
+
# _@param_ `exception` — The error to add to the current transaction.
|
479
|
+
#
|
480
|
+
# ```ruby
|
481
|
+
# class SomeController < ApplicationController
|
482
|
+
# def create
|
483
|
+
# # Do something that breaks
|
484
|
+
# rescue => error
|
485
|
+
# Appsignal.report_error(error)
|
486
|
+
# end
|
487
|
+
# end
|
488
|
+
# ```
|
489
|
+
#
|
490
|
+
# Add more metadata to transaction
|
491
|
+
# ```ruby
|
492
|
+
# Appsignal.report_error(error) do
|
493
|
+
# Appsignal.set_namespace("my_namespace")
|
494
|
+
# Appsignal.set_action("my_action_name")
|
495
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
496
|
+
# Appsignal.add_tags(:key => "value")
|
497
|
+
# end
|
498
|
+
# ```
|
499
|
+
#
|
500
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
501
|
+
def self.report_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
|
502
|
+
|
503
|
+
# Set a custom action name for the current transaction.
|
504
|
+
#
|
505
|
+
# When using an integration such as the Rails or Sinatra AppSignal will
|
506
|
+
# try to find the action name from the controller or endpoint for you.
|
507
|
+
#
|
508
|
+
# If you want to customize the action name as it appears on AppSignal.com
|
509
|
+
# you can use this method. This overrides the action name AppSignal
|
510
|
+
# generates in an integration.
|
511
|
+
#
|
512
|
+
# _@param_ `action`
|
513
|
+
#
|
514
|
+
# in a Rails controller
|
515
|
+
# ```ruby
|
516
|
+
# class SomeController < ApplicationController
|
517
|
+
# before_action :set_appsignal_action
|
518
|
+
#
|
519
|
+
# def set_appsignal_action
|
520
|
+
# Appsignal.set_action("DynamicController#dynamic_method")
|
521
|
+
# end
|
522
|
+
# end
|
523
|
+
# ```
|
524
|
+
def self.set_action: (String action) -> void
|
525
|
+
|
526
|
+
# Set a custom namespace for the current transaction.
|
527
|
+
#
|
528
|
+
# When using an integration such as Rails or Sidekiq AppSignal will try
|
529
|
+
# to find a appropriate namespace for the transaction.
|
530
|
+
#
|
531
|
+
# A Rails controller will be automatically put in the "http_request"
|
532
|
+
# namespace, while a Sidekiq background job is put in the
|
533
|
+
# "background_job" namespace.
|
534
|
+
#
|
535
|
+
# Note: The "http_request" namespace gets transformed on AppSignal.com to
|
536
|
+
# "Web" and "background_job" gets transformed to "Background".
|
537
|
+
#
|
538
|
+
# If you want to customize the namespace in which transactions appear you
|
539
|
+
# can use this method. This overrides the namespace AppSignal uses by
|
540
|
+
# default.
|
541
|
+
#
|
542
|
+
# A common request we've seen is to split the administration panel from
|
543
|
+
# the main application.
|
544
|
+
#
|
545
|
+
# _@param_ `namespace`
|
546
|
+
#
|
547
|
+
# create a custom admin namespace
|
548
|
+
# ```ruby
|
549
|
+
# class AdminController < ApplicationController
|
550
|
+
# before_action :set_appsignal_namespace
|
551
|
+
#
|
552
|
+
# def set_appsignal_namespace
|
553
|
+
# Appsignal.set_namespace("admin")
|
554
|
+
# end
|
555
|
+
# end
|
556
|
+
# ```
|
557
|
+
#
|
558
|
+
# _@see_ `https://docs.appsignal.com/guides/namespaces.html` — Grouping with namespaces guide
|
559
|
+
def self.set_namespace: (String namespace) -> void
|
560
|
+
|
561
|
+
# Add custom data to the current transaction.
|
562
|
+
#
|
563
|
+
# Add extra information about the request or background that cannot be
|
564
|
+
# expressed in tags, like nested data structures.
|
565
|
+
#
|
566
|
+
# If the root data type changes between calls of this method, the last
|
567
|
+
# method call is stored.
|
568
|
+
#
|
569
|
+
# _@param_ `data` — Custom data to add to the transaction.
|
570
|
+
#
|
571
|
+
# Add Hash data
|
572
|
+
# ```ruby
|
573
|
+
# Appsignal.add_custom_data(:user => { :locale => "en" })
|
574
|
+
# ```
|
575
|
+
#
|
576
|
+
# Merges Hash data
|
577
|
+
# ```ruby
|
578
|
+
# Appsignal.add_custom_data(:abc => "def")
|
579
|
+
# Appsignal.add_custom_data(:xyz => "...")
|
580
|
+
# # The custom data is: { :abc => "def", :xyz => "..." }
|
581
|
+
# ```
|
582
|
+
#
|
583
|
+
# Add Array data
|
584
|
+
# ```ruby
|
585
|
+
# Appsignal.add_custom_data([
|
586
|
+
# "array with data",
|
587
|
+
# "other value",
|
588
|
+
# :options => { :verbose => true }
|
589
|
+
# ])
|
590
|
+
# ```
|
591
|
+
#
|
592
|
+
# Merges Array data
|
593
|
+
# ```ruby
|
594
|
+
# Appsignal.add_custom_data([1, 2, 3])
|
595
|
+
# Appsignal.add_custom_data([4, 5, 6])
|
596
|
+
# # The custom data is: [1, 2, 3, 4, 5, 6]
|
597
|
+
# ```
|
598
|
+
#
|
599
|
+
# Mixing of root data types is not supported
|
600
|
+
# ```ruby
|
601
|
+
# Appsignal.add_custom_data(:abc => "def")
|
602
|
+
# Appsignal.add_custom_data([1, 2, 3])
|
603
|
+
# # The custom data is: [1, 2, 3]
|
604
|
+
# ```
|
605
|
+
#
|
606
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
607
|
+
def self.add_custom_data: ((::Hash[Object, Object] | ::Array[Object]) data) -> void
|
608
|
+
|
609
|
+
# Add tags to the current transaction.
|
610
|
+
#
|
611
|
+
# Tags are extra bits of information that are added to transaction and
|
612
|
+
# appear on sample details pages on AppSignal.com.
|
613
|
+
#
|
614
|
+
# When this method is called multiple times, it will merge the tags.
|
615
|
+
#
|
616
|
+
# _@param_ `tags` — Collection of tags to add to the transaction.
|
617
|
+
#
|
618
|
+
# ```ruby
|
619
|
+
# Appsignal.add_tags(:locale => "en", :user_id => 1)
|
620
|
+
# Appsignal.add_tags("locale" => "en")
|
621
|
+
# Appsignal.add_tags("user_id" => 1)
|
622
|
+
# ```
|
623
|
+
#
|
624
|
+
# Nested hashes are not supported
|
625
|
+
# ```ruby
|
626
|
+
# # Bad
|
627
|
+
# Appsignal.add_tags(:user => { :locale => "en" })
|
628
|
+
# ```
|
629
|
+
#
|
630
|
+
# in a Rails controller
|
631
|
+
# ```ruby
|
632
|
+
# class SomeController < ApplicationController
|
633
|
+
# before_action :add_appsignal_tags
|
634
|
+
#
|
635
|
+
# def add_appsignal_tags
|
636
|
+
# Appsignal.add_tags(:locale => I18n.locale)
|
637
|
+
# end
|
638
|
+
# end
|
639
|
+
# ```
|
640
|
+
#
|
641
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/tagging.html` — Tagging guide
|
642
|
+
def self.add_tags: (?::Hash[Object, Object] tags) -> void
|
643
|
+
|
644
|
+
# Add parameters to the current transaction.
|
645
|
+
#
|
646
|
+
# Parameters are automatically added by most of our integrations. It
|
647
|
+
# should not be necessary to call this method unless you want to report
|
648
|
+
# different parameters.
|
649
|
+
#
|
650
|
+
# This method accepts both Hash and Array parameter types:
|
651
|
+
# - Hash parameters will be merged when called multiple times
|
652
|
+
# - Array parameters will be concatenated when called multiple times
|
653
|
+
# - Mixing Hash and Array types will use the latest type (and log a warning)
|
654
|
+
#
|
655
|
+
# To filter parameters, see our parameter filtering guide.
|
656
|
+
#
|
657
|
+
# When both the `params` argument and a block is given to this method,
|
658
|
+
# the block is leading and the argument will _not_ be used.
|
659
|
+
#
|
660
|
+
# _@param_ `params` — The parameters to add to the transaction.
|
661
|
+
#
|
662
|
+
# Add Hash parameters
|
663
|
+
# ```ruby
|
664
|
+
# Appsignal.add_params("param1" => "value1")
|
665
|
+
# # The parameters include: { "param1" => "value1" }
|
666
|
+
# ```
|
667
|
+
#
|
668
|
+
# Add Array parameters
|
669
|
+
# ```ruby
|
670
|
+
# Appsignal.add_params(["item1", "item2"])
|
671
|
+
# # The parameters include: ["item1", "item2"]
|
672
|
+
# ```
|
673
|
+
#
|
674
|
+
# Calling `add_params` multiple times with Hashes merges values
|
675
|
+
# ```ruby
|
676
|
+
# Appsignal.add_params("param1" => "value1")
|
677
|
+
# Appsignal.add_params("param2" => "value2")
|
678
|
+
# # The parameters include:
|
679
|
+
# # { "param1" => "value1", "param2" => "value2" }
|
680
|
+
# ```
|
681
|
+
#
|
682
|
+
# Calling `add_params` multiple times with Arrays concatenates values
|
683
|
+
# ```ruby
|
684
|
+
# Appsignal.add_params(["item1"])
|
685
|
+
# Appsignal.add_params(["item2"])
|
686
|
+
# # The parameters include: ["item1", "item2"]
|
687
|
+
# ```
|
688
|
+
#
|
689
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
690
|
+
#
|
691
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-parameters.html` — Parameter filtering guide
|
692
|
+
def self.add_params: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
|
693
|
+
|
694
|
+
# Mark the parameters sample data to be set as an empty value.
|
695
|
+
#
|
696
|
+
# Use this helper to unset request parameters / background job arguments
|
697
|
+
# and not report any for this transaction.
|
698
|
+
#
|
699
|
+
# If parameters would normally be added by AppSignal instrumentations of
|
700
|
+
# libraries, these parameters will not be added to the Transaction.
|
701
|
+
#
|
702
|
+
# Calling {#add_params} after this helper will add new parameters to the
|
703
|
+
# transaction.
|
704
|
+
#
|
705
|
+
# _@see_ `Transaction#set_empty_params!`
|
706
|
+
#
|
707
|
+
# _@see_ `Transaction#set_params_if_nil`
|
708
|
+
def self.set_empty_params!: () -> void
|
709
|
+
|
710
|
+
# Add session data to the current transaction.
|
711
|
+
#
|
712
|
+
# Session data is automatically added by most of our integrations. It
|
713
|
+
# should not be necessary to call this method unless you want to report
|
714
|
+
# different session data.
|
715
|
+
#
|
716
|
+
# To filter session data, see our session data filtering guide.
|
717
|
+
#
|
718
|
+
# When both the `session_data` argument and a block is given to this
|
719
|
+
# method, the bock is leading and the argument will _not_ be used.
|
720
|
+
#
|
721
|
+
# _@param_ `session_data` — The session data to add to the transaction.
|
722
|
+
#
|
723
|
+
# Add session data
|
724
|
+
# ```ruby
|
725
|
+
# Appsignal.add_session_data("session" => "data")
|
726
|
+
# # The session data will include:
|
727
|
+
# # { "session" => "data" }
|
728
|
+
# ```
|
729
|
+
#
|
730
|
+
# Calling `add_session_data` multiple times merge the values
|
731
|
+
# ```ruby
|
732
|
+
# Appsignal.add_session_data("session" => "data")
|
733
|
+
# Appsignal.add_session_data("other" => "value")
|
734
|
+
# # The session data will include:
|
735
|
+
# # { "session" => "data", "other" => "value" }
|
736
|
+
# ```
|
737
|
+
#
|
738
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
739
|
+
#
|
740
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-session-data.html` — Session data filtering guide
|
741
|
+
def self.add_session_data: (?::Hash[String, Object]? session_data) ?{ () -> ::Hash[String, Object] } -> void
|
742
|
+
|
743
|
+
# Add request headers to the current transaction.
|
744
|
+
#
|
745
|
+
# Request headers are automatically added by most of our integrations. It
|
746
|
+
# should not be necessary to call this method unless you want to also
|
747
|
+
# report different request headers.
|
748
|
+
#
|
749
|
+
# To filter request headers, see our request header filtering guide.
|
750
|
+
#
|
751
|
+
# When both the `request_headers` argument and a block is given to this
|
752
|
+
# method, the block is leading and the argument will _not_ be used.
|
753
|
+
#
|
754
|
+
# _@param_ `headers` — The request headers to add to the transaction.
|
755
|
+
#
|
756
|
+
# Add request headers
|
757
|
+
# ```ruby
|
758
|
+
# Appsignal.add_headers("PATH_INFO" => "/some-path")
|
759
|
+
# # The request headers will include:
|
760
|
+
# # { "PATH_INFO" => "/some-path" }
|
761
|
+
# ```
|
762
|
+
#
|
763
|
+
# Calling `add_headers` multiple times merge the values
|
764
|
+
# ```ruby
|
765
|
+
# Appsignal.add_headers("PATH_INFO" => "/some-path")
|
766
|
+
# Appsignal.add_headers("HTTP_USER_AGENT" => "Firefox")
|
767
|
+
# # The request headers will include:
|
768
|
+
# # { "PATH_INFO" => "/some-path", "HTTP_USER_AGENT" => "Firefox" }
|
769
|
+
# ```
|
770
|
+
#
|
771
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
772
|
+
#
|
773
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
|
774
|
+
def self.add_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
|
775
|
+
|
776
|
+
# Add breadcrumbs to the transaction.
|
777
|
+
#
|
778
|
+
# Breadcrumbs can be used to trace what path a user has taken
|
779
|
+
# before encountering an error.
|
780
|
+
#
|
781
|
+
# Only the last 20 added breadcrumbs will be saved.
|
782
|
+
#
|
783
|
+
# _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
|
784
|
+
#
|
785
|
+
# _@param_ `action` — name of breadcrumb e.g "The user clicked a button", "HTTP 500 from http://blablabla.com"
|
786
|
+
#
|
787
|
+
# _@param_ `message` — optional message in string format
|
788
|
+
#
|
789
|
+
# _@param_ `metadata` — key/value metadata in <string, string> format
|
790
|
+
#
|
791
|
+
# _@param_ `time` — time of breadcrumb, should respond to `.to_i` defaults to `Time.now.utc`
|
792
|
+
#
|
793
|
+
# ```ruby
|
794
|
+
# Appsignal.add_breadcrumb(
|
795
|
+
# "Navigation",
|
796
|
+
# "http://blablabla.com",
|
797
|
+
# "",
|
798
|
+
# { :response => 200 },
|
799
|
+
# Time.now.utc
|
800
|
+
# )
|
801
|
+
# Appsignal.add_breadcrumb(
|
802
|
+
# "Network",
|
803
|
+
# "[GET] http://blablabla.com",
|
804
|
+
# "",
|
805
|
+
# { :response => 500 }
|
806
|
+
# )
|
807
|
+
# Appsignal.add_breadcrumb(
|
808
|
+
# "UI",
|
809
|
+
# "closed modal(change_password)",
|
810
|
+
# "User closed modal without actions"
|
811
|
+
# )
|
812
|
+
# ```
|
813
|
+
#
|
814
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/breadcrumbs.html` — Breadcrumb reference
|
815
|
+
def self.add_breadcrumb: (
|
816
|
+
String category,
|
817
|
+
String action,
|
818
|
+
?String message,
|
819
|
+
?::Hash[String, String] metadata,
|
820
|
+
?Time time
|
821
|
+
) -> void
|
822
|
+
|
823
|
+
# Instrument helper for AppSignal.
|
824
|
+
#
|
825
|
+
# For more help, read our custom instrumentation guide, listed under "See
|
826
|
+
# also".
|
827
|
+
#
|
828
|
+
# _@param_ `name` — Name of the instrumented event. Read our event naming guide listed under "See also".
|
829
|
+
#
|
830
|
+
# _@param_ `title` — Human readable name of the event.
|
831
|
+
#
|
832
|
+
# _@param_ `body` — Value of importance for the event, such as the server against an API call is made.
|
833
|
+
#
|
834
|
+
# _@param_ `body_format` — Enum for the type of event that is instrumented. Accepted values are {EventFormatter::DEFAULT} and {EventFormatter::SQL_BODY_FORMAT}, but we recommend you use {.instrument_sql} instead of {EventFormatter::SQL_BODY_FORMAT}.
|
835
|
+
#
|
836
|
+
# _@return_ — Returns the block's return value.
|
837
|
+
#
|
838
|
+
# Simple instrumentation
|
839
|
+
# ```ruby
|
840
|
+
# Appsignal.instrument("fetch.issue_fetcher") do
|
841
|
+
# # To be instrumented code
|
842
|
+
# end
|
843
|
+
# ```
|
844
|
+
#
|
845
|
+
# Instrumentation with title and body
|
846
|
+
# ```ruby
|
847
|
+
# Appsignal.instrument(
|
848
|
+
# "fetch.issue_fetcher",
|
849
|
+
# "Fetching issue",
|
850
|
+
# "GitHub API"
|
851
|
+
# ) do
|
852
|
+
# # To be instrumented code
|
853
|
+
# end
|
854
|
+
# ```
|
855
|
+
#
|
856
|
+
# _@see_ `.instrument_sql`
|
857
|
+
#
|
858
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
|
859
|
+
#
|
860
|
+
# _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
|
861
|
+
def self.instrument: (
|
862
|
+
String name,
|
863
|
+
?String? title,
|
864
|
+
?String? body,
|
865
|
+
?Integer body_format
|
866
|
+
) -> Object
|
867
|
+
|
868
|
+
# Instrumentation helper for SQL queries.
|
869
|
+
#
|
870
|
+
# This helper filters out values from SQL queries so you don't have to.
|
871
|
+
#
|
872
|
+
# _@param_ `name` — Name of the instrumented event. Read our event naming guide listed under "See also".
|
873
|
+
#
|
874
|
+
# _@param_ `title` — Human readable name of the event.
|
875
|
+
#
|
876
|
+
# _@param_ `body` — SQL query that's being executed.
|
877
|
+
#
|
878
|
+
# _@return_ — Returns the block's return value.
|
879
|
+
#
|
880
|
+
# SQL query instrumentation
|
881
|
+
# ```ruby
|
882
|
+
# body = "SELECT * FROM ..."
|
883
|
+
# Appsignal.instrument_sql("perform.query", nil, body) do
|
884
|
+
# # To be instrumented code
|
885
|
+
# end
|
886
|
+
# ```
|
887
|
+
#
|
888
|
+
# SQL query instrumentation
|
889
|
+
# ```ruby
|
890
|
+
# body = "WHERE email = 'foo@..'"
|
891
|
+
# Appsignal.instrument_sql("perform.query", nil, body) do
|
892
|
+
# # query value will replace 'foo..' with a question mark `?`.
|
893
|
+
# end
|
894
|
+
# ```
|
895
|
+
#
|
896
|
+
# _@see_ `.instrument`
|
897
|
+
#
|
898
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
|
899
|
+
#
|
900
|
+
# _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
|
901
|
+
def self.instrument_sql: (String name, ?String? title, ?String? body) -> Object
|
902
|
+
|
903
|
+
# Convenience method for ignoring instrumentation events in a block of
|
904
|
+
# code.
|
905
|
+
#
|
906
|
+
# - This helper ignores events, like those created
|
907
|
+
# `Appsignal.instrument`, within this block.
|
908
|
+
# This includes custom instrumentation and events recorded by AppSignal
|
909
|
+
# integrations for requests, database queries, view rendering, etc.
|
910
|
+
# - The time spent in the block is still reported on the transaction.
|
911
|
+
# - Errors and metrics are reported from within this block.
|
912
|
+
#
|
913
|
+
# _@return_ — Returns the return value of the block.
|
914
|
+
# Return nil if the block returns nil or no block is given.
|
915
|
+
#
|
916
|
+
# ```ruby
|
917
|
+
# Appsignal.instrument "my_event.my_group" do
|
918
|
+
# # Complex code here
|
919
|
+
# end
|
920
|
+
# Appsignal.ignore_instrumentation_events do
|
921
|
+
# Appsignal.instrument "my_ignored_event.my_ignored_group" do
|
922
|
+
# # Complex code here
|
923
|
+
# end
|
924
|
+
# end
|
925
|
+
#
|
926
|
+
# # Only the "my_event.my_group" instrumentation event is reported.
|
927
|
+
# ```
|
928
|
+
#
|
929
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/ignore-instrumentation.html` — Ignore instrumentation guide
|
930
|
+
def self.ignore_instrumentation_events: () ?{ () -> Object } -> Object?
|
931
|
+
|
932
|
+
# The loaded AppSignal configuration.
|
933
|
+
# Returns the current AppSignal configuration.
|
934
|
+
#
|
935
|
+
# Can return `nil` if no configuration has been set or automatically loaded
|
936
|
+
# by an automatic integration or by calling {.start}.
|
937
|
+
#
|
938
|
+
# ```ruby
|
939
|
+
# Appsignal.config
|
940
|
+
# ```
|
941
|
+
#
|
942
|
+
# _@see_ `configure`
|
943
|
+
#
|
944
|
+
# _@see_ `Config`
|
945
|
+
def self.config: () -> Config?
|
946
|
+
|
947
|
+
# Returns the error that was encountered while loading the `appsignal.rb`
|
948
|
+
# config file.
|
949
|
+
#
|
950
|
+
# It does not include any error that occurred while loading the
|
951
|
+
# `appsignal.yml` file.
|
952
|
+
#
|
953
|
+
# If the value is `nil`, no error was encountered or AppSignal wasn't
|
954
|
+
# started yet.
|
955
|
+
def self.config_error: () -> Exception?
|
956
|
+
|
957
|
+
# {Appsignal::Demo} is a way to send demonstration / test samples for a
|
958
|
+
# exception and a performance issue.
|
959
|
+
#
|
960
|
+
# @example Send example transactions
|
961
|
+
# Appsignal::Demo.transmit
|
962
|
+
#
|
963
|
+
# @since 2.0.0
|
964
|
+
# @see Appsignal::CLI::Demo
|
965
|
+
# @api private
|
966
|
+
class Demo
|
967
|
+
# Starts AppSignal and transmits the demonstration samples to AppSignal
|
968
|
+
# using the loaded configuration.
|
969
|
+
#
|
970
|
+
# _@return_ — - returns `false` if Appsignal is not active.
|
971
|
+
def self.transmit: () -> bool
|
972
|
+
|
973
|
+
# Error type used to create demonstration exception.
|
974
|
+
class TestError < StandardError
|
975
|
+
end
|
976
|
+
end
|
977
|
+
|
978
|
+
class Config
|
979
|
+
# Check if the configuration is valid.
|
980
|
+
#
|
981
|
+
# _@return_ — True if the configuration is valid, false otherwise.
|
982
|
+
def valid?: () -> bool
|
983
|
+
|
984
|
+
# Check if AppSignal is active for the current environment.
|
985
|
+
#
|
986
|
+
# _@return_ — True if active for the current environment.
|
987
|
+
def active_for_env?: () -> bool
|
988
|
+
|
989
|
+
# Check if AppSignal is active.
|
990
|
+
#
|
991
|
+
# _@return_ — True if valid and active for the current environment.
|
992
|
+
def active?: () -> bool
|
993
|
+
|
994
|
+
def yml_config_file?: () -> bool
|
995
|
+
|
996
|
+
# Configuration DSL for use in configuration blocks.
|
997
|
+
#
|
998
|
+
# This class provides a Domain Specific Language for configuring AppSignal
|
999
|
+
# within the `Appsignal.configure` block. It provides getter and setter
|
1000
|
+
# methods for all configuration options.
|
1001
|
+
#
|
1002
|
+
# @example Using the configuration DSL
|
1003
|
+
# Appsignal.configure do |config|
|
1004
|
+
# config.name = "My App"
|
1005
|
+
# config.active = true
|
1006
|
+
# config.push_api_key = "your-api-key"
|
1007
|
+
# config.ignore_actions = ["StatusController#health"]
|
1008
|
+
# end
|
1009
|
+
#
|
1010
|
+
# @see AppSignal Ruby gem configuration
|
1011
|
+
# https://docs.appsignal.com/ruby/configuration.html
|
1012
|
+
class ConfigDSL
|
1013
|
+
# Returns the application's root path.
|
1014
|
+
#
|
1015
|
+
# _@return_ — The root path of the application
|
1016
|
+
def app_path: () -> String
|
1017
|
+
|
1018
|
+
# Returns the current environment name.
|
1019
|
+
#
|
1020
|
+
# _@return_ — The environment name (e.g., "production", "development")
|
1021
|
+
def env: () -> String
|
1022
|
+
|
1023
|
+
# Returns true if the given environment name matches the loaded
|
1024
|
+
# environment name.
|
1025
|
+
#
|
1026
|
+
# _@param_ `given_env`
|
1027
|
+
def env?: ((String | Symbol) given_env) -> (TrueClass | FalseClass)
|
1028
|
+
|
1029
|
+
# Activates AppSignal if the current environment matches any of the given environments.
|
1030
|
+
#
|
1031
|
+
# _@param_ `envs` — List of environment names to activate for
|
1032
|
+
#
|
1033
|
+
# _@return_ — true if AppSignal was activated, false otherwise
|
1034
|
+
#
|
1035
|
+
# Activate for production and staging
|
1036
|
+
# ```ruby
|
1037
|
+
# config.activate_if_environment(:production, :staging)
|
1038
|
+
# ```
|
1039
|
+
def activate_if_environment: (*::Array[(String | Symbol)] envs) -> bool
|
1040
|
+
|
1041
|
+
# _@return_ — Error reporting mode for ActiveJob ("all", "discard" or "none")
|
1042
|
+
attr_accessor activejob_report_errors: String
|
1043
|
+
|
1044
|
+
# _@return_ — The application name
|
1045
|
+
attr_accessor name: String
|
1046
|
+
|
1047
|
+
# _@return_ — The host to the agent binds to for its HTTP server
|
1048
|
+
attr_accessor bind_address: String
|
1049
|
+
|
1050
|
+
# _@return_ — Path to the CA certificate file
|
1051
|
+
attr_accessor ca_file_path: String
|
1052
|
+
|
1053
|
+
# _@return_ — Override for the detected hostname
|
1054
|
+
attr_accessor hostname: String
|
1055
|
+
|
1056
|
+
# _@return_ — Role of the host for grouping in metrics
|
1057
|
+
attr_accessor host_role: String
|
1058
|
+
|
1059
|
+
# _@return_ — HTTP proxy URL
|
1060
|
+
attr_accessor http_proxy: String
|
1061
|
+
|
1062
|
+
# _@return_ — Log destination ("file" or "stdout")
|
1063
|
+
attr_accessor log: String
|
1064
|
+
|
1065
|
+
# _@return_ — AppSignal internal logger
|
1066
|
+
# log level ("error", "warn", "info", "debug", "trace")
|
1067
|
+
attr_accessor log_level: String
|
1068
|
+
|
1069
|
+
# _@return_ — Path to the log directory
|
1070
|
+
attr_accessor log_path: String
|
1071
|
+
|
1072
|
+
# _@return_ — Endpoint for log transmission
|
1073
|
+
attr_accessor logging_endpoint: String
|
1074
|
+
|
1075
|
+
# _@return_ — Push API endpoint URL
|
1076
|
+
attr_accessor endpoint: String
|
1077
|
+
|
1078
|
+
# _@return_ — AppSignal Push API key
|
1079
|
+
attr_accessor push_api_key: String
|
1080
|
+
|
1081
|
+
# _@return_ — Error reporting mode for Sidekiq ("all", "discard" or "none")
|
1082
|
+
attr_accessor sidekiq_report_errors: String
|
1083
|
+
|
1084
|
+
# _@return_ — Port for StatsD metrics
|
1085
|
+
attr_accessor statsd_port: String
|
1086
|
+
|
1087
|
+
# _@return_ — Port for Nginx metrics collection
|
1088
|
+
attr_accessor nginx_port: String
|
1089
|
+
|
1090
|
+
# _@return_ — Override for the agent working directory
|
1091
|
+
attr_accessor working_directory_path: String
|
1092
|
+
|
1093
|
+
# _@return_ — Application revision identifier
|
1094
|
+
attr_accessor revision: String
|
1095
|
+
|
1096
|
+
# _@return_ — Activate AppSignal for the loaded environment
|
1097
|
+
attr_accessor active: bool
|
1098
|
+
|
1099
|
+
# _@return_ — Configure whether allocation tracking is enabled
|
1100
|
+
attr_accessor enable_allocation_tracking: bool
|
1101
|
+
|
1102
|
+
# _@return_ — Configure whether the at_exit reporter is enabled
|
1103
|
+
attr_accessor enable_at_exit_reporter: bool
|
1104
|
+
|
1105
|
+
# _@return_ — Configure whether host metrics collection is enabled
|
1106
|
+
attr_accessor enable_host_metrics: bool
|
1107
|
+
|
1108
|
+
# _@return_ — Configure whether minutely probes are enabled
|
1109
|
+
attr_accessor enable_minutely_probes: bool
|
1110
|
+
|
1111
|
+
# _@return_ — Configure whether the StatsD metrics endpoint on the agent is enabled
|
1112
|
+
attr_accessor enable_statsd: bool
|
1113
|
+
|
1114
|
+
# _@return_ — Configure whether the agent's NGINX metrics endpoint is enabled
|
1115
|
+
attr_accessor enable_nginx_metrics: bool
|
1116
|
+
|
1117
|
+
# _@return_ — Configure whether the GVL global timer instrumentationis enabled
|
1118
|
+
attr_accessor enable_gvl_global_timer: bool
|
1119
|
+
|
1120
|
+
# _@return_ — Configure whether GVL waiting threads instrumentation is enabled
|
1121
|
+
attr_accessor enable_gvl_waiting_threads: bool
|
1122
|
+
|
1123
|
+
# _@return_ — Configure whether Rails error reporter integration is enabled
|
1124
|
+
attr_accessor enable_rails_error_reporter: bool
|
1125
|
+
|
1126
|
+
# _@return_ — Configure whether Rake performance instrumentation is enabled
|
1127
|
+
attr_accessor enable_rake_performance_instrumentation: bool
|
1128
|
+
|
1129
|
+
# _@return_ — Configure whether files created by AppSignal should be world accessible
|
1130
|
+
attr_accessor files_world_accessible: bool
|
1131
|
+
|
1132
|
+
# _@return_ — Configure whether to instrument requests made with the http.rb gem
|
1133
|
+
attr_accessor instrument_http_rb: bool
|
1134
|
+
|
1135
|
+
# _@return_ — Configure whether to instrument requests made with Net::HTTP
|
1136
|
+
attr_accessor instrument_net_http: bool
|
1137
|
+
|
1138
|
+
# _@return_ — Configure whether to instrument the Ownership gem
|
1139
|
+
attr_accessor instrument_ownership: bool
|
1140
|
+
|
1141
|
+
# _@return_ — Configure whether to instrument Redis queries
|
1142
|
+
attr_accessor instrument_redis: bool
|
1143
|
+
|
1144
|
+
# _@return_ — Configure whether to instrument Sequel queries
|
1145
|
+
attr_accessor instrument_sequel: bool
|
1146
|
+
|
1147
|
+
# _@return_ — Configure whether the Ownership gem instrumentation should set namespace
|
1148
|
+
attr_accessor ownership_set_namespace: bool
|
1149
|
+
|
1150
|
+
# _@return_ — Configure whether the application is running in a container
|
1151
|
+
attr_accessor running_in_container: bool
|
1152
|
+
|
1153
|
+
# _@return_ — Configure whether to send environment metadata
|
1154
|
+
attr_accessor send_environment_metadata: bool
|
1155
|
+
|
1156
|
+
# _@return_ — Configure whether to send request parameters
|
1157
|
+
attr_accessor send_params: bool
|
1158
|
+
|
1159
|
+
# _@return_ — Configure whether to send request session data
|
1160
|
+
attr_accessor send_session_data: bool
|
1161
|
+
|
1162
|
+
# _@return_ — Custom DNS servers to use
|
1163
|
+
attr_accessor dns_servers: ::Array[String]
|
1164
|
+
|
1165
|
+
# _@return_ — Metadata keys to filter from trace data
|
1166
|
+
attr_accessor filter_metadata: ::Array[String]
|
1167
|
+
|
1168
|
+
# _@return_ — Keys of parameter to filter
|
1169
|
+
attr_accessor filter_parameters: ::Array[String]
|
1170
|
+
|
1171
|
+
# _@return_ — Request session data keys to filter
|
1172
|
+
attr_accessor filter_session_data: ::Array[String]
|
1173
|
+
|
1174
|
+
# _@return_ — Ignore traces by action names
|
1175
|
+
attr_accessor ignore_actions: ::Array[String]
|
1176
|
+
|
1177
|
+
# _@return_ — List of errors to not report
|
1178
|
+
attr_accessor ignore_errors: ::Array[String]
|
1179
|
+
|
1180
|
+
# _@return_ — Ignore log messages by substrings
|
1181
|
+
attr_accessor ignore_logs: ::Array[String]
|
1182
|
+
|
1183
|
+
# _@return_ — Ignore traces by namespaces
|
1184
|
+
attr_accessor ignore_namespaces: ::Array[String]
|
1185
|
+
|
1186
|
+
# _@return_ — HTTP request headers to include in error reports
|
1187
|
+
attr_accessor request_headers: ::Array[String]
|
1188
|
+
|
1189
|
+
# _@return_ — CPU count override for metrics collection
|
1190
|
+
attr_accessor cpu_count: Float
|
1191
|
+
end
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
# Logger that flushes logs to the AppSignal logging service.
|
1195
|
+
#
|
1196
|
+
# @see https://docs.appsignal.com/logging/platforms/integrations/ruby.html
|
1197
|
+
# AppSignal Ruby logging documentation.
|
1198
|
+
class Logger < ::Logger
|
1199
|
+
# Create a new logger instance
|
1200
|
+
#
|
1201
|
+
# _@param_ `group` — Name of the group for this logger.
|
1202
|
+
#
|
1203
|
+
# _@param_ `level` — Minimum log level to report. Log lines below this level will be ignored.
|
1204
|
+
#
|
1205
|
+
# _@param_ `format` — Format to use to parse log line attributes.
|
1206
|
+
#
|
1207
|
+
# _@param_ `attributes` — Default attributes for all log lines.
|
1208
|
+
def initialize: (
|
1209
|
+
String group,
|
1210
|
+
?level: Integer,
|
1211
|
+
?format: Integer,
|
1212
|
+
?attributes: ::Hash[String, String]
|
1213
|
+
) -> void
|
1214
|
+
|
1215
|
+
# Sets the formatter for this logger and all broadcasted loggers.
|
1216
|
+
#
|
1217
|
+
# _@param_ `formatter` — The formatter to use for log messages.
|
1218
|
+
def formatter=: (Proc formatter) -> Proc
|
1219
|
+
|
1220
|
+
# Log a debug level message
|
1221
|
+
#
|
1222
|
+
# _@param_ `message` — Message to log
|
1223
|
+
#
|
1224
|
+
# _@param_ `attributes` — Attributes to tag the log with
|
1225
|
+
def debug: (?String? message, ?::Hash[String, Object] attributes) -> void
|
1226
|
+
|
1227
|
+
# Log an info level message
|
1228
|
+
#
|
1229
|
+
# _@param_ `message` — Message to log
|
1230
|
+
#
|
1231
|
+
# _@param_ `attributes` — Attributes to tag the log with
|
1232
|
+
def info: (?String? message, ?::Hash[String, Object] attributes) -> void
|
1233
|
+
|
1234
|
+
# Log a warn level message
|
1235
|
+
#
|
1236
|
+
# _@param_ `message` — Message to log
|
1237
|
+
#
|
1238
|
+
# _@param_ `attributes` — Attributes to tag the log with
|
1239
|
+
def warn: (?String? message, ?::Hash[String, Object] attributes) -> void
|
1240
|
+
|
1241
|
+
# Log an error level message
|
1242
|
+
#
|
1243
|
+
# _@param_ `message` — Message to log
|
1244
|
+
#
|
1245
|
+
# _@param_ `attributes` — Attributes to tag the log with
|
1246
|
+
def error: (?(String | Exception)? message, ?::Hash[String, Object] attributes) -> void
|
1247
|
+
|
1248
|
+
# Log a fatal level message
|
1249
|
+
#
|
1250
|
+
# _@param_ `message` — Message to log
|
1251
|
+
#
|
1252
|
+
# _@param_ `attributes` — Attributes to tag the log with
|
1253
|
+
def fatal: (?(String | Exception)? message, ?::Hash[String, Object] attributes) -> void
|
1254
|
+
|
1255
|
+
# Log an info level message
|
1256
|
+
#
|
1257
|
+
# Returns the number of characters written.
|
1258
|
+
#
|
1259
|
+
# _@param_ `message` — Message to log
|
1260
|
+
def <<: (String message) -> Integer
|
1261
|
+
|
1262
|
+
# Temporarily silences the logger to a specified level while executing a block.
|
1263
|
+
#
|
1264
|
+
# When using ActiveSupport::TaggedLogging without the broadcast feature,
|
1265
|
+
# the passed logger is required to respond to the `silence` method.
|
1266
|
+
#
|
1267
|
+
# Reference links:
|
1268
|
+
#
|
1269
|
+
# - https://github.com/rails/rails/blob/e11ebc04cfbe41c06cdfb70ee5a9fdbbd98bb263/activesupport/lib/active_support/logger.rb#L60-L76
|
1270
|
+
# - https://github.com/rails/rails/blob/e11ebc04cfbe41c06cdfb70ee5a9fdbbd98bb263/activesupport/lib/active_support/logger_silence.rb
|
1271
|
+
#
|
1272
|
+
# _@param_ `severity` — The minimum severity level to log during the block.
|
1273
|
+
#
|
1274
|
+
# _@return_ — The return value of the block.
|
1275
|
+
def silence: (?Integer severity) -> Object
|
1276
|
+
|
1277
|
+
# Adds a logger to broadcast log messages to.
|
1278
|
+
#
|
1279
|
+
# _@param_ `logger` — The logger to add to the broadcast list.
|
1280
|
+
def broadcast_to: (Logger logger) -> ::Array[Logger]
|
1281
|
+
|
1282
|
+
# Logging severity threshold
|
1283
|
+
attr_reader level: Integer
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
module Probes
|
1287
|
+
# Register a new minutely probe.
|
1288
|
+
#
|
1289
|
+
# Supported probe types are:
|
1290
|
+
#
|
1291
|
+
# - Lambda - A lambda is an object that listens to a `call` method call.
|
1292
|
+
# This `call` method is called every minute.
|
1293
|
+
# - Class - A class object is an object that listens to a `new` and
|
1294
|
+
# `call` method call. The `new` method is called when the minutely
|
1295
|
+
# probe thread is started to initialize all probes. This allows probes
|
1296
|
+
# to load dependencies once beforehand. Their `call` method is called
|
1297
|
+
# every minute.
|
1298
|
+
# - Class instance - A class instance object is an object that listens to
|
1299
|
+
# a `call` method call. The `call` method is called every minute.
|
1300
|
+
#
|
1301
|
+
# _@param_ `name` — Name of the probe. Can be used with {ProbeCollection#[]}. This name will be used in errors in the log and allows overwriting of probes by registering new ones with the same name.
|
1302
|
+
#
|
1303
|
+
# _@param_ `probe` — Any object that listens to the `call` method will be used as a probe.
|
1304
|
+
#
|
1305
|
+
# Register a new probe
|
1306
|
+
# ```ruby
|
1307
|
+
# Appsignal::Probes.register :my_probe, lambda {}
|
1308
|
+
# ```
|
1309
|
+
#
|
1310
|
+
# Overwrite an existing registered probe
|
1311
|
+
# ```ruby
|
1312
|
+
# Appsignal::Probes.register :my_probe, lambda {}
|
1313
|
+
# Appsignal::Probes.register :my_probe, lambda { puts "hello" }
|
1314
|
+
# ```
|
1315
|
+
#
|
1316
|
+
# Add a lambda as a probe
|
1317
|
+
# ```ruby
|
1318
|
+
# Appsignal::Probes.register :my_probe, lambda { puts "hello" }
|
1319
|
+
# # "hello" # printed every minute
|
1320
|
+
# ```
|
1321
|
+
#
|
1322
|
+
# Add a probe instance
|
1323
|
+
# ```ruby
|
1324
|
+
# class MyProbe
|
1325
|
+
# def initialize
|
1326
|
+
# puts "started"
|
1327
|
+
# end
|
1328
|
+
#
|
1329
|
+
# def call
|
1330
|
+
# puts "called"
|
1331
|
+
# end
|
1332
|
+
# end
|
1333
|
+
#
|
1334
|
+
# Appsignal::Probes.register :my_probe, MyProbe.new
|
1335
|
+
# # "started" # printed immediately
|
1336
|
+
# # "called" # printed every minute
|
1337
|
+
# ```
|
1338
|
+
#
|
1339
|
+
# Add a probe class
|
1340
|
+
# ```ruby
|
1341
|
+
# class MyProbe
|
1342
|
+
# def initialize
|
1343
|
+
# # Add things that only need to be done on start up for this probe
|
1344
|
+
# require "some/library/dependency"
|
1345
|
+
# @cache = {} # initialize a local cache variable
|
1346
|
+
# puts "started"
|
1347
|
+
# end
|
1348
|
+
#
|
1349
|
+
# def call
|
1350
|
+
# puts "called"
|
1351
|
+
# end
|
1352
|
+
# end
|
1353
|
+
#
|
1354
|
+
# Appsignal::Probes.register :my_probe, MyProbe
|
1355
|
+
# Appsignal::Probes.start # This is called for you
|
1356
|
+
# # "started" # Printed on Appsignal::Probes.start
|
1357
|
+
# # "called" # Repeated every minute
|
1358
|
+
# ```
|
1359
|
+
def self.register: ((Symbol | String) name, Object probe) -> void
|
1360
|
+
|
1361
|
+
# Unregister a probe that's registered with {register}.
|
1362
|
+
# Can also be used to unregister automatically registered probes by the
|
1363
|
+
# gem.
|
1364
|
+
#
|
1365
|
+
# _@param_ `name` — Name of the probe used to {register} the probe.
|
1366
|
+
#
|
1367
|
+
# Unregister probes
|
1368
|
+
# ```ruby
|
1369
|
+
# # First register a probe
|
1370
|
+
# Appsignal::Probes.register :my_probe, lambda {}
|
1371
|
+
#
|
1372
|
+
# # Then unregister a probe if needed
|
1373
|
+
# Appsignal::Probes.unregister :my_probe
|
1374
|
+
# ```
|
1375
|
+
def self.unregister: ((Symbol | String) name) -> void
|
1376
|
+
|
1377
|
+
def self.start: () -> void
|
1378
|
+
|
1379
|
+
# Returns if the probes thread has been started. If the value is false or
|
1380
|
+
# nil, it has not been started yet.
|
1381
|
+
def self.started?: () -> bool?
|
1382
|
+
|
1383
|
+
# Stop the minutely probes mechanism. Stop the thread and clear all probe
|
1384
|
+
# instances.
|
1385
|
+
def self.stop: () -> void
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
module CheckIn
|
1389
|
+
# Track cron check-ins.
|
1390
|
+
#
|
1391
|
+
# Track the execution of scheduled processes by sending a cron check-in.
|
1392
|
+
#
|
1393
|
+
# To track the duration of a piece of code, pass a block to {.cron}
|
1394
|
+
# to report both when the process starts, and when it finishes.
|
1395
|
+
#
|
1396
|
+
# If an exception is raised within the block, the finish event will not
|
1397
|
+
# be reported, triggering a notification about the missing cron check-in.
|
1398
|
+
# The exception will bubble outside of the cron check-in block.
|
1399
|
+
#
|
1400
|
+
# _@param_ `identifier` — identifier of the cron check-in to report.
|
1401
|
+
#
|
1402
|
+
# _@return_ — returns the block value.
|
1403
|
+
#
|
1404
|
+
# Send a cron check-in
|
1405
|
+
# ```ruby
|
1406
|
+
# Appsignal::CheckIn.cron("send_invoices")
|
1407
|
+
# ```
|
1408
|
+
#
|
1409
|
+
# Send a cron check-in with duration
|
1410
|
+
# ```ruby
|
1411
|
+
# Appsignal::CheckIn.cron("send_invoices") do
|
1412
|
+
# # your code
|
1413
|
+
# end
|
1414
|
+
# ```
|
1415
|
+
#
|
1416
|
+
# _@see_ `https://docs.appsignal.com/check-ins/cron`
|
1417
|
+
def self.cron: (String identifier) ?{ () -> Object } -> Object
|
1418
|
+
|
1419
|
+
# Track heartbeat check-ins.
|
1420
|
+
#
|
1421
|
+
# Track the execution of long-lived processes by sending a heartbeat
|
1422
|
+
# check-in.
|
1423
|
+
#
|
1424
|
+
# _@param_ `identifier` — identifier of the heartbeat check-in to report.
|
1425
|
+
#
|
1426
|
+
# _@param_ `continuous` — whether the heartbeats should be sent continuously during the lifetime of the process. Defaults to `false`.
|
1427
|
+
#
|
1428
|
+
# Send a heartbeat check-in
|
1429
|
+
# ```ruby
|
1430
|
+
# Appsignal::CheckIn.heartbeat("main_loop")
|
1431
|
+
# ```
|
1432
|
+
#
|
1433
|
+
# _@see_ `https://docs.appsignal.com/check-ins/heartbeat`
|
1434
|
+
def self.heartbeat: (String identifier, ?continuous: bool) -> void
|
1435
|
+
end
|
1436
|
+
|
1437
|
+
class Transaction
|
1438
|
+
HTTP_REQUEST: String
|
1439
|
+
BACKGROUND_JOB: String
|
1440
|
+
|
1441
|
+
# Create a new transaction and set it as the currently active
|
1442
|
+
# transaction.
|
1443
|
+
#
|
1444
|
+
# _@param_ `namespace` — Namespace of the to be created transaction.
|
1445
|
+
def self.create: (String namespace) -> Transaction
|
1446
|
+
|
1447
|
+
# Returns currently active transaction or a {NilTransaction} if none is
|
1448
|
+
# active.
|
1449
|
+
#
|
1450
|
+
# _@see_ `.current?`
|
1451
|
+
def self.current: () -> (Appsignal::Transaction | Appsignal::Transaction::NilTransaction)
|
1452
|
+
|
1453
|
+
# Returns if any transaction is currently active or not. A
|
1454
|
+
# {NilTransaction} is not considered an active transaction.
|
1455
|
+
#
|
1456
|
+
# _@see_ `.current`
|
1457
|
+
def self.current?: () -> bool
|
1458
|
+
|
1459
|
+
# Complete the currently active transaction and unset it as the active
|
1460
|
+
# transaction.
|
1461
|
+
def self.complete_current!: () -> void
|
1462
|
+
|
1463
|
+
# Add parameters to the transaction.
|
1464
|
+
#
|
1465
|
+
# When this method is called multiple times, it will merge the request parameters.
|
1466
|
+
#
|
1467
|
+
# When both the `given_params` and a block is given to this method, the
|
1468
|
+
# block is leading and the argument will _not_ be used.
|
1469
|
+
#
|
1470
|
+
# _@param_ `given_params` — The parameters to set on the transaction.
|
1471
|
+
#
|
1472
|
+
# _@see_ `Helpers::Instrumentation#add_params`
|
1473
|
+
#
|
1474
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
1475
|
+
def add_params: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
|
1476
|
+
|
1477
|
+
# Add tags to the transaction.
|
1478
|
+
#
|
1479
|
+
# When this method is called multiple times, it will merge the tags.
|
1480
|
+
#
|
1481
|
+
# _@param_ `given_tags` — Collection of tags.
|
1482
|
+
#
|
1483
|
+
# _@see_ `Helpers::Instrumentation#add_tags`
|
1484
|
+
#
|
1485
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/tagging.html` — Tagging guide
|
1486
|
+
def add_tags: (?::Hash[String, Object] given_tags) -> void
|
1487
|
+
|
1488
|
+
# Add session data to the transaction.
|
1489
|
+
#
|
1490
|
+
# When this method is called multiple times, it will merge the session data.
|
1491
|
+
#
|
1492
|
+
# When both the `given_session_data` and a block is given to this method,
|
1493
|
+
# the block is leading and the argument will _not_ be used.
|
1494
|
+
#
|
1495
|
+
# _@param_ `given_session_data` — A hash containing session data.
|
1496
|
+
#
|
1497
|
+
# _@see_ `Helpers::Instrumentation#add_session_data`
|
1498
|
+
#
|
1499
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
1500
|
+
def add_session_data: (?::Hash[String, Object]? given_session_data) ?{ () -> ::Hash[String, Object] } -> void
|
1501
|
+
|
1502
|
+
# Add headers to the transaction.
|
1503
|
+
#
|
1504
|
+
# _@param_ `given_headers` — A hash containing headers.
|
1505
|
+
#
|
1506
|
+
# _@see_ `Helpers::Instrumentation#add_headers`
|
1507
|
+
#
|
1508
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
1509
|
+
def add_headers: (?::Hash[String, Object]? given_headers) ?{ () -> ::Hash[String, Object] } -> void
|
1510
|
+
|
1511
|
+
# Add custom data to the transaction.
|
1512
|
+
#
|
1513
|
+
# _@param_ `data` — Custom data to add to the transaction.
|
1514
|
+
#
|
1515
|
+
# _@see_ `Helpers::Instrumentation#add_custom_data`
|
1516
|
+
#
|
1517
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
1518
|
+
def add_custom_data: ((::Hash[Object, Object] | ::Array[Object]) data) -> void
|
1519
|
+
|
1520
|
+
# Add breadcrumbs to the transaction.
|
1521
|
+
#
|
1522
|
+
# _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
|
1523
|
+
#
|
1524
|
+
# _@param_ `action` — name of breadcrumb e.g "The user clicked a button", "HTTP 500 from http://blablabla.com"
|
1525
|
+
#
|
1526
|
+
# _@param_ `message` — optional message in string format
|
1527
|
+
#
|
1528
|
+
# _@param_ `metadata` — key/value metadata in <string, string> format
|
1529
|
+
#
|
1530
|
+
# _@param_ `time` — time of breadcrumb, should respond to `.to_i` defaults to `Time.now.utc`
|
1531
|
+
#
|
1532
|
+
# _@see_ `Appsignal.add_breadcrumb`
|
1533
|
+
#
|
1534
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/breadcrumbs.html` — Breadcrumb reference
|
1535
|
+
def add_breadcrumb: (
|
1536
|
+
String category,
|
1537
|
+
String action,
|
1538
|
+
?String message,
|
1539
|
+
?::Hash[String, String] metadata,
|
1540
|
+
?Time time
|
1541
|
+
) -> void
|
1542
|
+
|
1543
|
+
# Set an action name for the transaction.
|
1544
|
+
#
|
1545
|
+
# An action name is used to identify the location of a certain sample;
|
1546
|
+
# error and performance issues.
|
1547
|
+
#
|
1548
|
+
# _@param_ `action` — the action name to set.
|
1549
|
+
#
|
1550
|
+
# _@see_ `Appsignal::Helpers::Instrumentation#set_action`
|
1551
|
+
def set_action: (String action) -> void
|
1552
|
+
|
1553
|
+
# Set the namespace for this transaction.
|
1554
|
+
#
|
1555
|
+
# Useful to split up parts of an application into certain namespaces. For
|
1556
|
+
# example: http requests, background jobs and administration panel
|
1557
|
+
# controllers.
|
1558
|
+
#
|
1559
|
+
# Note: The "http_request" namespace gets transformed on AppSignal.com to
|
1560
|
+
# "Web" and "background_job" gets transformed to "Background".
|
1561
|
+
#
|
1562
|
+
# _@param_ `namespace` — namespace name to use for this transaction.
|
1563
|
+
#
|
1564
|
+
# ```ruby
|
1565
|
+
# transaction.set_namespace("background")
|
1566
|
+
# ```
|
1567
|
+
#
|
1568
|
+
# _@see_ `Appsignal::Helpers::Instrumentation#set_namespace`
|
1569
|
+
#
|
1570
|
+
# _@see_ `https://docs.appsignal.com/guides/namespaces.html` — Grouping with namespaces guide
|
1571
|
+
def set_namespace: (String namespace) -> void
|
1572
|
+
|
1573
|
+
# Set queue start time for transaction.
|
1574
|
+
#
|
1575
|
+
# _@param_ `start` — Queue start time in milliseconds.
|
1576
|
+
def set_queue_start: (Integer start) -> void
|
1577
|
+
end
|
1578
|
+
|
1579
|
+
# Custom markers are used on AppSignal.com to indicate events in an
|
1580
|
+
# application, to give additional context on graph timelines.
|
1581
|
+
#
|
1582
|
+
# This helper class will send a request to the AppSignal public endpoint to
|
1583
|
+
# create a Custom marker for the application on AppSignal.com.
|
1584
|
+
#
|
1585
|
+
# @see https://docs.appsignal.com/api/public-endpoint/custom-markers.html
|
1586
|
+
# Public Endpoint API markers endpoint documentation
|
1587
|
+
# @see https://docs.appsignal.com/appsignal/terminology.html#markers
|
1588
|
+
# Terminology: Markers
|
1589
|
+
class CustomMarker
|
1590
|
+
# _@param_ `icon` — icon to use for the marker, like an emoji.
|
1591
|
+
#
|
1592
|
+
# _@param_ `message` — name of the user that is creating the marker.
|
1593
|
+
#
|
1594
|
+
# _@param_ `created_at` — A Ruby time object or a valid ISO8601 timestamp.
|
1595
|
+
def self.report: (?icon: String?, ?message: String?, ?created_at: (Time | String)?) -> bool
|
1596
|
+
end
|
1597
|
+
|
1598
|
+
# Keeps track of formatters for types event that we can use to get
|
1599
|
+
# the title and body of an event. Formatters should inherit from this class
|
1600
|
+
# and implement a format(payload) method which returns an array with the title
|
1601
|
+
# and body.
|
1602
|
+
#
|
1603
|
+
# When implementing a formatter remember that it cannot keep separate state per
|
1604
|
+
# event, the same object will be called intermittently in a threaded environment.
|
1605
|
+
# So only keep global configuration as state and pass the payload around as an
|
1606
|
+
# argument if you need to use helper methods.
|
1607
|
+
class EventFormatter
|
1608
|
+
DEFAULT: Integer
|
1609
|
+
SQL_BODY_FORMAT: Integer
|
1610
|
+
|
1611
|
+
# Registers an event formatter for a specific event name.
|
1612
|
+
#
|
1613
|
+
# _@param_ `name` — The name of the event to register the formatter for.
|
1614
|
+
#
|
1615
|
+
# _@param_ `formatter` — The formatter class that implements the `format(payload)` method.
|
1616
|
+
#
|
1617
|
+
# Register a custom formatter
|
1618
|
+
# ```ruby
|
1619
|
+
# class CustomFormatter < Appsignal::EventFormatter
|
1620
|
+
# def format(payload)
|
1621
|
+
# ["Custom event", payload[:body]]
|
1622
|
+
# end
|
1623
|
+
# end
|
1624
|
+
#
|
1625
|
+
# Appsignal::EventFormatter.register("my.event", CustomFormatter)
|
1626
|
+
# ```
|
1627
|
+
#
|
1628
|
+
# _@see_ `#unregister`
|
1629
|
+
#
|
1630
|
+
# _@see_ `#registered?`
|
1631
|
+
def self.register: ((String | Symbol) name, ?Class? formatter) -> void
|
1632
|
+
|
1633
|
+
# Unregisters an event formatter for a specific event name.
|
1634
|
+
#
|
1635
|
+
# _@param_ `name` — The name of the event to unregister the formatter for.
|
1636
|
+
#
|
1637
|
+
# _@param_ `formatter` — The formatter class to unregister. Defaults to `self`.
|
1638
|
+
#
|
1639
|
+
# Unregister a custom formatter
|
1640
|
+
# ```ruby
|
1641
|
+
# Appsignal::EventFormatter.unregister("my.event", CustomFormatter)
|
1642
|
+
# ```
|
1643
|
+
#
|
1644
|
+
# _@see_ `#register`
|
1645
|
+
#
|
1646
|
+
# _@see_ `#registered?`
|
1647
|
+
def self.unregister: ((String | Symbol) name, ?Class formatter) -> void
|
1648
|
+
|
1649
|
+
# Checks if an event formatter is registered for a specific event name.
|
1650
|
+
#
|
1651
|
+
# _@param_ `name` — The name of the event to check.
|
1652
|
+
#
|
1653
|
+
# _@param_ `klass` — The specific formatter class to check for. Optional.
|
1654
|
+
#
|
1655
|
+
# _@return_ — true if a formatter is registered, false otherwise.
|
1656
|
+
#
|
1657
|
+
# _@see_ `#register`
|
1658
|
+
#
|
1659
|
+
# _@see_ `#unregister`
|
1660
|
+
def self.registered?: ((String | Symbol) name, ?Class? klass) -> bool
|
1661
|
+
end
|
1662
|
+
|
1663
|
+
module Helpers
|
1664
|
+
module Metrics
|
1665
|
+
# Report a gauge metric.
|
1666
|
+
#
|
1667
|
+
# _@param_ `name` — The name of the metric.
|
1668
|
+
#
|
1669
|
+
# _@param_ `value` — The value of the metric.
|
1670
|
+
#
|
1671
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
1672
|
+
#
|
1673
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
1674
|
+
def set_gauge: ((String | Symbol) name, (Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
1675
|
+
|
1676
|
+
# Report a counter metric.
|
1677
|
+
#
|
1678
|
+
# _@param_ `name` — The name of the metric.
|
1679
|
+
#
|
1680
|
+
# _@param_ `value` — The value of the metric.
|
1681
|
+
#
|
1682
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
1683
|
+
#
|
1684
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
1685
|
+
def increment_counter: ((String | Symbol) name, ?(Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
1686
|
+
|
1687
|
+
# Report a distribution metric.
|
1688
|
+
#
|
1689
|
+
# _@param_ `name` — The name of the metric.
|
1690
|
+
#
|
1691
|
+
# _@param_ `value` — The value of the metric.
|
1692
|
+
#
|
1693
|
+
# _@param_ `tags` — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.
|
1694
|
+
#
|
1695
|
+
# _@see_ `https://docs.appsignal.com/metrics/custom.html` — Metrics documentation
|
1696
|
+
def add_distribution_value: ((String | Symbol) name, (Integer | Float) value, ?::Hash[String, Object] tags) -> void
|
1697
|
+
end
|
1698
|
+
|
1699
|
+
module Instrumentation
|
1700
|
+
# Monitor a block of code with AppSignal.
|
1701
|
+
#
|
1702
|
+
# This is a helper to create an AppSignal transaction, track any errors
|
1703
|
+
# that may occur and complete the transaction.
|
1704
|
+
#
|
1705
|
+
# This helper is recommended to be used in Ruby scripts and parts of an
|
1706
|
+
# app not already instrumented by AppSignal's automatic instrumentations.
|
1707
|
+
#
|
1708
|
+
# Use this helper in combination with our {.instrument} helper to track
|
1709
|
+
# instrumentation events.
|
1710
|
+
#
|
1711
|
+
# If AppSignal is not active ({Appsignal.active?}) it will still execute
|
1712
|
+
# the block, but not create a transaction for it.
|
1713
|
+
#
|
1714
|
+
# _@param_ `namespace` — The namespace to set on the new transaction. Defaults to the 'web' namespace. This will not update the active transaction's namespace if {.monitor} is called when another transaction is already active.
|
1715
|
+
#
|
1716
|
+
# _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
|
1717
|
+
#
|
1718
|
+
# _@return_ — The value of the given block is returned.
|
1719
|
+
# Returns `nil` if there already is a transaction active and no block
|
1720
|
+
# was given.
|
1721
|
+
#
|
1722
|
+
# Instrument a block of code
|
1723
|
+
# ```ruby
|
1724
|
+
# Appsignal.monitor(
|
1725
|
+
# :namespace => "my_namespace",
|
1726
|
+
# :action => "MyClass#my_method"
|
1727
|
+
# ) do
|
1728
|
+
# # Some code
|
1729
|
+
# end
|
1730
|
+
# ```
|
1731
|
+
#
|
1732
|
+
# Instrument a block of code using the default namespace
|
1733
|
+
# ```ruby
|
1734
|
+
# Appsignal.monitor(
|
1735
|
+
# :action => "MyClass#my_method"
|
1736
|
+
# ) do
|
1737
|
+
# # Some code
|
1738
|
+
# end
|
1739
|
+
# ```
|
1740
|
+
#
|
1741
|
+
# Instrument a block of code with an instrumentation event
|
1742
|
+
# ```ruby
|
1743
|
+
# Appsignal.monitor(
|
1744
|
+
# :namespace => "my_namespace",
|
1745
|
+
# :action => "MyClass#my_method"
|
1746
|
+
# ) do
|
1747
|
+
# Appsignal.instrument("some_event.some_group") do
|
1748
|
+
# # Some code
|
1749
|
+
# end
|
1750
|
+
# end
|
1751
|
+
# ```
|
1752
|
+
#
|
1753
|
+
# Set the action name in the monitor block
|
1754
|
+
# ```ruby
|
1755
|
+
# Appsignal.monitor(
|
1756
|
+
# :action => nil
|
1757
|
+
# ) do
|
1758
|
+
# # Some code
|
1759
|
+
#
|
1760
|
+
# Appsignal.set_action("GET /resource/:id")
|
1761
|
+
# end
|
1762
|
+
# ```
|
1763
|
+
#
|
1764
|
+
# Set the action name in the monitor block
|
1765
|
+
# ```ruby
|
1766
|
+
# Appsignal.monitor(
|
1767
|
+
# :action => :set_later # Explicit placeholder
|
1768
|
+
# ) do
|
1769
|
+
# # Some code
|
1770
|
+
#
|
1771
|
+
# Appsignal.set_action("GET /resource/:id")
|
1772
|
+
# end
|
1773
|
+
# ```
|
1774
|
+
#
|
1775
|
+
# Set custom metadata on the transaction
|
1776
|
+
# ```ruby
|
1777
|
+
# Appsignal.monitor(
|
1778
|
+
# :namespace => "my_namespace",
|
1779
|
+
# :action => "MyClass#my_method"
|
1780
|
+
# ) do
|
1781
|
+
# # Some code
|
1782
|
+
#
|
1783
|
+
# Appsignal.add_tags(:tag1 => "value1", :tag2 => "value2")
|
1784
|
+
# Appsignal.add_params(:param1 => "value1", :param2 => "value2")
|
1785
|
+
# end
|
1786
|
+
# ```
|
1787
|
+
#
|
1788
|
+
# Call monitor within monitor will do nothing
|
1789
|
+
# ```ruby
|
1790
|
+
# Appsignal.monitor(
|
1791
|
+
# :namespace => "my_namespace",
|
1792
|
+
# :action => "MyClass#my_method"
|
1793
|
+
# ) do
|
1794
|
+
# # This will _not_ update the namespace and action name
|
1795
|
+
# Appsignal.monitor(
|
1796
|
+
# :namespace => "my_other_namespace",
|
1797
|
+
# :action => "MyOtherClass#my_other_method"
|
1798
|
+
# ) do
|
1799
|
+
# # Some code
|
1800
|
+
#
|
1801
|
+
# # The reported namespace will be "my_namespace"
|
1802
|
+
# # The reported action will be "MyClass#my_method"
|
1803
|
+
# end
|
1804
|
+
# end
|
1805
|
+
# ```
|
1806
|
+
#
|
1807
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
|
1808
|
+
def monitor: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
|
1809
|
+
|
1810
|
+
# Instrument a block of code and stop AppSignal.
|
1811
|
+
#
|
1812
|
+
# Useful for cases such as one-off scripts where there is no long running
|
1813
|
+
# process active and the data needs to be sent after the process exists.
|
1814
|
+
#
|
1815
|
+
# Acts the same way as {.monitor}. See that method for more
|
1816
|
+
# documentation.
|
1817
|
+
#
|
1818
|
+
# _@param_ `namespace` — The namespace to set on the new transaction. Defaults to the 'web' namespace. This will not update the active transaction's namespace if {.monitor} is called when another transaction is already active.
|
1819
|
+
#
|
1820
|
+
# _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
|
1821
|
+
#
|
1822
|
+
# _@return_ — The value of the given block is returned.
|
1823
|
+
#
|
1824
|
+
# _@see_ `monitor`
|
1825
|
+
def monitor_and_stop: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
|
1826
|
+
|
1827
|
+
# Send an error to AppSignal regardless of the context.
|
1828
|
+
#
|
1829
|
+
# **We recommend using the {#report_error} helper instead.**
|
1830
|
+
#
|
1831
|
+
# Records and send the exception to AppSignal.
|
1832
|
+
#
|
1833
|
+
# This instrumentation helper does not require a transaction to be
|
1834
|
+
# active, it starts a new transaction by itself.
|
1835
|
+
#
|
1836
|
+
# Use {.set_error} if your want to add an exception to the current
|
1837
|
+
# transaction.
|
1838
|
+
#
|
1839
|
+
# **Note**: Does not do anything if AppSignal is not active or when the
|
1840
|
+
# "error" is not a class extended from Ruby's Exception class.
|
1841
|
+
#
|
1842
|
+
# _@param_ `error` — The error to send to AppSignal.
|
1843
|
+
#
|
1844
|
+
# Send an exception
|
1845
|
+
# ```ruby
|
1846
|
+
# begin
|
1847
|
+
# raise "oh no!"
|
1848
|
+
# rescue => e
|
1849
|
+
# Appsignal.send_error(e)
|
1850
|
+
# end
|
1851
|
+
# ```
|
1852
|
+
#
|
1853
|
+
# Add more metadata to transaction
|
1854
|
+
# ```ruby
|
1855
|
+
# Appsignal.send_error(e) do
|
1856
|
+
# Appsignal.set_namespace("my_namespace")
|
1857
|
+
# Appsignal.set_action("my_action_name")
|
1858
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
1859
|
+
# Appsignal.add_tags(:key => "value")
|
1860
|
+
# end
|
1861
|
+
# ```
|
1862
|
+
#
|
1863
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
1864
|
+
def send_error: (Exception error) ?{ (Transaction transaction) -> void } -> void
|
1865
|
+
|
1866
|
+
# Set an error on the current transaction.
|
1867
|
+
#
|
1868
|
+
# **We recommend using the {#report_error} helper instead.**
|
1869
|
+
#
|
1870
|
+
# **Note**: Does not do anything if AppSignal is not active, no
|
1871
|
+
# transaction is currently active or when the "error" is not a class
|
1872
|
+
# extended from Ruby's Exception class.
|
1873
|
+
#
|
1874
|
+
# _@param_ `exception` — The error to add to the current transaction.
|
1875
|
+
#
|
1876
|
+
# Manual instrumentation of set_error.
|
1877
|
+
# ```ruby
|
1878
|
+
# # Manually starting AppSignal here
|
1879
|
+
# # Manually starting a transaction here.
|
1880
|
+
# begin
|
1881
|
+
# raise "oh no!"
|
1882
|
+
# rescue => e
|
1883
|
+
# Appsignal.set_error(e)
|
1884
|
+
# end
|
1885
|
+
# # Manually completing the transaction here.
|
1886
|
+
# # Manually stopping AppSignal here
|
1887
|
+
# ```
|
1888
|
+
#
|
1889
|
+
# In a Rails application
|
1890
|
+
# ```ruby
|
1891
|
+
# class SomeController < ApplicationController
|
1892
|
+
# # The AppSignal transaction is created by our integration for you.
|
1893
|
+
# def create
|
1894
|
+
# # Do something that breaks
|
1895
|
+
# rescue => e
|
1896
|
+
# Appsignal.set_error(e)
|
1897
|
+
# end
|
1898
|
+
# end
|
1899
|
+
# ```
|
1900
|
+
#
|
1901
|
+
# Add more metadata to transaction
|
1902
|
+
# ```ruby
|
1903
|
+
# Appsignal.set_error(e) do
|
1904
|
+
# Appsignal.set_namespace("my_namespace")
|
1905
|
+
# Appsignal.set_action("my_action_name")
|
1906
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
1907
|
+
# Appsignal.add_tags(:key => "value")
|
1908
|
+
# end
|
1909
|
+
# ```
|
1910
|
+
#
|
1911
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
1912
|
+
def set_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
|
1913
|
+
|
1914
|
+
# Report an error to AppSignal.
|
1915
|
+
#
|
1916
|
+
# If a transaction is currently active, it will report the error on the
|
1917
|
+
# current transaction. If no transaction is active, it will report the
|
1918
|
+
# error on a new transaction.
|
1919
|
+
#
|
1920
|
+
# If a transaction is active and the transaction already has an error
|
1921
|
+
# reported on it, it will report multiple errors, up to a maximum of 10
|
1922
|
+
# errors.
|
1923
|
+
#
|
1924
|
+
# If a block is given to this method, the metadata set in this block will
|
1925
|
+
# only be applied to the transaction created for the given error. The
|
1926
|
+
# block will be called when the transaction is completed, which can be
|
1927
|
+
# much later than when {#report_error} is called.
|
1928
|
+
#
|
1929
|
+
# **Note**: If AppSignal is not active, no error is reported.
|
1930
|
+
#
|
1931
|
+
# **Note**: If the given exception argument is not an Exception subclass,
|
1932
|
+
# it will not be reported.
|
1933
|
+
#
|
1934
|
+
# _@param_ `exception` — The error to add to the current transaction.
|
1935
|
+
#
|
1936
|
+
# ```ruby
|
1937
|
+
# class SomeController < ApplicationController
|
1938
|
+
# def create
|
1939
|
+
# # Do something that breaks
|
1940
|
+
# rescue => error
|
1941
|
+
# Appsignal.report_error(error)
|
1942
|
+
# end
|
1943
|
+
# end
|
1944
|
+
# ```
|
1945
|
+
#
|
1946
|
+
# Add more metadata to transaction
|
1947
|
+
# ```ruby
|
1948
|
+
# Appsignal.report_error(error) do
|
1949
|
+
# Appsignal.set_namespace("my_namespace")
|
1950
|
+
# Appsignal.set_action("my_action_name")
|
1951
|
+
# Appsignal.add_params(:search_query => params[:search_query])
|
1952
|
+
# Appsignal.add_tags(:key => "value")
|
1953
|
+
# end
|
1954
|
+
# ```
|
1955
|
+
#
|
1956
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
|
1957
|
+
def report_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
|
1958
|
+
|
1959
|
+
# Set a custom action name for the current transaction.
|
1960
|
+
#
|
1961
|
+
# When using an integration such as the Rails or Sinatra AppSignal will
|
1962
|
+
# try to find the action name from the controller or endpoint for you.
|
1963
|
+
#
|
1964
|
+
# If you want to customize the action name as it appears on AppSignal.com
|
1965
|
+
# you can use this method. This overrides the action name AppSignal
|
1966
|
+
# generates in an integration.
|
1967
|
+
#
|
1968
|
+
# _@param_ `action`
|
1969
|
+
#
|
1970
|
+
# in a Rails controller
|
1971
|
+
# ```ruby
|
1972
|
+
# class SomeController < ApplicationController
|
1973
|
+
# before_action :set_appsignal_action
|
1974
|
+
#
|
1975
|
+
# def set_appsignal_action
|
1976
|
+
# Appsignal.set_action("DynamicController#dynamic_method")
|
1977
|
+
# end
|
1978
|
+
# end
|
1979
|
+
# ```
|
1980
|
+
def set_action: (String action) -> void
|
1981
|
+
|
1982
|
+
# Set a custom namespace for the current transaction.
|
1983
|
+
#
|
1984
|
+
# When using an integration such as Rails or Sidekiq AppSignal will try
|
1985
|
+
# to find a appropriate namespace for the transaction.
|
1986
|
+
#
|
1987
|
+
# A Rails controller will be automatically put in the "http_request"
|
1988
|
+
# namespace, while a Sidekiq background job is put in the
|
1989
|
+
# "background_job" namespace.
|
1990
|
+
#
|
1991
|
+
# Note: The "http_request" namespace gets transformed on AppSignal.com to
|
1992
|
+
# "Web" and "background_job" gets transformed to "Background".
|
1993
|
+
#
|
1994
|
+
# If you want to customize the namespace in which transactions appear you
|
1995
|
+
# can use this method. This overrides the namespace AppSignal uses by
|
1996
|
+
# default.
|
1997
|
+
#
|
1998
|
+
# A common request we've seen is to split the administration panel from
|
1999
|
+
# the main application.
|
2000
|
+
#
|
2001
|
+
# _@param_ `namespace`
|
2002
|
+
#
|
2003
|
+
# create a custom admin namespace
|
2004
|
+
# ```ruby
|
2005
|
+
# class AdminController < ApplicationController
|
2006
|
+
# before_action :set_appsignal_namespace
|
2007
|
+
#
|
2008
|
+
# def set_appsignal_namespace
|
2009
|
+
# Appsignal.set_namespace("admin")
|
2010
|
+
# end
|
2011
|
+
# end
|
2012
|
+
# ```
|
2013
|
+
#
|
2014
|
+
# _@see_ `https://docs.appsignal.com/guides/namespaces.html` — Grouping with namespaces guide
|
2015
|
+
def set_namespace: (String namespace) -> void
|
2016
|
+
|
2017
|
+
# Add custom data to the current transaction.
|
2018
|
+
#
|
2019
|
+
# Add extra information about the request or background that cannot be
|
2020
|
+
# expressed in tags, like nested data structures.
|
2021
|
+
#
|
2022
|
+
# If the root data type changes between calls of this method, the last
|
2023
|
+
# method call is stored.
|
2024
|
+
#
|
2025
|
+
# _@param_ `data` — Custom data to add to the transaction.
|
2026
|
+
#
|
2027
|
+
# Add Hash data
|
2028
|
+
# ```ruby
|
2029
|
+
# Appsignal.add_custom_data(:user => { :locale => "en" })
|
2030
|
+
# ```
|
2031
|
+
#
|
2032
|
+
# Merges Hash data
|
2033
|
+
# ```ruby
|
2034
|
+
# Appsignal.add_custom_data(:abc => "def")
|
2035
|
+
# Appsignal.add_custom_data(:xyz => "...")
|
2036
|
+
# # The custom data is: { :abc => "def", :xyz => "..." }
|
2037
|
+
# ```
|
2038
|
+
#
|
2039
|
+
# Add Array data
|
2040
|
+
# ```ruby
|
2041
|
+
# Appsignal.add_custom_data([
|
2042
|
+
# "array with data",
|
2043
|
+
# "other value",
|
2044
|
+
# :options => { :verbose => true }
|
2045
|
+
# ])
|
2046
|
+
# ```
|
2047
|
+
#
|
2048
|
+
# Merges Array data
|
2049
|
+
# ```ruby
|
2050
|
+
# Appsignal.add_custom_data([1, 2, 3])
|
2051
|
+
# Appsignal.add_custom_data([4, 5, 6])
|
2052
|
+
# # The custom data is: [1, 2, 3, 4, 5, 6]
|
2053
|
+
# ```
|
2054
|
+
#
|
2055
|
+
# Mixing of root data types is not supported
|
2056
|
+
# ```ruby
|
2057
|
+
# Appsignal.add_custom_data(:abc => "def")
|
2058
|
+
# Appsignal.add_custom_data([1, 2, 3])
|
2059
|
+
# # The custom data is: [1, 2, 3]
|
2060
|
+
# ```
|
2061
|
+
#
|
2062
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
2063
|
+
def add_custom_data: ((::Hash[Object, Object] | ::Array[Object]) data) -> void
|
2064
|
+
|
2065
|
+
# Add tags to the current transaction.
|
2066
|
+
#
|
2067
|
+
# Tags are extra bits of information that are added to transaction and
|
2068
|
+
# appear on sample details pages on AppSignal.com.
|
2069
|
+
#
|
2070
|
+
# When this method is called multiple times, it will merge the tags.
|
2071
|
+
#
|
2072
|
+
# _@param_ `tags` — Collection of tags to add to the transaction.
|
2073
|
+
#
|
2074
|
+
# ```ruby
|
2075
|
+
# Appsignal.add_tags(:locale => "en", :user_id => 1)
|
2076
|
+
# Appsignal.add_tags("locale" => "en")
|
2077
|
+
# Appsignal.add_tags("user_id" => 1)
|
2078
|
+
# ```
|
2079
|
+
#
|
2080
|
+
# Nested hashes are not supported
|
2081
|
+
# ```ruby
|
2082
|
+
# # Bad
|
2083
|
+
# Appsignal.add_tags(:user => { :locale => "en" })
|
2084
|
+
# ```
|
2085
|
+
#
|
2086
|
+
# in a Rails controller
|
2087
|
+
# ```ruby
|
2088
|
+
# class SomeController < ApplicationController
|
2089
|
+
# before_action :add_appsignal_tags
|
2090
|
+
#
|
2091
|
+
# def add_appsignal_tags
|
2092
|
+
# Appsignal.add_tags(:locale => I18n.locale)
|
2093
|
+
# end
|
2094
|
+
# end
|
2095
|
+
# ```
|
2096
|
+
#
|
2097
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/tagging.html` — Tagging guide
|
2098
|
+
def add_tags: (?::Hash[Object, Object] tags) -> void
|
2099
|
+
|
2100
|
+
# Add parameters to the current transaction.
|
2101
|
+
#
|
2102
|
+
# Parameters are automatically added by most of our integrations. It
|
2103
|
+
# should not be necessary to call this method unless you want to report
|
2104
|
+
# different parameters.
|
2105
|
+
#
|
2106
|
+
# This method accepts both Hash and Array parameter types:
|
2107
|
+
# - Hash parameters will be merged when called multiple times
|
2108
|
+
# - Array parameters will be concatenated when called multiple times
|
2109
|
+
# - Mixing Hash and Array types will use the latest type (and log a warning)
|
2110
|
+
#
|
2111
|
+
# To filter parameters, see our parameter filtering guide.
|
2112
|
+
#
|
2113
|
+
# When both the `params` argument and a block is given to this method,
|
2114
|
+
# the block is leading and the argument will _not_ be used.
|
2115
|
+
#
|
2116
|
+
# _@param_ `params` — The parameters to add to the transaction.
|
2117
|
+
#
|
2118
|
+
# Add Hash parameters
|
2119
|
+
# ```ruby
|
2120
|
+
# Appsignal.add_params("param1" => "value1")
|
2121
|
+
# # The parameters include: { "param1" => "value1" }
|
2122
|
+
# ```
|
2123
|
+
#
|
2124
|
+
# Add Array parameters
|
2125
|
+
# ```ruby
|
2126
|
+
# Appsignal.add_params(["item1", "item2"])
|
2127
|
+
# # The parameters include: ["item1", "item2"]
|
2128
|
+
# ```
|
2129
|
+
#
|
2130
|
+
# Calling `add_params` multiple times with Hashes merges values
|
2131
|
+
# ```ruby
|
2132
|
+
# Appsignal.add_params("param1" => "value1")
|
2133
|
+
# Appsignal.add_params("param2" => "value2")
|
2134
|
+
# # The parameters include:
|
2135
|
+
# # { "param1" => "value1", "param2" => "value2" }
|
2136
|
+
# ```
|
2137
|
+
#
|
2138
|
+
# Calling `add_params` multiple times with Arrays concatenates values
|
2139
|
+
# ```ruby
|
2140
|
+
# Appsignal.add_params(["item1"])
|
2141
|
+
# Appsignal.add_params(["item2"])
|
2142
|
+
# # The parameters include: ["item1", "item2"]
|
2143
|
+
# ```
|
2144
|
+
#
|
2145
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
2146
|
+
#
|
2147
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-parameters.html` — Parameter filtering guide
|
2148
|
+
def add_params: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
|
2149
|
+
|
2150
|
+
# Mark the parameters sample data to be set as an empty value.
|
2151
|
+
#
|
2152
|
+
# Use this helper to unset request parameters / background job arguments
|
2153
|
+
# and not report any for this transaction.
|
2154
|
+
#
|
2155
|
+
# If parameters would normally be added by AppSignal instrumentations of
|
2156
|
+
# libraries, these parameters will not be added to the Transaction.
|
2157
|
+
#
|
2158
|
+
# Calling {#add_params} after this helper will add new parameters to the
|
2159
|
+
# transaction.
|
2160
|
+
#
|
2161
|
+
# _@see_ `Transaction#set_empty_params!`
|
2162
|
+
#
|
2163
|
+
# _@see_ `Transaction#set_params_if_nil`
|
2164
|
+
def set_empty_params!: () -> void
|
2165
|
+
|
2166
|
+
# Add session data to the current transaction.
|
2167
|
+
#
|
2168
|
+
# Session data is automatically added by most of our integrations. It
|
2169
|
+
# should not be necessary to call this method unless you want to report
|
2170
|
+
# different session data.
|
2171
|
+
#
|
2172
|
+
# To filter session data, see our session data filtering guide.
|
2173
|
+
#
|
2174
|
+
# When both the `session_data` argument and a block is given to this
|
2175
|
+
# method, the bock is leading and the argument will _not_ be used.
|
2176
|
+
#
|
2177
|
+
# _@param_ `session_data` — The session data to add to the transaction.
|
2178
|
+
#
|
2179
|
+
# Add session data
|
2180
|
+
# ```ruby
|
2181
|
+
# Appsignal.add_session_data("session" => "data")
|
2182
|
+
# # The session data will include:
|
2183
|
+
# # { "session" => "data" }
|
2184
|
+
# ```
|
2185
|
+
#
|
2186
|
+
# Calling `add_session_data` multiple times merge the values
|
2187
|
+
# ```ruby
|
2188
|
+
# Appsignal.add_session_data("session" => "data")
|
2189
|
+
# Appsignal.add_session_data("other" => "value")
|
2190
|
+
# # The session data will include:
|
2191
|
+
# # { "session" => "data", "other" => "value" }
|
2192
|
+
# ```
|
2193
|
+
#
|
2194
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
2195
|
+
#
|
2196
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-session-data.html` — Session data filtering guide
|
2197
|
+
def add_session_data: (?::Hash[String, Object]? session_data) ?{ () -> ::Hash[String, Object] } -> void
|
2198
|
+
|
2199
|
+
# Add request headers to the current transaction.
|
2200
|
+
#
|
2201
|
+
# Request headers are automatically added by most of our integrations. It
|
2202
|
+
# should not be necessary to call this method unless you want to also
|
2203
|
+
# report different request headers.
|
2204
|
+
#
|
2205
|
+
# To filter request headers, see our request header filtering guide.
|
2206
|
+
#
|
2207
|
+
# When both the `request_headers` argument and a block is given to this
|
2208
|
+
# method, the block is leading and the argument will _not_ be used.
|
2209
|
+
#
|
2210
|
+
# _@param_ `headers` — The request headers to add to the transaction.
|
2211
|
+
#
|
2212
|
+
# Add request headers
|
2213
|
+
# ```ruby
|
2214
|
+
# Appsignal.add_headers("PATH_INFO" => "/some-path")
|
2215
|
+
# # The request headers will include:
|
2216
|
+
# # { "PATH_INFO" => "/some-path" }
|
2217
|
+
# ```
|
2218
|
+
#
|
2219
|
+
# Calling `add_headers` multiple times merge the values
|
2220
|
+
# ```ruby
|
2221
|
+
# Appsignal.add_headers("PATH_INFO" => "/some-path")
|
2222
|
+
# Appsignal.add_headers("HTTP_USER_AGENT" => "Firefox")
|
2223
|
+
# # The request headers will include:
|
2224
|
+
# # { "PATH_INFO" => "/some-path", "HTTP_USER_AGENT" => "Firefox" }
|
2225
|
+
# ```
|
2226
|
+
#
|
2227
|
+
# _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
|
2228
|
+
#
|
2229
|
+
# _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
|
2230
|
+
def add_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
|
2231
|
+
|
2232
|
+
# Add breadcrumbs to the transaction.
|
2233
|
+
#
|
2234
|
+
# Breadcrumbs can be used to trace what path a user has taken
|
2235
|
+
# before encountering an error.
|
2236
|
+
#
|
2237
|
+
# Only the last 20 added breadcrumbs will be saved.
|
2238
|
+
#
|
2239
|
+
# _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
|
2240
|
+
#
|
2241
|
+
# _@param_ `action` — name of breadcrumb e.g "The user clicked a button", "HTTP 500 from http://blablabla.com"
|
2242
|
+
#
|
2243
|
+
# _@param_ `message` — optional message in string format
|
2244
|
+
#
|
2245
|
+
# _@param_ `metadata` — key/value metadata in <string, string> format
|
2246
|
+
#
|
2247
|
+
# _@param_ `time` — time of breadcrumb, should respond to `.to_i` defaults to `Time.now.utc`
|
2248
|
+
#
|
2249
|
+
# ```ruby
|
2250
|
+
# Appsignal.add_breadcrumb(
|
2251
|
+
# "Navigation",
|
2252
|
+
# "http://blablabla.com",
|
2253
|
+
# "",
|
2254
|
+
# { :response => 200 },
|
2255
|
+
# Time.now.utc
|
2256
|
+
# )
|
2257
|
+
# Appsignal.add_breadcrumb(
|
2258
|
+
# "Network",
|
2259
|
+
# "[GET] http://blablabla.com",
|
2260
|
+
# "",
|
2261
|
+
# { :response => 500 }
|
2262
|
+
# )
|
2263
|
+
# Appsignal.add_breadcrumb(
|
2264
|
+
# "UI",
|
2265
|
+
# "closed modal(change_password)",
|
2266
|
+
# "User closed modal without actions"
|
2267
|
+
# )
|
2268
|
+
# ```
|
2269
|
+
#
|
2270
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/breadcrumbs.html` — Breadcrumb reference
|
2271
|
+
def add_breadcrumb: (
|
2272
|
+
String category,
|
2273
|
+
String action,
|
2274
|
+
?String message,
|
2275
|
+
?::Hash[String, String] metadata,
|
2276
|
+
?Time time
|
2277
|
+
) -> void
|
2278
|
+
|
2279
|
+
# Instrument helper for AppSignal.
|
2280
|
+
#
|
2281
|
+
# For more help, read our custom instrumentation guide, listed under "See
|
2282
|
+
# also".
|
2283
|
+
#
|
2284
|
+
# _@param_ `name` — Name of the instrumented event. Read our event naming guide listed under "See also".
|
2285
|
+
#
|
2286
|
+
# _@param_ `title` — Human readable name of the event.
|
2287
|
+
#
|
2288
|
+
# _@param_ `body` — Value of importance for the event, such as the server against an API call is made.
|
2289
|
+
#
|
2290
|
+
# _@param_ `body_format` — Enum for the type of event that is instrumented. Accepted values are {EventFormatter::DEFAULT} and {EventFormatter::SQL_BODY_FORMAT}, but we recommend you use {.instrument_sql} instead of {EventFormatter::SQL_BODY_FORMAT}.
|
2291
|
+
#
|
2292
|
+
# _@return_ — Returns the block's return value.
|
2293
|
+
#
|
2294
|
+
# Simple instrumentation
|
2295
|
+
# ```ruby
|
2296
|
+
# Appsignal.instrument("fetch.issue_fetcher") do
|
2297
|
+
# # To be instrumented code
|
2298
|
+
# end
|
2299
|
+
# ```
|
2300
|
+
#
|
2301
|
+
# Instrumentation with title and body
|
2302
|
+
# ```ruby
|
2303
|
+
# Appsignal.instrument(
|
2304
|
+
# "fetch.issue_fetcher",
|
2305
|
+
# "Fetching issue",
|
2306
|
+
# "GitHub API"
|
2307
|
+
# ) do
|
2308
|
+
# # To be instrumented code
|
2309
|
+
# end
|
2310
|
+
# ```
|
2311
|
+
#
|
2312
|
+
# _@see_ `.instrument_sql`
|
2313
|
+
#
|
2314
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
|
2315
|
+
#
|
2316
|
+
# _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
|
2317
|
+
def instrument: (
|
2318
|
+
String name,
|
2319
|
+
?String? title,
|
2320
|
+
?String? body,
|
2321
|
+
?Integer body_format
|
2322
|
+
) -> Object
|
2323
|
+
|
2324
|
+
# Instrumentation helper for SQL queries.
|
2325
|
+
#
|
2326
|
+
# This helper filters out values from SQL queries so you don't have to.
|
2327
|
+
#
|
2328
|
+
# _@param_ `name` — Name of the instrumented event. Read our event naming guide listed under "See also".
|
2329
|
+
#
|
2330
|
+
# _@param_ `title` — Human readable name of the event.
|
2331
|
+
#
|
2332
|
+
# _@param_ `body` — SQL query that's being executed.
|
2333
|
+
#
|
2334
|
+
# _@return_ — Returns the block's return value.
|
2335
|
+
#
|
2336
|
+
# SQL query instrumentation
|
2337
|
+
# ```ruby
|
2338
|
+
# body = "SELECT * FROM ..."
|
2339
|
+
# Appsignal.instrument_sql("perform.query", nil, body) do
|
2340
|
+
# # To be instrumented code
|
2341
|
+
# end
|
2342
|
+
# ```
|
2343
|
+
#
|
2344
|
+
# SQL query instrumentation
|
2345
|
+
# ```ruby
|
2346
|
+
# body = "WHERE email = 'foo@..'"
|
2347
|
+
# Appsignal.instrument_sql("perform.query", nil, body) do
|
2348
|
+
# # query value will replace 'foo..' with a question mark `?`.
|
2349
|
+
# end
|
2350
|
+
# ```
|
2351
|
+
#
|
2352
|
+
# _@see_ `.instrument`
|
2353
|
+
#
|
2354
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
|
2355
|
+
#
|
2356
|
+
# _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
|
2357
|
+
def instrument_sql: (String name, ?String? title, ?String? body) -> Object
|
2358
|
+
|
2359
|
+
# Convenience method for ignoring instrumentation events in a block of
|
2360
|
+
# code.
|
2361
|
+
#
|
2362
|
+
# - This helper ignores events, like those created
|
2363
|
+
# `Appsignal.instrument`, within this block.
|
2364
|
+
# This includes custom instrumentation and events recorded by AppSignal
|
2365
|
+
# integrations for requests, database queries, view rendering, etc.
|
2366
|
+
# - The time spent in the block is still reported on the transaction.
|
2367
|
+
# - Errors and metrics are reported from within this block.
|
2368
|
+
#
|
2369
|
+
# _@return_ — Returns the return value of the block.
|
2370
|
+
# Return nil if the block returns nil or no block is given.
|
2371
|
+
#
|
2372
|
+
# ```ruby
|
2373
|
+
# Appsignal.instrument "my_event.my_group" do
|
2374
|
+
# # Complex code here
|
2375
|
+
# end
|
2376
|
+
# Appsignal.ignore_instrumentation_events do
|
2377
|
+
# Appsignal.instrument "my_ignored_event.my_ignored_group" do
|
2378
|
+
# # Complex code here
|
2379
|
+
# end
|
2380
|
+
# end
|
2381
|
+
#
|
2382
|
+
# # Only the "my_event.my_group" instrumentation event is reported.
|
2383
|
+
# ```
|
2384
|
+
#
|
2385
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/ignore-instrumentation.html` — Ignore instrumentation guide
|
2386
|
+
def ignore_instrumentation_events: () ?{ () -> Object } -> Object?
|
2387
|
+
end
|
2388
|
+
end
|
2389
|
+
|
2390
|
+
class InternalError < StandardError
|
2391
|
+
end
|
2392
|
+
|
2393
|
+
class NotStartedError < Appsignal::InternalError
|
2394
|
+
def message: () -> String
|
2395
|
+
end
|
2396
|
+
end
|
2397
|
+
|
2398
|
+
# Extensions to Object for AppSignal method instrumentation.
|
2399
|
+
#
|
2400
|
+
# @see https://docs.appsignal.com/ruby/instrumentation/method-instrumentation.html
|
2401
|
+
# Method instrumentation documentation.
|
2402
|
+
class Object < BasicObject
|
2403
|
+
# Instruments a class method with AppSignal monitoring.
|
2404
|
+
#
|
2405
|
+
# _@param_ `method_name` — The name of the class method to instrument.
|
2406
|
+
#
|
2407
|
+
# _@param_ `options` — Options for instrumentation.
|
2408
|
+
#
|
2409
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/method-instrumentation.html` — Method instrumentation documentation.
|
2410
|
+
def self.appsignal_instrument_class_method: (Symbol method_name, ?::Hash[Symbol, String] options) -> Symbol
|
2411
|
+
|
2412
|
+
# Instruments an instance method with AppSignal monitoring.
|
2413
|
+
#
|
2414
|
+
# _@param_ `method_name` — The name of the instance method to instrument.
|
2415
|
+
#
|
2416
|
+
# _@param_ `options` — Options for instrumentation.
|
2417
|
+
#
|
2418
|
+
# _@see_ `https://docs.appsignal.com/ruby/instrumentation/method-instrumentation.html` — Method instrumentation documentation.
|
2419
|
+
def self.appsignal_instrument_method: (Symbol method_name, ?::Hash[Symbol, String] options) -> Symbol
|
2420
|
+
end
|