skylight 5.3.4 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eff8fe1dc5d710696a97b5e2a3cfe53eba04e34a9ded8c9b550bc82538b6dfbb
4
- data.tar.gz: a1236552d1cee17eaf0c0aee7371e7f6f201ab6810c4721a7ac67dcfe1f70177
3
+ metadata.gz: 4b0217b6b6828530f0fe344fbb3ca9ada78c96188e30ebe6556b74e9a152b1d2
4
+ data.tar.gz: 2b50af0d2954293733319ae585480329431a6000df515ba28f45e8a7cf9946e7
5
5
  SHA512:
6
- metadata.gz: e7a91c535de86e475c325c9a287c92754603e186e583691f4db240557a1d3fc9393ea0180c0e18273e86350c16562097b6040d709f91692340788b13c605a858
7
- data.tar.gz: c0bbf8d365bf386a7e1a0ae858b8007cb4046416e91b69862b250c21938a72b725ad0b0f5f0d25ffc73fc4fb435dff705bcb50c00c416fcdf0bb58e9dbcf8cfc
6
+ metadata.gz: 3bee5a6d0dcff8bcd132209bc48e726a25a3ecce65f4130c74bde52c9a4187cfcfe13358efd3ec8f8f4bbbca017204384e73be1ed71efbbf00a18f94fca3affb
7
+ data.tar.gz: 2d799ddf111d8bb4caae235b29010620aa90fa4618e3de7dc9fab2ff7a68e61b4a0f642d45f58761942df55effa1b8c6daf2bafc043259a6767395ed9c45d8f7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## 6.0.4 (February 23, 2024)
2
+ - [IMPROVEMENT] Set "turbo-frame" in the request segment when making a Turbo-Frame request
3
+
4
+ ## 6.0.3 (January 18, 2024)
5
+ - [IMPROVEMENT] Remove an outdated "abbrev" requirement
6
+
7
+ ## 6.0.2 (January 9, 2024)
8
+
9
+ - [IMPROVEMENT] When using certain versions of Rubygems (< 3.4.9), some users experienced a Rubygems bug in which the wrong version of Psych native extensions were loaded during Skylight's native extension building. We have inlined the data needed to download libskylight, so YAML is no longer required during installation. Note that for existing versions of Skylight, this issue may also be corrected by updating Rubygems to at least 3.4.9.
10
+
11
+ ## 6.0.1 (September 12, 2023)
12
+ - [BUGFIX] Fix a logger message that could raise an error when I18n is misconfigured or unconfigured.
13
+ - [BUGFIX] Fix an issue with proxy config in skylightd.
14
+
15
+ ## 6.0.0 (September 11, 2023)
16
+ - [BREAKING] End support for Ruby 2.6
17
+ - The following libraries are no longer tested and are not guaranteed to work with Skylight 6:
18
+ - Sinatra 1.x
19
+ - GraphQL 1.7 and 1.8
20
+ - Sidekiq 4
21
+ - NOTE: There is an inconsistency in the order of application of `ruby2_keywords` and `instrument_method` in
22
+ Ruby >= 3.2. We recommend not combining these two annotations at all, but if you must, call `instrument_method`
23
+ after your method has been defined.
24
+ - [IMPROVEMENT] When Rails's `exceptions_app` (used by ActionDispatch::ShowExceptions) is set to another instrumented
25
+ responder (like a Rails router), Skylight will not set the endpoint name after exception processing has started.
26
+ This means that error traces will now be aggregated under the original endpoint that generated the error (but with
27
+ the 'error' segment), rather than under the exception handler's controller and action name.
28
+ - [IMPROVEMENT] (Once again) Provide native support for FreeBSD.
29
+ - [BUGFIX] Fix an issue in which the daemon could time out if the processes file descriptor count was set very high (e.g. on Heroku's Performance dynos)
30
+ - [IMPROVEMENT] Better support for GraphQL versions >= 2.0.18.
31
+
32
+ ## 5.3.5 (January 18, 2024)
33
+ - [IMPROVEMENT] Remove an outdated "abbrev" requirement
34
+
1
35
  ## 5.3.4 (October 17, 2022)
2
36
 
3
37
  - [BUGFIX] Fix a middleware response method that was incompatible with Puma >= 6.
data/ext/extconf.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "rbconfig"
2
2
  require "mkmf"
3
- require "yaml"
4
3
  require "logger"
5
4
  require "fileutils"
6
5
 
@@ -12,6 +11,20 @@ require "skylight/util/platform"
12
11
  GLIBC_MIN = 2.23
13
12
  GLIBC_V4_MIN = 2.15
14
13
 
14
+ LIBSKYLIGHT_INFO = {
15
+ "version" => "5.2.0-15d2f2b",
16
+ "checksums" => {
17
+ "x86-linux" => "ae972e44ac926411971c7c2161f7b63d885108818bcdb9b67a34aef72650a01e",
18
+ "x86_64-linux" => "385369da7811b7ab9a71990c873858a21fd0c44b2b44c480c269a5632d886e5f",
19
+ "x86_64-linux-musl" => "a3404b9d02fd82dfc20bfa06889da79122626099a1aca0e3c009fe3724ba94b1",
20
+ "x86_64-darwin" => "779198627e376d4bf281f484a8b5ed818a500439ffe57f965b3797c4eac0c096",
21
+ "x86_64-freebsd" => "40fd09224f2ccd8d49c87eb9f27f6c4aa3b5e7d982f6c1c87de9b1038188e7ff",
22
+ "aarch64-linux" => "855e3ac01054b35a7eefbfd764ee87b07b54055a9397b969f7c25d442e514319",
23
+ "aarch64-linux-musl" => "59295e2a8183258aabaa9af7dbab222d3cd3fd2b22c287c3adf85f0d1669cb83",
24
+ "aarch64-darwin" => "adc070c71413520afb7186b6c6c04e1149120965c1609a60fa2b427615b51cf9"
25
+ }.freeze
26
+ }.freeze
27
+
15
28
  ldd_output =
16
29
  begin
17
30
  `ldd --version`
@@ -85,7 +98,7 @@ end
85
98
  # If the user installs Xcode-only, they have to approve the
86
99
  # license or no "xc*" tool will work.
87
100
 
88
- # prettier-ignore
101
+ # stree-ignore
89
102
  if Platform::OS == "darwin" && (`/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?)
90
103
  fail <<~MESSAGE
91
104
  You have not agreed to the Xcode license and so we are unable to build the native agent.
@@ -97,11 +110,10 @@ end
97
110
  #
98
111
  # === Setup paths
99
112
  #
100
- root = File.expand_path(__dir__)
101
113
  hdrpath = File.expand_path(SKYLIGHT_HDR_PATH)
102
114
  libpath = File.expand_path(SKYLIGHT_LIB_PATH)
115
+ extconf = __FILE__
103
116
  libskylight = File.expand_path("libskylight.#{Platform.libext}", libpath)
104
- libskylight_yml = File.expand_path("libskylight.yml", root)
105
117
  skylight_dlopen_h = File.expand_path("skylight_dlopen.h", hdrpath)
106
118
  skylight_dlopen_c = File.expand_path("skylight_dlopen.c", hdrpath)
107
119
 
@@ -115,32 +127,25 @@ LOG.info "file exists; path=#{skylight_dlopen_h}" if File.exist?(skylight_dlopen
115
127
  if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(skylight_dlopen_h)
116
128
  fail "libskylight.#{LIBEXT} not found -- remote download disabled; aborting install" unless SKYLIGHT_FETCH_LIB
117
129
 
118
- # Ensure that libskylight.yml is present and load it
119
- fail "`#{libskylight_yml}` does not exist" unless File.exist?(libskylight_yml)
120
-
121
- unless (libskylight_info = YAML.load_file(libskylight_yml))
122
- fail "`#{libskylight_yml}` does not contain data"
123
- end
124
-
125
130
  if (version = SKYLIGHT_VERSION)
126
131
  unless (checksum = SKYLIGHT_CHECKSUM)
127
132
  fail "no checksum provided when using custom version"
128
133
  end
129
- elsif (platform_info = libskylight_info[Platform.tuple])
134
+ elsif (platform_info = LIBSKYLIGHT_INFO[Platform.tuple])
130
135
  unless (version = platform_info["version"])
131
- fail "libskylight version missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
136
+ fail "libskylight version missing from `#{extconf}`; platform=#{Platform.tuple}"
132
137
  end
133
138
 
134
139
  unless (checksum = platform_info["checksum"])
135
- fail "checksum missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
140
+ fail "checksum missing from `#{extconf}`; platform=#{Platform.tuple}"
136
141
  end
137
142
  else
138
- unless (version = libskylight_info["version"])
139
- fail "libskylight version missing from `#{libskylight_yml}`"
143
+ unless (version = LIBSKYLIGHT_INFO["version"])
144
+ fail "libskylight version missing from `#{extconf}`"
140
145
  end
141
146
 
142
- unless (checksums = libskylight_info["checksums"])
143
- fail "libskylight checksums missing from `#{libskylight_yml}`"
147
+ unless (checksums = LIBSKYLIGHT_INFO["checksums"])
148
+ fail "libskylight checksums missing from `#{extconf}`"
144
149
  end
145
150
 
146
151
  unless (checksum = checksums[Platform.tuple])
@@ -245,9 +245,8 @@ module Skylight
245
245
  end
246
246
 
247
247
  if @parent_app && parent_component_fingerprints.include?([child_app.name, child_env])
248
- errors <<
249
- "Sorry, `#{@parent_app.name}` already has a `#{child_env}` " \
250
- "component that conflicts with this merge request. Please choose a new environment."
248
+ errors << "Sorry, `#{@parent_app.name}` already has a `#{child_env}` " \
249
+ "component that conflicts with this merge request. Please choose a new environment."
251
250
  end
252
251
 
253
252
  return child_env unless errors.any?
data/lib/skylight/cli.rb CHANGED
@@ -97,7 +97,9 @@ module Skylight
97
97
  namefile = Tempfile.new("skylight-app-name")
98
98
 
99
99
  # Windows appears to need double quotes for `rails runner`
100
+ # rubocop:disable Layout/LineLength
100
101
  `rails runner "File.open('#{namefile.path}', 'w') {|f| f.write(Rails.application.class.name) rescue '' }"`
102
+ # rubocop:enable Layout/LineLength
101
103
  name = namefile.read.split("::").first.underscore.titleize
102
104
  name = nil if name.empty?
103
105
  rescue StandardError => e
@@ -167,50 +167,49 @@ module Skylight
167
167
  }.freeze
168
168
 
169
169
  def self.native_env_keys
170
- @native_env_keys ||=
171
- %i[
172
- native_log_level
173
- native_log_file
174
- log_sql_parse_errors
175
- version
176
- root
177
- proxy_url
178
- hostname
179
- session_token
180
- auth_url
181
- auth_http_deflate
182
- auth_http_connect_timeout
183
- auth_http_read_timeout
184
- report_url
185
- report_http_deflate
186
- report_http_connect_timeout
187
- report_http_read_timeout
188
- report_http_disabled
189
- report_use_grpc
190
- report_grpc_url
191
- daemon.lazy_start
192
- daemon.exec_path
193
- daemon.lib_path
194
- daemon.pidfile_path
195
- daemon.sockdir_path
196
- daemon.batch_queue_depth
197
- daemon.batch_sample_size
198
- daemon.batch_flush_interval
199
- daemon.tick_interval
200
- daemon.lock_check_interval
201
- daemon.inactivity_timeout
202
- daemon.max_connect_tries
203
- daemon.connect_try_window
204
- daemon.max_prespawn_jitter
205
- daemon.wait_timeout
206
- daemon.client_check_interval
207
- daemon.client_queue_depth
208
- daemon.client_write_timeout
209
- daemon.ssl_cert_path
210
- daemon.ssl_cert_dir
211
- daemon.enable_tcp
212
- daemon.tcp_port
213
- ]
170
+ @native_env_keys ||= %i[
171
+ native_log_level
172
+ native_log_file
173
+ log_sql_parse_errors
174
+ version
175
+ root
176
+ proxy_url
177
+ hostname
178
+ session_token
179
+ auth_url
180
+ auth_http_deflate
181
+ auth_http_connect_timeout
182
+ auth_http_read_timeout
183
+ report_url
184
+ report_http_deflate
185
+ report_http_connect_timeout
186
+ report_http_read_timeout
187
+ report_http_disabled
188
+ report_use_grpc
189
+ report_grpc_url
190
+ daemon.lazy_start
191
+ daemon.exec_path
192
+ daemon.lib_path
193
+ daemon.pidfile_path
194
+ daemon.sockdir_path
195
+ daemon.batch_queue_depth
196
+ daemon.batch_sample_size
197
+ daemon.batch_flush_interval
198
+ daemon.tick_interval
199
+ daemon.lock_check_interval
200
+ daemon.inactivity_timeout
201
+ daemon.max_connect_tries
202
+ daemon.connect_try_window
203
+ daemon.max_prespawn_jitter
204
+ daemon.wait_timeout
205
+ daemon.client_check_interval
206
+ daemon.client_queue_depth
207
+ daemon.client_write_timeout
208
+ daemon.ssl_cert_path
209
+ daemon.ssl_cert_dir
210
+ daemon.enable_tcp
211
+ daemon.tcp_port
212
+ ]
214
213
  end
215
214
 
216
215
  # Maps legacy config keys to new config keys
@@ -219,8 +218,9 @@ module Skylight
219
218
  end
220
219
 
221
220
  def self.validators
222
- @validators ||=
223
- { "agent.interval": [->(v, _c) { v.is_a?(Integer) && v > 0 }, "must be an integer greater than 0"] }
221
+ @validators ||= {
222
+ "agent.interval": [->(v, _c) { v.is_a?(Integer) && v > 0 }, "must be an integer greater than 0"]
223
+ }
224
224
  end
225
225
 
226
226
  # @api private
@@ -301,21 +301,20 @@ module Skylight
301
301
  next unless k =~ /^(?:SK|SKYLIGHT)_(.+)$/
302
302
  next unless (key = ENV_TO_KEY[$1])
303
303
 
304
- ret[key] =
305
- case val
306
- when /^false$/i
307
- false
308
- when /^true$/i
309
- true
310
- when /^(nil|null)$/i
311
- nil
312
- when /^\d+$/
313
- val.to_i
314
- when /^\d+\.\d+$/
315
- val.to_f
316
- else
317
- val
318
- end
304
+ ret[key] = case val
305
+ when /^false$/i
306
+ false
307
+ when /^true$/i
308
+ true
309
+ when /^(nil|null)$/i
310
+ nil
311
+ when /^\d+$/
312
+ val.to_i
313
+ when /^\d+\.\d+$/
314
+ val.to_f
315
+ else
316
+ val
317
+ end
319
318
  end
320
319
 
321
320
  ret
@@ -450,16 +449,13 @@ module Skylight
450
449
  def to_native_env
451
450
  ret = []
452
451
 
453
- self
454
- .class
455
- .native_env_keys
456
- .each do |key|
457
- value = send_or_get(key)
458
- unless value.nil?
459
- env_key = KEY_TO_NATIVE_ENV[key] || ENV_TO_KEY.key(key) || key.upcase
460
- ret << "SKYLIGHT_#{env_key}" << cast_for_env(value)
461
- end
452
+ self.class.native_env_keys.each do |key|
453
+ value = send_or_get(key)
454
+ unless value.nil?
455
+ env_key = KEY_TO_NATIVE_ENV[key] || ENV_TO_KEY.key(key) || key.upcase
456
+ ret << "SKYLIGHT_#{env_key}" << cast_for_env(value)
462
457
  end
458
+ end
463
459
 
464
460
  ret << "SKYLIGHT_AUTHENTICATION" << authentication_with_meta
465
461
  ret << "SKYLIGHT_VALIDATE_AUTHENTICATION" << "false"
@@ -737,11 +733,10 @@ module Skylight
737
733
  end
738
734
 
739
735
  def components
740
- @components ||=
741
- {
742
- web: Util::Component.new(get(:env), Util::Component::DEFAULT_NAME),
743
- worker: Util::Component.new(get(:env), get(:component) || get(:worker_component), force_worker: true)
744
- }
736
+ @components ||= {
737
+ web: Util::Component.new(get(:env), Util::Component::DEFAULT_NAME),
738
+ worker: Util::Component.new(get(:env), get(:component) || get(:worker_component), force_worker: true)
739
+ }
745
740
  rescue ArgumentError => e
746
741
  raise ConfigError, e.message
747
742
  end
@@ -77,13 +77,17 @@ module Skylight
77
77
  @config = config
78
78
  end
79
79
 
80
- def process_trace_meta(_meta); end
80
+ def process_trace_meta(_meta)
81
+ end
81
82
 
82
- def process_instrument_options(_opts, _meta); end
83
+ def process_instrument_options(_opts, _meta)
84
+ end
83
85
 
84
- def process_normalizer_meta(_payload, _meta, **opts); end
86
+ def process_normalizer_meta(_payload, _meta, **opts)
87
+ end
85
88
 
86
- def trace_preprocess_meta(_meta); end
89
+ def trace_preprocess_meta(_meta)
90
+ end
87
91
 
88
92
  def allowed_meta_keys
89
93
  []
@@ -77,6 +77,11 @@ module Skylight
77
77
  # do_expensive_stuff
78
78
  # end
79
79
  # end
80
+ #
81
+ # NOTE: On Ruby >= 3.2, there is an inconsistency in the order ruby2_keywords is applied
82
+ # when combined with instrument_method in the prefix position. We recommend not mixing
83
+ # these two annotations, but if you must, call `instrument_method` in the suffix position
84
+ # after your method has been defined, e.g. `instrument_method :my_method`
80
85
  def instrument_method(*args, **opts)
81
86
  if (name = args.pop)
82
87
  title = "#{self}##{name}"
@@ -130,8 +135,6 @@ module Skylight
130
135
 
131
136
  private
132
137
 
133
- HAS_ARGUMENT_FORWARDING = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
134
-
135
138
  def __sk_instrument_method_on(klass, name, title, **opts)
136
139
  category = (opts[:category] || "app.method").to_s
137
140
  title = (opts[:title] || title).to_s
@@ -156,12 +159,7 @@ module Skylight
156
159
  # forward the different argument types.
157
160
  is_setter_method = name.to_s.end_with?("=")
158
161
 
159
- arg_string =
160
- if HAS_ARGUMENT_FORWARDING
161
- is_setter_method ? "*args, **kwargs, &blk" : "..."
162
- else
163
- "*args, &blk"
164
- end
162
+ arg_string = is_setter_method ? "*args, **kwargs, &blk" : "..."
165
163
 
166
164
  original_method_dispatch =
167
165
  if is_setter_method
@@ -31,7 +31,16 @@ module Skylight
31
31
  Thread.current[@muted_key] = val
32
32
  end
33
33
 
34
- def muted?
34
+ def muted
35
+ Thread.current[@muted_key]
36
+ end
37
+
38
+ def tracing_muted?
39
+ Thread.current[@muted_key] == :all
40
+ end
41
+
42
+ def endpoint_assignment_muted?
43
+ # all truthy values will mute endpoint assignment.
35
44
  !!Thread.current[@muted_key]
36
45
  end
37
46
  end
@@ -120,20 +129,32 @@ module Skylight
120
129
  @trace_info.muted = val
121
130
  end
122
131
 
123
- def muted?
124
- @trace_info.muted?
132
+ def muted
133
+ @trace_info.muted
134
+ end
135
+
136
+ def tracing_muted?
137
+ muted == :all || muted == true
138
+ end
139
+
140
+ def endpoint_assignment_muted?
141
+ tracing_muted? || muted == :endpoint_assignment
125
142
  end
126
143
 
127
- def mute
128
- old_muted = muted?
129
- self.muted = true
144
+ # possible values:
145
+ # ignore: :all
146
+ # ignore: :endpoint_assignment
147
+ # ignore: false | nil
148
+ def mute(ignore: :all)
149
+ old_muted = muted
150
+ self.muted = ignore
130
151
  yield if block_given?
131
152
  ensure
132
153
  self.muted = old_muted
133
154
  end
134
155
 
135
156
  def unmute
136
- old_muted = muted?
157
+ old_muted = muted
137
158
  self.muted = false
138
159
  yield if block_given?
139
160
  ensure
@@ -151,7 +172,7 @@ module Skylight
151
172
  end
152
173
 
153
174
  alias disable mute
154
- alias disabled? muted?
175
+ alias disabled? tracing_muted?
155
176
 
156
177
  def start!
157
178
  # We do this here since we can't report these issues via Gem install without stopping install entirely.
@@ -232,7 +253,7 @@ module Skylight
232
253
  def instrument(cat, title = nil, desc = nil, meta = nil)
233
254
  raise ArgumentError, "cat is required" unless cat
234
255
 
235
- if muted?
256
+ if tracing_muted?
236
257
  return yield if block_given?
237
258
 
238
259
  return
@@ -38,8 +38,8 @@ module Skylight
38
38
  # We are applying this special case for #each only. Future bugs of this
39
39
  # class will be handled by requesting users to patch their ruby
40
40
  # implementation, to save adding too many methods in this class.
41
- def each(*args, &block)
42
- @body.each(*args, &block)
41
+ def each(...)
42
+ @body.each(...)
43
43
  end
44
44
 
45
45
  def method_missing(*args, &block)
@@ -132,7 +132,7 @@ module Skylight
132
132
  end
133
133
 
134
134
  def make_request_id(request_id)
135
- request_id && !request_id.empty? ? request_id.gsub(/[^\w\-]/, "".freeze)[0...255] : internal_request_id
135
+ request_id && !request_id.empty? ? request_id.gsub(/[^\w-]/, "".freeze)[0...255] : internal_request_id
136
136
  end
137
137
 
138
138
  def internal_request_id
@@ -18,8 +18,9 @@ module Skylight
18
18
  # @option payload [String] :action Action name
19
19
  # @return [Array]
20
20
  def normalize(trace, _name, payload)
21
- trace.endpoint = controller_action(payload)
22
- [CAT, trace.endpoint, nil]
21
+ endpoint = controller_action(payload)
22
+ trace.endpoint = endpoint
23
+ [CAT, endpoint, nil]
23
24
  end
24
25
 
25
26
  def normalize_after(trace, _span, _name, payload)
@@ -45,11 +46,12 @@ module Skylight
45
46
  # Show 'error' if there's an unhandled exception or if the status is 4xx or 5xx
46
47
  return "error" if payload[:exception] || payload[:exception_object]
47
48
 
48
- segment_from_status(payload[:status]) || if payload[:sk_rendered_format]
49
- # We only show the variant if we actually have a format
50
- # We won't have a sk_rendered_format if it's a `head` outside of a `respond_to` block.
51
- [payload[:sk_rendered_format], payload[:sk_variant]].compact.flatten.join("+")
52
- end
49
+ segment_from_status(payload[:status]) ||
50
+ if payload[:sk_rendered_format]
51
+ # We only show the variant if we actually have a format
52
+ # We won't have a sk_rendered_format if it's a `head` outside of a `respond_to` block.
53
+ [payload[:sk_rendered_format], payload[:sk_variant]].compact.flatten.join("+")
54
+ end
53
55
  end
54
56
 
55
57
  def segment_from_status(status)
@@ -8,7 +8,7 @@ module Skylight
8
8
 
9
9
  def normalize(trace, _name, _payload)
10
10
  trace.endpoint = router_class_name
11
- [CAT, trace.endpoint, nil]
11
+ [CAT, router_class_name, nil]
12
12
  end
13
13
 
14
14
  private
@@ -8,16 +8,12 @@ module Skylight
8
8
  DELAYED_JOB_WRAPPER = "ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper".freeze
9
9
 
10
10
  def self.normalize_title(job_instance)
11
- job_instance
12
- .class
13
- .name
14
- .to_s
15
- .tap do |str|
16
- if str.match(DELIVERY_JOB)
17
- mailer_class, mailer_method, * = job_instance.arguments
18
- return "#{mailer_class}##{mailer_method}", str if mailer_class && mailer_method
19
- end
11
+ job_instance.class.name.to_s.tap do |str|
12
+ if str.match(DELIVERY_JOB)
13
+ mailer_class, mailer_method, * = job_instance.arguments
14
+ return "#{mailer_class}##{mailer_method}", str if mailer_class && mailer_method
20
15
  end
16
+ end
21
17
  end
22
18
 
23
19
  CAT = "app.job.perform".freeze
@@ -75,7 +75,8 @@ module Skylight
75
75
  [cat, title, desc, meta]
76
76
  end
77
77
 
78
- def normalize_after(trace, span, name, payload); end
78
+ def normalize_after(trace, span, name, payload)
79
+ end
79
80
 
80
81
  private
81
82
 
@@ -11,7 +11,14 @@ module Skylight
11
11
  def append_info_to_payload(payload)
12
12
  append_info_to_payload_without_sk(payload)
13
13
 
14
- payload[:sk_rendered_format] = sk_rendered_mime.try(:ref)
14
+ mime = sk_rendered_mime.try(:ref)
15
+
16
+ payload[:sk_rendered_format] = if request&.headers&.[]("Turbo-Frame")
17
+ [mime, "turbo-frame"].compact.join("+")
18
+ else
19
+ mime
20
+ end
21
+
15
22
  payload[:sk_variant] = request.respond_to?(:variant) ? request.variant : nil
16
23
  end
17
24
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skylight
4
+ module Probes
5
+ module ActionDispatch
6
+ module ShowExceptions
7
+ module Instrumentation
8
+ def initialize(...)
9
+ super
10
+
11
+ exceptions_app = @exceptions_app
12
+ @exceptions_app =
13
+ lambda do |env|
14
+ Skylight.instrumenter&.current_trace&.segment = "error"
15
+ Skylight.mute(ignore: :endpoint_assignment) { exceptions_app.call(env) }
16
+ end
17
+ end
18
+ end
19
+
20
+ class Probe
21
+ def install
22
+ ::ActionDispatch::ShowExceptions.prepend(Instrumentation)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ register(
29
+ :rails_show_exceptions,
30
+ "ActionDispatch::ShowExceptions",
31
+ "action_dispatch/show_exceptions",
32
+ ActionDispatch::ShowExceptions::Probe.new
33
+ )
34
+ end
35
+ end
@@ -1,2 +1,3 @@
1
1
  Skylight.probe("action_dispatch/request_id")
2
2
  Skylight.probe("action_dispatch/routing/route_set")
3
+ Skylight.probe("action_dispatch/show_exceptions")
@@ -11,20 +11,67 @@ module Skylight
11
11
 
12
12
  return unless defined?(@tracers)
13
13
 
14
+ # This is the legacy tracing used in graphql =< 2.0.17
14
15
  unless @tracers.include?(::GraphQL::Tracing::ActiveSupportNotificationsTracing)
15
16
  @tracers << ::GraphQL::Tracing::ActiveSupportNotificationsTracing
16
17
  end
17
18
  end
18
19
  end
19
20
 
21
+ module InstrumentationV2
22
+ def self.included(base)
23
+ base.singleton_class.prepend ClassMethods
24
+ end
25
+
26
+ # GraphQL versions 2.0.18 - 2.0.21 (or higher?) were missing this notification
27
+ module ExecuteMultiplexNotification
28
+ def execute_multiplex(**metadata, &blk)
29
+ if @notifications_engine
30
+ @notifications_engine.instrument("execute_multiplex.graphql", metadata, &blk)
31
+ else
32
+ # safety fallback in case graphql's authors unexpectedly rename @notifications_engine
33
+ super
34
+ end
35
+ end
36
+ end
37
+
38
+ module ClassMethods
39
+ def new_trace(*, **)
40
+ unless @__sk_instrumentation_installed
41
+ trace_with(::GraphQL::Tracing::ActiveSupportNotificationsTrace)
42
+
43
+ unless ::GraphQL::Tracing::ActiveSupportNotificationsTrace.instance_methods.include?(:execute_multiplex)
44
+ trace_with(ExecuteMultiplexNotification)
45
+ end
46
+
47
+ @__sk_instrumentation_installed = true
48
+ end
49
+
50
+ super
51
+ end
52
+ end
53
+ end
54
+
20
55
  class Probe
21
56
  def install
22
- tracing_klass_name = "::GraphQL::Tracing::ActiveSupportNotificationsTracing"
23
- klasses_to_probe = %w[::GraphQL::Execution::Multiplex ::GraphQL::Query]
57
+ new_tracing = false
58
+ begin
59
+ require "graphql/tracing/active_support_notifications_trace"
60
+ new_tracing = true
61
+ rescue LoadError # rubocop:disable Lint/SuppressedException
62
+ end
63
+
64
+ if new_tracing
65
+ # GraphQL >= 2.0.18
66
+ ::GraphQL::Schema.include(InstrumentationV2)
67
+ else
68
+ tracing_klass_name = "::GraphQL::Tracing::ActiveSupportNotificationsTracing"
69
+ klasses_to_probe = %w[::GraphQL::Execution::Multiplex ::GraphQL::Query]
24
70
 
25
- return unless ([tracing_klass_name] + klasses_to_probe).all?(&method(:safe_constantize))
71
+ return unless ([tracing_klass_name] + klasses_to_probe).all?(&method(:safe_constantize))
26
72
 
27
- klasses_to_probe.each { |klass_name| safe_constantize(klass_name).prepend(Instrumentation) }
73
+ klasses_to_probe.each { |klass_name| safe_constantize(klass_name).prepend(Instrumentation) }
74
+ end
28
75
  end
29
76
 
30
77
  def safe_constantize(klass_name)
@@ -9,16 +9,15 @@ module Skylight
9
9
  # NOTE: Caching here leads to better performance, but will not notice if the method is overridden
10
10
  # We don't have access to the config here so we can't check whether source locations are enabled.
11
11
  # However, this only happens once per middleware so it should be minimal impact.
12
- @payload[:sk_source_location] =
13
- begin
14
- if middleware.is_a?(Proc)
15
- middleware.source_location
16
- elsif middleware.respond_to?(:call)
17
- middleware.method(:call).source_location
18
- end
19
- rescue StandardError
20
- nil
12
+ @payload[:sk_source_location] = begin
13
+ if middleware.is_a?(Proc)
14
+ middleware.source_location
15
+ elsif middleware.respond_to?(:call)
16
+ middleware.method(:call).source_location
21
17
  end
18
+ rescue StandardError
19
+ nil
20
+ end
22
21
  end
23
22
  end
24
23
 
@@ -50,8 +50,8 @@ module Skylight
50
50
 
51
51
  class Probe
52
52
  def install
53
- if ::Sinatra::VERSION < "1.4.0"
54
- Skylight.error "Sinatra must be version 1.4.0 or greater."
53
+ if ::Sinatra::VERSION < "2.0.0"
54
+ Skylight.error "Sinatra must be version 2.0.0 or greater."
55
55
  return
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ module Skylight
59
59
 
60
60
  class << self
61
61
  def constant_available?(const_name)
62
- ::ActiveSupport::Inflector.safe_constantize(const_name).present?
62
+ !::ActiveSupport::Inflector.safe_constantize(const_name).nil?
63
63
  end
64
64
 
65
65
  def install!
@@ -45,7 +45,7 @@ module Skylight
45
45
 
46
46
  return if reasons.empty?
47
47
 
48
- sk_config.logger.warn("Activating Skylight for Background Jobs because #{reasons.to_sentence}")
48
+ sk_config.logger.warn("Activating Skylight for Background Jobs because #{reasons.to_sentence(locale: false)}")
49
49
  end
50
50
 
51
51
  def log_prefix
data/lib/skylight/test.rb CHANGED
@@ -33,7 +33,8 @@ module Skylight
33
33
  config[:mock_submission].call(trace)
34
34
  end
35
35
 
36
- def native_stop; end
36
+ def native_stop
37
+ end
37
38
  end
38
39
  )
