skylight 5.1.1 → 5.2.0.beta

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: 2881749e5739ff283ad0f62f4db4c22697a6ee17a9f0f47f80839591f49e104c
4
- data.tar.gz: 8c8b28c31dc351e9a2c3e847907f90917aede27e6cef2c0881392769c9b5510d
3
+ metadata.gz: b66ffaaf8386f9d50b7fd82087d0fb04e5326701e027f640912e16a9238908e9
4
+ data.tar.gz: 8318788b892615da50939c6d4e760b65be8c1842ec403a0886f0c78f99a38f36
5
5
  SHA512:
6
- metadata.gz: ee70e27064ac11830d29ee7fdf52886a0b776afe3e36aec79e5c2da40e6a0fe09f40ff46d4e7c5947587bd94428bf3b1dd40274fdc4fdbc93836aabedf0b5f1d
7
- data.tar.gz: c3441c25d153055d0461b23c01416bf773c612c3af607dd8b9cf142491f5237b205e4da5ab1edcf653327199cdcbceba3170a4c101560dc875d991b6945a98c2
6
+ metadata.gz: b0c4222c14f45e9129a8fe0a61e1d895d2d5d1996b29879b106ffa89ee190ffc7c84d41513e56954467ad502304ac94488ce7ded24271e96630bd49e0cc4b34e
7
+ data.tar.gz: fd8105a613dd0b44aaa3d23580a83aa3b92ca665b08c47cadb87c87368b77834957730c5eef5a83a9794f92153e5b329301fbd6d7655c2e765dd0ebd157f8e0b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 5.2.0-beta (7 September 2021)
2
+
3
+ - [IMPROVEMENT] Add Rack::Builder probe to better instrument middlewares in Sinatra and other Builder-based apps
4
+ - [BUGFIX] Fix an issue in which trace logging could output the incorrect request ID.
5
+ - [BUGFIX] fix native extension configuration for arm64 hosts
6
+
1
7
  ## 5.1.1 (May 27, 2021)
2
8
 
3
9
  - [BUGFIX] Correct ruby version requirement in skylight.gemspec
data/ext/libskylight.yml CHANGED
@@ -1,11 +1,11 @@
1
- # commit b6bb0714913a5be54f4eac717d5096dc7ba5f3eb
1
+ # commit fd0d58cc393e044e5b80ab419e61ebbaec902181
2
2
  ---
3
- version: "5.1.0-0d59831"
3
+ version: "5.1.0-ab315e7"
4
4
  checksums:
5
- x86-linux: "e15fff9269f5451302aaee56b4d4631c86f979298bc22536f28f884c170c127f"
6
- x86_64-linux: "be95b9c91dffb0133b57183d160cad700213703a87f52488cf114a4fff92ff4d"
7
- x86_64-linux-musl: "945ebefa0384e23121bc1674f0eda0600aef204599e5819bdbecd6d62252b769"
8
- x86_64-darwin: "d98ee1d331394ac43bd37f2d3d5d591a41d912dfa2c3e5d0b21d97f7a5198cf1"
9
- aarch64-linux: "b6add5dda52a2cae4b5e3899a5e0c938049385443d82acbd1a8a2fb0d8502933"
10
- aarch64-linux-musl: "667030ade09a69a664380262ec1e6ceeb77f49585201e670528f4cd52d3def86"
11
- aarch64-darwin: "d3225034d18d99e358ace24cf951468feaf3b83f0b33e32965bc2139e0300505"
5
+ x86-linux: "4ea5ab2ed7789e6d041ce4cc0384d3fbd8bb7462e8eca879d6c2b242c35eb3b4"
6
+ x86_64-linux: "8edb5247e982c3571d19e7e607f01c69b5eb657ae310e3bf00e83c1330fdb794"
7
+ x86_64-linux-musl: "35c4ae1c66b529750358c0acb36d33da1d3ffaf17336ff882ce6ce9a632d9be6"
8
+ x86_64-darwin: "5d0b3a210931714ad17b8226aac59a39760d7fe8f86a13460dda517bc2886193"
9
+ aarch64-linux: "1ce0d0f1e7bf9c6c92052080b18738c2f775a01d2004ee434cef74b557a3cafd"
10
+ aarch64-linux-musl: "f186576b4164d0a4135d5fde3202a3e95c38fc0ea35413288de6bb28c9fc9ac4"
11
+ aarch64-darwin: "a4f7fb9e483933c194ade230381e3da2f4e6f4dee76550f6f098fc6b46967b3d"
@@ -119,7 +119,7 @@ module Skylight
119
119
  end
