skylight 7.0.0 → 7.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3776b9d0ac094a7a81dc034b8a0c05d1a9caa55c21c17556a2e9c01e9eeaf3e7
4
- data.tar.gz: ca55da2082e52d7ea119cf2c3a6743c28f0d72a475c31768df01f649b6a1c980
3
+ metadata.gz: 774c7246629b4496c5856c89f79c06d8f41bcbb3e57f674facc3a9dbaec02247
4
+ data.tar.gz: a3a0a2e50567c145b00bdcef640b9812856a2c30099c618b19c7cbbf46018432
5
5
  SHA512:
6
- metadata.gz: b5cda810a0dde1ecb00b676d39400c363ecb3b0c7705b97b096852fbfa74e41b9d52da642e4a5a322874f1e02fb4977563db3ad4042883e3cb3db3a0bec28383
7
- data.tar.gz: d466244683b532a00efb3aa48162f12e284be24d6b981e3824deaf473c1f272d0cd731fa3d34ecc0d996b63b600267885dcf130c175638f49e1047d1afbea956
6
+ metadata.gz: 897f0dbcb877701b768a18060af7b35fb691a61bb464f6dbda10ff773c5a0b0e701a341a6adaaf1b66594cef803198e66d9f609bba1c57bbcc88dfd4f430e701
7
+ data.tar.gz: dda53c4b01214548fd9ecdfd708eb6629a7970d74b2fadcf0be1e63d332b3d04c3d0835197cb31c5d6a422457d6f0971cb53cb9973ee97188e989d516dc5aab4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 7.1.0 (January 20, 2025)
2
+ - BREAKING end support for Rails < 7.2.
3
+ - IMPROVEMENT better support for Grape 3.x
4
+ - IMPROVEMENT better ActiveRecord instrumentation for async queries in Rails 8.2
5
+
1
6
  ## 7.0.0 (September 16, 2025)
2
7
 
3
8
  - IMPROVEMENT Initial (beta) support for AWS Lambda
@@ -21,8 +21,7 @@
21
21
 
22
22
  #define CHECK_NUMERIC(VAL) \