39
40
 
@@ -105,7 +106,8 @@ module Skylight
105
106
  mock_spans[span][:meta] = meta
106
107
  end
107
108
 
108
- def native_span_started(span); end
109
+ def native_span_started(span)
110
+ end
109
111
 
110
112
  def native_span_set_exception(span, exception_object, exception)
111
113
  mock_spans[span][:exception_object] = exception_object
@@ -77,19 +77,13 @@ module Skylight
77
77
  end
78
78
 
79
79
  def endpoint=(value)
80
- if muted?
81
- maybe_warn(:endpoint_set_muted, "tried to set endpoint name while muted")
82
- return
83
- end
80
+ return if endpoint_assignment_muted?
84
81
  @endpoint = value
85
82
  native_set_endpoint(value)
86
83
  end
87
84
 
88
85
  def segment=(value)
89
- if muted?
90
- maybe_warn(:segment_set_muted, "tried to set segment name while muted")
91
- return
92
- end
86
+ return if endpoint_assignment_muted?
93
87
  @segment = value
94
88
  end
95
89
 
@@ -99,8 +93,16 @@ module Skylight
99
93
  @instrumenter.config
100
94
  end
101
95
 
102
- def muted?
103
- !!@child_instrumentation_muted_by || @instrumenter.muted?
96
+ def muted
97
+ @child_instrumentation_muted_by || @instrumenter.muted
98
+ end
99
+
100
+ def tracing_muted?
101
+ !!@child_instrumentation_muted_by || @instrumenter.tracing_muted?
102
+ end
103
+
104
+ def endpoint_assignment_muted?
105
+ tracing_muted? || @instrumenter.endpoint_assignment_muted?
104
106
  end