120
120
  config.logger = logger
121
121
 
122
- config.set(:'daemon.lazy_start', false)
122
+ config.set(:"daemon.lazy_start", false)
123
123
 
124
124
  started = Skylight.start!(config)
125
125
 
@@ -32,9 +32,9 @@ module Skylight
32
32
  -"COMPONENT" => :component,
33
33
  -"REPORT_RAILS_ENV" => :report_rails_env,
34
34
  # == Deploy settings ==
35
- -"DEPLOY_ID" => :'deploy.id',
36
- -"DEPLOY_GIT_SHA" => :'deploy.git_sha',
37
- -"DEPLOY_DESCRIPTION" => :'deploy.description',
35
+ -"DEPLOY_ID" => :"deploy.id",
36
+ -"DEPLOY_GIT_SHA" => :"deploy.git_sha",
37
+ -"DEPLOY_DESCRIPTION" => :"deploy.description",
38
38
  # == Logging ==
39
39
  -"LOG_FILE" => :log_file,
40
40
  -"LOG_LEVEL" => :log_level,
@@ -69,35 +69,35 @@ module Skylight
69
69
  -"REPORT_HTTP_DISABLED" => :report_http_disabled,
70
70
  # == Native agent settings ==
71
71
  #
72
- -"LAZY_START" => :'daemon.lazy_start',
73
- -"DAEMON_EXEC_PATH" => :'daemon.exec_path',
74
- -"DAEMON_LIB_PATH" => :'daemon.lib_path',
75
- -"PIDFILE_PATH" => :'daemon.pidfile_path',
76
- -"SOCKDIR_PATH" => :'daemon.sockdir_path',
77
- -"BATCH_QUEUE_DEPTH" => :'daemon.batch_queue_depth',
78
- -"BATCH_SAMPLE_SIZE" => :'daemon.batch_sample_size',
79
- -"BATCH_FLUSH_INTERVAL" => :'daemon.batch_flush_interval',
80
- -"DAEMON_TICK_INTERVAL" => :'daemon.tick_interval',
81
- -"DAEMON_LOCK_CHECK_INTERVAL" => :'daemon.lock_check_interval',
82
- -"DAEMON_INACTIVITY_TIMEOUT" => :'daemon.inactivity_timeout',
83
- -"CLIENT_MAX_TRIES" => :'daemon.max_connect_tries',
84
- -"CLIENT_CONN_TRY_WIN" => :'daemon.connect_try_window',
85
- -"MAX_PRESPAWN_JITTER" => :'daemon.max_prespawn_jitter',
86
- -"DAEMON_WAIT_TIMEOUT" => :'daemon.wait_timeout',
87
- -"CLIENT_CHECK_INTERVAL" => :'daemon.client_check_interval',
88
- -"CLIENT_QUEUE_DEPTH" => :'daemon.client_queue_depth',
89
- -"CLIENT_WRITE_TIMEOUT" => :'daemon.client_write_timeout',
90
- -"SSL_CERT_PATH" => :'daemon.ssl_cert_path',
91
- -"ENABLE_TCP" => :'daemon.enable_tcp',
92
- -"TCP_PORT" => :'daemon.tcp_port',
72
+ -"LAZY_START" => :"daemon.lazy_start",
73
+ -"DAEMON_EXEC_PATH" => :"daemon.exec_path",
74
+ -"DAEMON_LIB_PATH" => :"daemon.lib_path",
75
+ -"PIDFILE_PATH" => :"daemon.pidfile_path",
76
+ -"SOCKDIR_PATH" => :"daemon.sockdir_path",
77
+ -"BATCH_QUEUE_DEPTH" => :"daemon.batch_queue_depth",
78
+ -"BATCH_SAMPLE_SIZE" => :"daemon.batch_sample_size",
79
+ -"BATCH_FLUSH_INTERVAL" => :"daemon.batch_flush_interval",
80
+ -"DAEMON_TICK_INTERVAL" => :"daemon.tick_interval",
81
+ -"DAEMON_LOCK_CHECK_INTERVAL" => :"daemon.lock_check_interval",
82
+ -"DAEMON_INACTIVITY_TIMEOUT" => :"daemon.inactivity_timeout",
83
+ -"CLIENT_MAX_TRIES" => :"daemon.max_connect_tries",
84
+ -"CLIENT_CONN_TRY_WIN" => :"daemon.connect_try_window",
85
+ -"MAX_PRESPAWN_JITTER" => :"daemon.max_prespawn_jitter",
86
+ -"DAEMON_WAIT_TIMEOUT" => :"daemon.wait_timeout",
87
+ -"CLIENT_CHECK_INTERVAL" => :"daemon.client_check_interval",
88
+ -"CLIENT_QUEUE_DEPTH" => :"daemon.client_queue_depth",
89
+ -"CLIENT_WRITE_TIMEOUT" => :"daemon.client_write_timeout",
90
+ -"SSL_CERT_PATH" => :"daemon.ssl_cert_path",
91
+ -"ENABLE_TCP" => :"daemon.enable_tcp",
92
+ -"TCP_PORT" => :"daemon.tcp_port",
93
93
  # == Legacy env vars ==