23
23
  do { \
24
- if (TYPE(VAL) != T_BIGNUM && \
25
- TYPE(VAL) != T_FIXNUM) { \
24
+ if (!RB_INTEGER_TYPE_P(VAL)) { \
26
25
  rb_raise(rb_eArgError, "expected " #VAL " to be numeric but was '%s' (%s [%i])", \
27
26
  TO_S(VAL), rb_obj_classname(VAL), TYPE(VAL)); \
28
27
  return Qnil; \
@@ -19,9 +19,7 @@ module Skylight
19
19
  # @api private
20
20
  MUTEX = Mutex.new
21
21
 
22
- DEFAULT_IGNORED_ENDPOINTS = %w[
23
- Rails::HealthController#show
24
- ].freeze
22
+ DEFAULT_IGNORED_ENDPOINTS = %w[Rails::HealthController#show].freeze
25
23
 
26
24
  # Map environment variable keys with Skylight configuration keys
27
25
  ENV_TO_KEY = {
@@ -148,12 +148,25 @@ module Skylight
148
148
  p_user, p_pass = uri.userinfo.split(/:/) if uri.userinfo
149
149
  end
150
150
 
151
- opts = {}
152
- opts[:use_ssl] = use_ssl
151
+ opts = { use_ssl: use_ssl }
153
152
 
154
- opts[:ca_file] = Util::SSL.ca_cert_file_or_default if use_ssl
153
+ if use_ssl
154
+ # Create a cert store that doesn't enable CRL checking.
155
+ # OpenSSL 3.x may enable CRL checking by default, which fails when
156
+ # the CRL distribution point is unreachable.
157
+ begin
158
+ cert_store = OpenSSL::X509::Store.new
159
+ cert_store.set_default_paths
160
+ ca_file = Util::SSL.ca_cert_file_or_default
161
+ cert_store.add_file(ca_file) if ca_file && File.exist?(ca_file)
162
+ opts[:cert_store] = cert_store
163
+ rescue OpenSSL::X509::StoreError => e
164
+ log "failed to configure cert store: #{e.message}, using defaults"
165
+ end
166
+ opts[:verify_mode] = OpenSSL::SSL::VERIFY_PEER
167
+ end
155
168
 
156
- Net::HTTP.start(host, port, p_host, p_port, p_user, p_pass, use_ssl: use_ssl) do |http|
169
+ Net::HTTP.start(host, port, p_host, p_port, p_user, p_pass, **opts) do |http|
157
170
  http.request_get path do |resp|
158
171
  case resp
159
172
  when Net::HTTPSuccess
@@ -12,7 +12,7 @@ module Skylight
12
12
  register "future_result.active_record"
13
13
 
14
14
  def normalize(_trace, _name, payload)
15
- ["db.future_result", "Async #{payload[:args][1] || "Query"}"]
15
+ ["db.future_result", "Async #{payload[:name] || "Query"}"]
16
16
  end
17
17
  end
18
18
  end
@@ -19,8 +19,13 @@ module Skylight
19
19
  end
20
20
 
21
21
  def get_namespace(endpoint)
22
- # slice off preceding slash for data continuity
23
- ::Grape::Namespace.joined_space_path(endpoint.namespace_stackable(:namespace)).to_s[1..]
22
+ if endpoint.respond_to?(:namespace_stackable)
23
+ # Grape 2.x
24
+ ::Grape::Namespace.joined_space_path(endpoint.namespace_stackable(:namespace)).to_s[1..]
25
+ else
26
+ # Grape 3.x
27
+ endpoint.namespace.to_s[1..]
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -31,7 +31,12 @@ module Skylight
31
31
  ep = endpoint.options[:for]
32
32
  return ep.name if ep.name
33
33
 
34
- ep.base.name if ep.respond_to?(:base) && ep.base.respond_to?(:name)
34
+ if ep.respond_to?(:base) && ep.base.respond_to?(:name)
35
+ ep.base.name
36
+ elsif ep.respond_to?(:to_s)
37
+ # grape >= 3.1 removes the `base` attr_reader but delegates to_s to :@base
38
+ ep.to_s
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -38,29 +38,27 @@ module Skylight
38
38
  end
39
39
  end
40
40
 
41
- # Applied to FutureResult
42
- module Instrumentation
41
+ # Applied to FutureResult (Rails <= 8.1)
42
+ # Handles both the outer instrumentation and the execute_or_wait hook
43
+ module FutureResultInstrumentation
43
44
  def result(*, **)
44
- # This instruments the whole FutureResult so that we know when we were executing (potenially) async.
45
- ActiveSupport::Notifications.instrument("future_result.active_record", { args: @args, kwargs: @kwargs }) do
46
- super
47
- end
45
+ name = @args&.[](1)
46
+
47
+ ActiveSupport::Notifications.instrument("future_result.active_record", { name: name }) { super }
48
48
  end
49
49
 
50
50
  private
51
51
 
52
52
  def execute_or_wait(*, **)
53
- # At this point we're actually waiting for the query to have finished executing.
54
-
55
53
  begin
56
54
  # If the query has already started async, the @event_buffer will be defined.
57
55
  # We grab the events (currently only the SQL queries), extend them with our
58
56
  # special methods and notify Skylight.
59
- # We act as if the event has just stared, though the query may already have been
57
+ # We act as if the event has just started, though the query may already have been
60
58
  # running. This means we're essentially just logging blocking time right now.
61
59
 
62
60
  # Dup here just in case more get added somehow during the super call
63
- events = @event_buffer&.instance_variable_get(:@events).dup
61
+ events = @event_buffer&.instance_variable_get(:@events)&.dup
64
62
 
65
63
  events&.each do |event|
66
64
  event.singleton_class.prepend(AsyncEventExtensions)
@@ -78,9 +76,48 @@ module Skylight
78
76
  end
79
77
  end
80
78
 
79
+ # Applied to FutureResult (Rails >= 8.2)
80
+ module FutureResultInstrumentationRails82
81
+ def result(*, **)
82
+ name = @intent&.name
83
+
84
+ ActiveSupport::Notifications.instrument("future_result.active_record", { name: name }) { super }
85
+ end
86
+ end
87
+
88
+ # Applied to QueryIntent (Rails >= 8.2)
89
+ module QueryIntentInstrumentation
90
+ private
91
+
92
+ def execute_or_wait(*, **)
93
+ begin
94
+ # If the query has already started async, the @event_buffer will be defined.
95
+ events = @event_buffer&.instance_variable_get(:@events)&.dup
96
+
97
+ events&.each do |event|
98
+ event.singleton_class.prepend(AsyncEventExtensions)
99
+ event.__sk_start!
100
+ end
101
+ rescue StandardError => e
102
+ Skylight.error("Unable to start events for QueryIntent: #{e}")
103
+ end
104
+
105
+ super
106
+ ensure
107
+ events&.reverse_each(&:__sk_finish!)
108
+ end
109
+ end
110
+
81
111
  class Probe
82
112
  def install
83
- ::ActiveRecord::FutureResult.prepend(Instrumentation)
113
+ if defined?(::ActiveRecord::ConnectionAdapters::QueryIntent)
114
+ # Rails >= 8.2
115
+ ::ActiveRecord::FutureResult.prepend(FutureResultInstrumentationRails82)
116
+ ::ActiveRecord::ConnectionAdapters::QueryIntent.prepend(QueryIntentInstrumentation)
117
+ else
118
+ # Rails <= 8.1
119
+ ::ActiveRecord::FutureResult.prepend(FutureResultInstrumentation)
120
+ end
84
121
  end
85
122
  end
86
123
  end
@@ -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 = "7.0.0".freeze
6
+ VERSION = "7.1.0".freeze
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 7.1.0
18
+ version: 7.2.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 7.1.0
25
+ version: 7.2.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: beefcake
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -85,14 +85,14 @@ dependencies:
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 13.0.1
88
+ version: '13.0'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 13.0.1
95
+ version: '13.0'
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: rake-compiler
98
98
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +205,20 @@ dependencies:
205
205
  - - ">="
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
+ - !ruby/object:Gem::Dependency
209
+ name: ostruct
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
208
222
  email:
209
223
  - engineering@tilde.io
210
224
  executables:
@@ -398,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
398
412
  - !ruby/object:Gem::Version
399
413
  version: '0'
400
414
  requirements: []
401
- rubygems_version: 3.6.2
415
+ rubygems_version: 3.6.9
402
416
  specification_version: 4
403
417
  summary: Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps.
404
418
  test_files: []