105
107
 
106
108
  def broken?
@@ -117,7 +119,7 @@ module Skylight
117
119
  end
118
120
 
119
121
  def instrument(cat, title = nil, desc = nil, meta = nil)
120
- return if muted?
122
+ return if tracing_muted?
121
123
  return if broken?
122
124
 
123
125
  t { "instrument: #{cat}, #{title}" }
@@ -300,9 +302,8 @@ module Skylight
300
302
  message << "\nWe disabled the Middleware probe but unfortunately, this didn't solve the issue."
301
303
  else
302
304
  Skylight::Probes::Middleware::Probe.disable!
303
- message <<
304
- "\n#{native_span_get_title(span)} may be a Middleware that doesn't fully conform " \
305
- "to the Rack SPEC. We've disabled the Middleware probe to see if that resolves the issue."
305
+ message << "\n#{native_span_get_title(span)} may be a Middleware that doesn't fully conform " \
306
+ "to the Rack SPEC. We've disabled the Middleware probe to see if that resolves the issue."
306
307
  end
307
308
  end
308
309
 
@@ -1,23 +1,23 @@
1
1
  module Skylight
2
2
  module Util
3
3
  module InstrumenterMethod
4
- def instrumenter_method(name, block: false)
5
- if block
4
+ def instrumenter_method(name, wrapped_block: false)
5
+ if wrapped_block
6
6
  module_eval <<-RUBY, __FILE__, __LINE__ + 1
7
- def #{name}(*args) # def mute(*args)
8
- unless instrumenter # unless instrumenter
9
- return yield if block_given? # return yield if block_given?
10
- return # return
11
- end # end
12
- #
13
- instrumenter.#{name}(*args) { yield } # instrumenter.mute(*args) { yield }
14
- end # end
7
+ def #{name}(...) # def mute(...)
8
+ unless instrumenter # unless instrumenter
9
+ return yield if block_given? # return yield if block_given?
10
+ return # return
11
+ end # end
12
+ #
13
+ instrumenter.#{name}(...) # instrumenter.mute(...)
14
+ end # end
15
15
  RUBY
16
16
  else
17
17
  module_eval <<-RUBY, __FILE__, __LINE__ + 1
18
- def #{name}(*args) # def config(*args)
19
- instrumenter&.#{name}(*args) # instrumenter&.config(*args)
20
- end # end
18
+ def #{name}(...) # def config(...)
19
+ instrumenter&.#{name}(...) # instrumenter&.config(...)
20
+ end # end
21
21
  RUBY
22
22
  end
23
23
  end
@@ -17,7 +17,8 @@ module Skylight
17
17
  @logger.<<(*args) if logger_out != $stdout && logger_out != $stderr
18
18
  end
19
19
 
20
- def close; end
20
+ def close
21
+ end
21
22
  end
22
23
 
23
24
  module Logging
@@ -10,7 +10,6 @@
10
10
  require "erb"
11
11
  require "optparse"
12
12
  require "stringio"
13
- require "abbrev"
14
13
  require "highline/system_extensions"
15
14
  require "highline/question"
16
15
  require "highline/menu"
@@ -3,5 +3,5 @@ module Skylight
3
3
  # for compatibility with semver when it is parsed by the rust agent.
4
4
  # This string will be transformed in the gemspec to "5.0.0.alpha"
5
5
  # to conform with rubygems.
6
- VERSION = "5.3.4".freeze
6
+ VERSION = "6.0.4".freeze
7
7
  end
@@ -49,7 +49,8 @@ module Skylight
49
49
  # Fallback
50
50
  unless defined?(VM::GC)
51
51
  class GC
52
- def enable; end
52
+ def enable
53
+ end
53
54
 
54
55
  def total_time
55
56
  0
data/lib/skylight.rb CHANGED
@@ -202,9 +202,10 @@ module Skylight
202
202
 
203
203
  instrumenter_method :config
204
204
 
205
- instrumenter_method :mute, block: true
206
- instrumenter_method :unmute, block: true
207
- instrumenter_method :muted?
205
+ instrumenter_method :mute, wrapped_block: true
206
+ instrumenter_method :unmute, wrapped_block: true
207
+ instrumenter_method :tracing_muted?
208
+ instrumenter_method :endpoint_assignment_muted?
208
209
 
209
210
  # End a span
210
211
  instrumenter_method :done
@@ -212,7 +213,7 @@ module Skylight
212
213
  instrumenter_method :broken!
213
214
 
214
215
  # Temporarily disable
215
- instrumenter_method :disable, block: true
216
+ instrumenter_method :disable, wrapped_block: true
216
217
 
217
218
  # Runs the shutdown procedure in the background.
218
219
  # This should do little more than unsubscribe from all ActiveSupport::Notifications
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.4
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.21.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: syntax_tree
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: timecop
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +223,6 @@ files:
209
223
  - README.md
210
224
  - bin/skylight
211
225
  - ext/extconf.rb
212
- - ext/libskylight.yml
213
226
  - ext/skylight_memprof.c
214
227
  - ext/skylight_native.c
215
228
  - ext/skylight_native.h
@@ -281,6 +294,7 @@ files:
281
294
  - lib/skylight/probes/action_dispatch.rb
282
295
  - lib/skylight/probes/action_dispatch/request_id.rb
283
296
  - lib/skylight/probes/action_dispatch/routing/route_set.rb
297
+ - lib/skylight/probes/action_dispatch/show_exceptions.rb
284
298
  - lib/skylight/probes/action_view.rb
285
299
  - lib/skylight/probes/active_job.rb
286
300
  - lib/skylight/probes/active_job_enqueue.rb
@@ -378,14 +392,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
378
392
  requirements:
379
393
  - - ">="
380
394
  - !ruby/object:Gem::Version
381
- version: '2.6'
395
+ version: '2.7'
382
396
  required_rubygems_version: !ruby/object:Gem::Requirement
383
397
  requirements:
384
398
  - - ">="
385
399
  - !ruby/object:Gem::Version
386
400
  version: '0'
387
401
  requirements: []
388
- rubygems_version: 3.3.3
402
+ rubygems_version: 3.4.10
389
403
  signing_key:
390
404
  specification_version: 4
391
405
  summary: Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps.
data/ext/libskylight.yml DELETED
@@ -1,9 +0,0 @@
1
- version: "5.1.0-cd7d6af"
2
- checksums:
3
- x86-linux: "921381c014b87e67fa2049e9891377f737b5abb10963228ddcd65caede7b58d2"
4
- x86_64-linux: "e89f0ec3f39ecca060b757fcd1b9d8f38e5846f65579785454bb69a968e8528f"
5
- x86_64-linux-musl: "78239bc7581c124c2a00cfbc42ec6cf73e7ed280ed1a27d85bb915531a683f1a"
6
- x86_64-darwin: "faa7363ada4bf476511f6700856fd91b9d61fed055297417ce41d83aa11fe07c"
7
- aarch64-linux: "e172515a6f7923552e842d21319b3630bdc6e264b6a434b43d2db682dcde18cc"
8
- aarch64-linux-musl: "1665adf149bd2c12e409f387de5d796ef9e55d4cfd9a886f69c42cab59a51926"
9
- aarch64-darwin: "027bec103668e89f318b55ddc2a48ca5c84c7a6dcd1dd273cc9b7b46d918ef12"