94
94
  #
95
- -"AGENT_LOCKFILE" => :'agent.lockfile',
96
- -"AGENT_SOCKFILE_PATH" => :'agent.sockfile_path',
95
+ -"AGENT_LOCKFILE" => :"agent.lockfile",
96
+ -"AGENT_SOCKFILE_PATH" => :"agent.sockfile_path",
97
97
  # == User config settings ==
98
98
  -"USER_CONFIG_PATH" => :user_config_path,
99
99
  # == Heroku settings ==
100
- -"HEROKU_DYNO_INFO_PATH" => :'heroku.dyno_info_path',
100
+ -"HEROKU_DYNO_INFO_PATH" => :"heroku.dyno_info_path",
101
101
  # == Source Location ==
102
102
  -"SOURCE_LOCATION_IGNORED_GEMS" => :source_location_ignored_gems,
103
103
  -"SOURCE_LOCATION_CACHE_SIZE" => :source_location_cache_size
@@ -135,22 +135,22 @@ module Skylight
135
135
  sinatra_route_prefixes: false,
136
136
  enable_source_locations: true,
137
137
  # Deploys
138
- 'heroku.dyno_info_path': -"/etc/heroku/dyno",
138
+ "heroku.dyno_info_path": -"/etc/heroku/dyno",
139
139
  report_rails_env: true,
140
140
  # Daemon
141
- 'daemon.lazy_start': true,
141
+ "daemon.lazy_start": true,
142
142
  hostname: Util::Hostname.default_hostname,
143
143
  report_max_spans_exceeded: false,
144
144
  prune_large_traces: true
145
145
  }
146
146
 
147
- ret[:'daemon.ssl_cert_path'] = Util::SSL.ca_cert_file_or_default unless Util::Platform::OS == -"darwin"
147
+ ret[:"daemon.ssl_cert_path"] = Util::SSL.ca_cert_file_or_default unless Util::Platform::OS == -"darwin"
148
148
 
149
149
  if Skylight.native?
150
150
  native_path = Skylight.libskylight_path
151
151
 
152
- ret[:'daemon.lib_path'] = native_path
153
- ret[:'daemon.exec_path'] = File.join(native_path, "skylightd")
152
+ ret[:"daemon.lib_path"] = native_path
153
+ ret[:"daemon.exec_path"] = File.join(native_path, "skylightd")
154
154
  end
155
155
 
156
156
  ret
@@ -211,12 +211,12 @@ module Skylight
211
211
 
212
212
  # Maps legacy config keys to new config keys
213
213
  def self.legacy_keys
214
- @legacy_keys ||= { 'agent.sockfile_path': :'daemon.sockdir_path', 'agent.lockfile': :'daemon.pidfile_path' }
214
+ @legacy_keys ||= { "agent.sockfile_path": :"daemon.sockdir_path", "agent.lockfile": :"daemon.pidfile_path" }
215
215
  end
216
216
 
217
217
  def self.validators
218
218
  @validators ||=
219
- { 'agent.interval': [->(v, _c) { v.is_a?(Integer) && v > 0 }, "must be an integer greater than 0"] }
219
+ { "agent.interval": [->(v, _c) { v.is_a?(Integer) && v > 0 }, "must be an integer greater than 0"] }
220
220
  end
221
221
 
222
222
  # @api private
@@ -334,8 +334,8 @@ module Skylight
334
334
  # TODO: Move this out of the validate! method: https://github.com/tildeio/direwolf-agent/issues/273
335
335
  # FIXME: Why not set the sockdir_path and pidfile_path explicitly?
336
336
  # That way we don't have to keep this in sync with the Rust repo.
337
- sockdir_path = File.expand_path(self[:'daemon.sockdir_path'] || ".", root)
338
- pidfile_path = File.expand_path(self[:'daemon.pidfile_path'] || "skylight.pid", sockdir_path)
337
+ sockdir_path = File.expand_path(self[:"daemon.sockdir_path"] || ".", root)
338
+ pidfile_path = File.expand_path(self[:"daemon.pidfile_path"] || "skylight.pid", sockdir_path)
339
339
 
340
340
  check_file_permissions(pidfile_path, "daemon.pidfile_path or daemon.sockdir_path")
341
341
  check_sockdir_permissions(sockdir_path)
@@ -588,7 +588,7 @@ module Skylight
588
588
  end
589
589
 
590
590
  def on_heroku?
591
- File.exist?(get(:'heroku.dyno_info_path'))
591
+ File.exist?(get(:"heroku.dyno_info_path"))
592
592
  end
593
593
 
594
594
  private
@@ -3,6 +3,8 @@ require "securerandom"
3
3
  module Skylight
4
4
  # @api private
5
5
  class Middleware
6
+ SKYLIGHT_REQUEST_ID = "skylight.request_id".freeze
7
+
6
8
  class BodyProxy
7
9
  def initialize(body, &block)
8
10
  @body = body
@@ -81,7 +83,8 @@ module Skylight
81
83
  set_request_id(env)
82
84
 
83
85
  if Skylight.tracing?
84
- error "Already instrumenting. Make sure the Skylight Rack Middleware hasn't been added more than once."
86
+ debug "Already instrumenting. Make sure the Skylight Rack Middleware hasn't been added more than once."
87
+ return @app.call(env)
85
88
  end
86
89
 
87
90
  if env["REQUEST_METHOD"] == "HEAD"
@@ -108,7 +111,7 @@ module Skylight
108
111
 
109
112
  def log_context
110
113
  # Don't cache this, it will change
111
- { request_id: @current_request_id, inst: Skylight.instrumenter&.uuid }
114
+ { request_id: current_request_id, inst: Skylight.instrumenter&.uuid }
112
115
  end
113
116
 
114
117
  # Allow for overwriting
@@ -122,8 +125,10 @@ module Skylight
122
125
 
123
126
  # Request ID code based on ActionDispatch::RequestId
124
127
  def set_request_id(env)
128
+ return if env[SKYLIGHT_REQUEST_ID]
129
+
125
130
  existing_request_id = env["action_dispatch.request_id"] || env["HTTP_X_REQUEST_ID"]
126
- @current_request_id = env["skylight.request_id"] = make_request_id(existing_request_id)
131
+ self.current_request_id = env[SKYLIGHT_REQUEST_ID] = make_request_id(existing_request_id)
127
132
  end
128
133
 
129
134
  def make_request_id(request_id)
@@ -133,5 +138,13 @@ module Skylight
133
138
  def internal_request_id
134
139
  SecureRandom.uuid
135
140
  end
141
+
142
+ def current_request_id
143
+ Thread.current[SKYLIGHT_REQUEST_ID]
144
+ end
145
+
146
+ def current_request_id=(request_id)
147
+ Thread.current[SKYLIGHT_REQUEST_ID] = request_id
148
+ end
136
149
  end
137
150
  end
@@ -20,7 +20,7 @@ module Skylight
20
20
 
21
21
  def get_namespace(endpoint)
22
22
  # slice off preceding slash for data continuity
23
- ::Grape::Namespace.joined_space_path(endpoint.namespace_stackable(:namespace)).to_s[1..-1]
23
+ ::Grape::Namespace.joined_space_path(endpoint.namespace_stackable(:namespace)).to_s[1..]
24
24
  end
25
25
  end
26
26
  end
@@ -25,10 +25,10 @@ module Skylight
25
25
  # for Rails <= 5.2 ActionDispatch::MiddlewareStack::Middleware
26
26
  module Instrumentation
27
27
  def build(*)
28
- sk_instrument_middleware(super)
28
+ Instrumentation.sk_instrument_middleware(super)
29
29
  end
30
30
 
31
- def sk_instrument_middleware(middleware)
31
+ def self.sk_instrument_middleware(middleware)
32
32
  return middleware if middleware.is_a?(Skylight::Middleware)
33
33
 
34
34
  # Not sure how this would actually happen
@@ -0,0 +1,37 @@
1
+ module Skylight
2
+ module Probes
3
+ module Rack
4
+ module Builder
5
+ module Instrumentation
6
+ def use(middleware, *args, &block)
7
+ if @map
8
+ mapping = @map
9
+ @map = nil
10
+ @use << proc { |app| generate_map(app, mapping) }
11
+ end
12
+ @use << proc do |app|
13
+ middleware
14
+ .new(app, *args, &block)
15
+ .tap do |middleware_instance|
16
+ Skylight::Probes::Middleware::Instrumentation.sk_instrument_middleware(middleware_instance)
17
+ end
18
+ end
19
+ end
20
+ ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
21
+ end
22
+
23
+ class Probe
24
+ def install
25
+ if defined?(::Rack.release) && Gem::Version.new(::Rack.release) >= ::Gem::Version.new("1.4") &&
26
+ defined?(::Rack::Builder)
27
+ require "skylight/probes/middleware"
28
+ ::Rack::Builder.prepend(Instrumentation)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ register(:rack_builder, "Rack::Builder", "rack/builder", Skylight::Probes::Rack::Builder::Probe.new)
36
+ end
37
+ end
@@ -2,8 +2,8 @@ module Skylight
2
2
  module Probes
3
3
  module Sinatra
4
4
  module Instrumentation
5
- def build(*)
6
- use Skylight::Middleware
5
+ def setup_default_middleware(builder)
6
+ builder.use Skylight::Middleware
7
7
  super
8
8
  end
9
9
  end
@@ -99,8 +99,8 @@ module Skylight
99
99
 
100
100
  configure_logging(config, app)
101
101
 
102
- config[:'daemon.sockdir_path'] ||= tmp
103
- config[:'normalizers.render.view_paths'] = existent_paths(app.config.paths["app/views"]) + [Rails.root.to_s]
102
+ config[:"daemon.sockdir_path"] ||= tmp
103
+ config[:"normalizers.render.view_paths"] = existent_paths(app.config.paths["app/views"]) + [Rails.root.to_s]
104
104
 
105
105
  config[:env] ||= Rails.env.to_s if config[:report_rails_env]
106
106
 
@@ -1,2 +1,2 @@
1
1
  require "skylight"
2
- Skylight.probe(:sinatra_add_middleware, :sinatra, :tilt, :sequel)
2
+ Skylight.probe(:sinatra_add_middleware, :sinatra, :tilt, :sequel, :rack_builder)
@@ -52,15 +52,15 @@ module Skylight
52
52
  end
53
53
 
54
54
  def id
55
- config.get(:'deploy.id') || git_sha
55
+ config.get(:"deploy.id") || git_sha
56
56
  end
57
57
 
58
58
  def git_sha
59
- config.get(:'deploy.git_sha')
59
+ config.get(:"deploy.git_sha")
60
60
  end
61
61
 
62
62
  def description
63
- config.get(:'deploy.description')
63
+ config.get(:"deploy.description")
64
64
  end
65
65
  end
66
66
 
@@ -85,7 +85,7 @@ module Skylight
85
85
  private
86
86
 
87
87
  def get_info
88
- info_path = config[:'heroku.dyno_info_path']
88
+ info_path = config[:"heroku.dyno_info_path"]
89
89
 
90
90
  if File.exist?(info_path) && (info = JSON.parse(File.read(info_path)))
91
91
  info["release"]
@@ -38,8 +38,8 @@ module Skylight
38
38
  "x86"
39
39
  when /ppc|powerpc/
40
40
  "powerpc"
41
- when /^arm/
42
- "arm"
41
+ when /arm64|aarch64/
42
+ "aarch64"
43
43
  else
44
44
  cpu
45
45
  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 = "5.1.1".freeze
6
+ VERSION = "5.2.0-beta".freeze
7
7
  end
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.1.1
4
+ version: 5.2.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-28 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.15.0
145
+ version: 1.20.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.15.0
152
+ version: 1.20.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -296,6 +296,7 @@ files:
296
296
  - lib/skylight/probes/mongo.rb
297
297
  - lib/skylight/probes/mongoid.rb
298
298
  - lib/skylight/probes/net_http.rb
299
+ - lib/skylight/probes/rack_builder.rb
299
300
  - lib/skylight/probes/redis.rb
300
301
  - lib/skylight/probes/sequel.rb
301
302
  - lib/skylight/probes/sinatra.rb
@@ -378,9 +379,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
378
379
  version: '2.6'
379
380
  required_rubygems_version: !ruby/object:Gem::Requirement
380
381
  requirements:
381
- - - ">="
382
+ - - ">"
382
383
  - !ruby/object:Gem::Version
383
- version: '0'
384
+ version: 1.3.1
384
385
  requirements: []
385
386
  rubygems_version: 3.2.15
386
387
  signing_key: