skylight 4.1.1.beta → 4.2.0.beta

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: cdfdccaa0d3d3b5163035985d500bee74aa687de5c8e3e8f58e661684131d8ea
4
- data.tar.gz: 85118921b59286d9417ce14b3078ce34b77c34b2bb7a103979a3b3612127ea80
3
+ metadata.gz: d91b4f08958f93027e62e1d08cc6047462c39c9df2c98de8e27f3dcb4d4f10ce
4
+ data.tar.gz: 3a35d4f4c300d77dd911d964f405d42a026c447d6dc8d1a0d69a1301f0ec5d3d
5
5
  SHA512:
6
- metadata.gz: db7577c627384f1ffdb99fd4c442f00acb753cd5d612b2cb2ee58988edd7085cda9378858df850082077e26bd1cbfe4835b83f5fccc68752de2606d8fd1caf90
7
- data.tar.gz: 550a3ff7eb92ae32a60bbf04286358540b387de49863a9df8b9ce5388c9e56691b24351bc5c923e2bdcb744d4a7351bb47b7251427db8b2cab6172ef0ae12e5e
6
+ metadata.gz: eb320617e3176912f281b45ee47f7a09b3ac7f71d2acea26505beed0c3d05910249f6ced4e4c304addfa56a9cf1cf66ef199f0af1d0e378892ef4141e4830860
7
+ data.tar.gz: 3a86a8b24adda0054a4c3a8945df3f97559b44a42dfab2c954a6d361cd7e2a4c23407bd6a2db01480915a690e2ba60e4c47d706c99751810879973f699054247
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- ## 4.1.1-beta
1
+ ## 4.2.0-beta
2
+ * [FEATURE] Add `Skylight.mute` and `Skylight.unmute` blocks to selectively disable and re-enable instrumentation
3
+ * [IMPROVEMENT] Revise agent authorization strategy (fixes some issues related to activation for background jobs)
4
+ * [IMPROVEMENT] Fix Rails 6 deprecation warnings
5
+
6
+ ## 4.1.2
7
+ * [BUGFIX] Correct an issue where the delayed_job probe may not be activated on startup
8
+
9
+ ## 4.1.1
10
+ * [BUGFIX] Fix Skylight installation when bundled with edge rails [Issue #132](https://github.com/skylightio/skylight-ruby/issues/132)
2
11
  * [IMPROVEMENT] Improve socket retry handling in skylightd
3
12
 
4
13
  ## 4.1.0 (June 3, 2019)
data/ext/extconf.rb CHANGED
@@ -6,19 +6,8 @@ require "fileutils"
6
6
 
7
7
  $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
8
8
 
9
- require "skylight/version"
10
-
11
- # Don't use the gem for dev
12
- if File.exist?(File.expand_path("../Gemfile", __dir__))
13
- # This approach won't work in production since skylight-core isn't in the skylight gem
14
- $LOAD_PATH.unshift File.expand_path("../skylight-core/lib", __dir__)
15
- else
16
- # Is there a better way to get this into lib?
17
- gem "skylight-core", Skylight::VERSION.tr("-", ".")
18
- end
19
-
20
9
  require "skylight/native_ext_fetcher"
21
- require "skylight/core/util/platform"
10
+ require "skylight/util/platform"
22
11
 
23
12
  # Util allowing proxying writes to multiple location
24
13
  class MultiIO
@@ -35,7 +24,7 @@ class MultiIO
35
24
  end
36
25
  end
37
26
 
38
- include Skylight::Core::Util
27
+ include Skylight::Util
39
28
 
40
29
  SKYLIGHT_INSTALL_LOG = File.expand_path("install.log", __dir__)
41
30
  SKYLIGHT_REQUIRED = ENV.key?("SKYLIGHT_REQUIRED") && ENV["SKYLIGHT_REQUIRED"] !~ /^false$/i
data/ext/libskylight.yml CHANGED
@@ -1,7 +1,7 @@
1
- version: "4.0.0-4f6f5da"
1
+ version: "4.0.0-d262d98"
2
2
  checksums:
3
- x86-linux: "d0c1ae51a2c4c0038df985e808f3ff8ce043e8cb0670027ef825bf9b5ae96dc8"
4
- x86_64-linux: "c5178f140882406c19700c9488150d5b891e8f47fd685f40595d1ec76c8f4667"
5
- x86_64-linux-musl: "8b9d599e7000c776f5b951baf0646cacee49c326883bfd7e0e2b5a03d9deab97"
6
- x86_64-darwin: "c5611ef825fefee403b4722e87f6ef38ae802a8a7f2c702280ee880c382a7308"
7
- x86_64-freebsd: "151d374739099a04373945cb4784240437ede4aaafe0400f47317ff63693bd15"
3
+ x86-linux: "2b104d93829722c841202dc770a43d65db2a96083638aea6f68310f74e051ace"
4
+ x86_64-linux: "9573011a562944b869acdb8fa464108c2dff31d663ca182240377c22681c4f1e"
5
+ x86_64-linux-musl: "aeb0e7aaef0b6f113b80d3ee458a815e70d047e4f4722a1f57d21f292a4d11ab"
6
+ x86_64-darwin: "3de86542427fa7e47a0c1d0ec44f71b2851ecb6aef9d26875d6f7dd8c536194b"
7
+ x86_64-freebsd: "871c12ea4a5abada8e8ca005362ca0d2870e7d0f839b542f4780abeee042b6d1"
@@ -334,6 +334,34 @@ trace_set_endpoint(VALUE self, VALUE endpoint) {
334
334
  return Qnil;
335
335
  }
336
336
 
337
+ static VALUE
338
+ trace_get_component(VALUE self) {
339
+ sky_trace_t* trace;
340
+ sky_buf_t component;
341
+
342
+ My_Struct(trace, sky_trace_t, consumed_trace_msg);
343
+
344
+ CHECK_FFI(
345
+ sky_trace_component(trace, &component),
346
+ "Trace#native_get_component");
347
+
348
+ return BUF2STR(component);
349
+ }
350
+
351
+ static VALUE
352
+ trace_set_component(VALUE self, VALUE component) {
353
+ sky_trace_t* trace;
354
+
355
+ CHECK_TYPE(component, T_STRING);
356
+ My_Struct(trace, sky_trace_t, consumed_trace_msg);
357
+
358
+ CHECK_FFI(
359
+ sky_trace_set_component(trace, STR2BUF(component)),
360
+ "Trace#native_set_component");
361
+
362
+ return Qnil;
363
+ }
364
+
337
365
  static VALUE
338
366
  trace_use_pruning(VALUE self) {
339
367
  sky_trace_t* trace;
@@ -569,6 +597,8 @@ void Init_skylight_native() {
569
597
  rb_define_method(rb_cTrace, "native_get_started_at", trace_get_started_at, 0);
570
598
  rb_define_method(rb_cTrace, "native_get_endpoint", trace_get_endpoint, 0);
571
599
  rb_define_method(rb_cTrace, "native_set_endpoint", trace_set_endpoint, 1);
600
+ rb_define_method(rb_cTrace, "native_get_component", trace_get_component, 0);
601
+ rb_define_method(rb_cTrace, "native_set_component", trace_set_component, 1);
572
602
  rb_define_method(rb_cTrace, "native_use_pruning", trace_use_pruning, 0);
573
603
  rb_define_method(rb_cTrace, "native_set_exception", trace_set_exception, 1);
574
604
  rb_define_method(rb_cTrace, "native_get_uuid", trace_get_uuid, 0);
@@ -184,7 +184,7 @@ module Skylight
184
184
  end
185
185
 
186
186
  def mac?
187
- Core::Util::Platform::OS == "darwin"
187
+ Util::Platform::OS == "darwin"
188
188
  end
189
189
 
190
190
  # NOTE: This check won't work correctly on Windows
@@ -1,7 +1,7 @@
1
1
  require "openssl"
2
2
  require "skylight/util/component"
3
3
  require "skylight/util/deploy"
4
- require "skylight/core/util/platform"
4
+ require "skylight/util/platform"
5
5
  require "skylight/util/hostname"
6
6
  require "skylight/util/ssl"
7
7
 
@@ -94,7 +94,7 @@ module Skylight
94
94
  report_rails_env: true
95
95
  )
96
96
 
97
- if Core::Util::Platform::OS != "darwin"
97
+ unless Util::Platform::OS == "darwin"
98
98
  ret[:'daemon.ssl_cert_path'] = Util::SSL.ca_cert_file_or_default
99
99
  ret[:'daemon.ssl_cert_dir'] = Util::SSL.ca_cert_dir
100
100
  end
@@ -276,7 +276,6 @@ module Skylight
276
276
  if token
277
277
  meta = {}
278
278
  meta.merge!(deploy.to_query_hash) if deploy
279
- meta[:component] = component.to_s if component
280
279
  meta[:reporting_env] = true if reporting_env?
281
280
 
282
281
  # A pipe should be a safe delimiter since it's not in the standard token
@@ -291,21 +290,24 @@ module Skylight
291
290
  @deploy ||= Util::Deploy.build(self)
292
291
  end
293
292
 
294
- def component
295
- @component ||= Util::Component.new(
296
- get(:env),
297
- get(:component) || get(:worker_component)
298
- )
293
+ def components
294
+ @components ||= {
295
+ web: Util::Component.new(
296
+ get(:env),
297
+ Util::Component::DEFAULT_NAME
298
+ ),
299
+ worker: Util::Component.new(
300
+ get(:env),
301
+ get(:component) || get(:worker_component),
302
+ force_worker: true
303
+ )
304
+ }
299
305
  rescue ArgumentError => e
300
306
  raise Core::ConfigError, e.message
301
307
  end
302
308
 
303
- def worker_context?
304
- component.worker?
305
- end
306
-
307
- def web_context?
308
- component.web?
309
+ def component
310
+ components[:web]
309
311
  end
310
312
 
311
313
  def as_json(*)
@@ -1,4 +1,4 @@
1
- require "skylight/core/util/platform"
1
+ require "skylight/util/platform"
2
2
 
3
3
  module Skylight
4
4
  # @api private
@@ -10,14 +10,14 @@ module Skylight
10
10
  end
11
11
 
12
12
  def self.libskylight_path
13
- ENV["SKYLIGHT_LIB_PATH"] || File.expand_path("../native/#{Core::Util::Platform.tuple}", __FILE__)
13
+ ENV["SKYLIGHT_LIB_PATH"] || File.expand_path("../native/#{Util::Platform.tuple}", __FILE__)
14
14
  end
15
15
 
16
16
  skylight_required = ENV.key?("SKYLIGHT_REQUIRED") && ENV["SKYLIGHT_REQUIRED"] !~ /^false$/i
17
17
 
18
18
  begin
19
19
  unless ENV.key?("SKYLIGHT_DISABLE_AGENT") && ENV["SKYLIGHT_DISABLE_AGENT"] !~ /^false$/i
20
- lib = "#{libskylight_path}/libskylight.#{Core::Util::Platform.libext}"
20
+ lib = "#{libskylight_path}/libskylight.#{Util::Platform.libext}"
21
21
 
22
22
  if File.exist?(lib)
23
23
  # First attempt to require the native extension
@@ -5,7 +5,7 @@ require "fileutils"
5
5
  require "digest/sha2"
6
6
  require "open3"
7
7
  require "skylight/util/ssl"
8
- require "skylight/core/util/proxy"
8
+ require "skylight/util/proxy"
9
9
 
10
10
  # Used from extconf.rb
11
11
  module Skylight
@@ -137,7 +137,7 @@ module Skylight
137
137
  #
138
138
  # If `ENV['HTTP_PROXY']` is set, it will be used as a proxy for this request.
139
139
  def http_get(host, port, use_ssl, path, out)
140
- if (http_proxy = Core::Util::Proxy.detect_url(ENV))
140
+ if (http_proxy = Util::Proxy.detect_url(ENV))
141
141
  log "connecting with proxy: #{http_proxy}"
142
142
  uri = URI.parse(http_proxy)
143
143
  p_host = uri.host
@@ -35,25 +35,20 @@ module Skylight
35
35
 
36
36
  def activate?(sk_config)
37
37
  return false unless super && sk_config
38
- activate_for_worker?(sk_config) || activate_for_web?(sk_config)
38
+ show_worker_activation_warning(sk_config)
39
+ true
39
40
  end
40
41
 
41
42
  # We must have an opt-in signal
42
- def activate_for_worker?(sk_config)
43
- return unless sk_config.worker_context?
44
-
43
+ def show_worker_activation_warning(sk_config)
45
44
  reasons = []
46
45
  reasons << "the 'active_job' probe is enabled" if sk_rails_config.probes.include?("active_job")
46
+ reasons << "the 'delayed_job' probe is enabled" if sk_rails_config.probes.include?("delayed_job")
47
47
  reasons << "SKYLIGHT_ENABLE_SIDEKIQ is set" if sk_config.enable_sidekiq?
48
48
 
49
49
  return if reasons.empty?
50
50
 
51
51
  sk_config.logger.warn("Activating Skylight for Background Jobs because #{reasons.to_sentence}")
52
- true
53
- end
54
-
55
- def activate_for_web?(sk_config)
56
- sk_config.web_context?
57
52
  end
58
53
 
59
54
  def development_warning
@@ -1,7 +1,10 @@
1
1
  module Skylight
2
2
  class Trace < Core::Trace
3
- def initialize(*)
3
+ attr_reader :component
4
+
5
+ def initialize(*, component: nil)
4
6
  super
7
+ self.component = component if component
5
8
  @too_many_spans = false
6
9
  native_use_pruning if use_pruning?
7
10
  end
@@ -51,5 +54,16 @@ module Skylight
51
54
  def use_pruning?
52
55
  config.get(:prune_large_traces)
53
56
  end
57
+
58
+ def resolve_component(component)
59
+ config.components[component].to_encoded_s
60
+ end
61
+
62
+ def component=(component)
63
+ resolve_component(component).tap do |c|
64
+ @component = c
65
+ native_set_component(c)
66
+ end
67
+ end
54
68
  end
55
69
  end
@@ -1,35 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require "uri"
3
+
1
4
  module Skylight
2
5
  module Util
3
6
  class Component
4
7
  attr_accessor :environment, :name
5
8
 
6
9
  NAME_FORMAT = /\A[a-zA-Z0-9_-]+\z/
7
- DEFAULT_NAME = "web".freeze
8
- WORKER_NAME = "worker".freeze
9
- DEFAULT_ENVIRONMENT = "production".freeze
10
-
11
- WORKER_PROGRAM_MATCHER = Regexp.union [
12
- /sidekiq$/i,
13
- /backburner$/i,
14
- /delayed_job$/i,
15
- /que$/i,
16
- /sneakers$/i,
17
- /shoryuken$/i
18
- ]
19
-
20
- WORKER_RAKE_MATCHER = Regexp.union [
21
- /\Aresque:/,
22
- /\Abackburner:/,
23
- /\Ajobs:/, # DelayedJob. can also be `rake jobs:workoff`
24
- /\Aqu:/,
25
- /\Aque:/,
26
- /\Aqc:/,
27
- /\Asneakers:/
28
- ]
10
+ DEFAULT_NAME = "web"
11
+ WORKER_NAME = "worker"
12
+ DEFAULT_ENVIRONMENT = "production"
29
13
 
30
- def initialize(environment, name)
14
+ def initialize(environment, name, force_worker: false)
31
15
  @environment = environment || DEFAULT_ENVIRONMENT
32
- @name = resolve_name(name)
16
+ @name = resolve_name(name, force_worker)
33
17
 
34
18
  raise ArgumentError, "environment can't be blank" if @environment.empty?
35
19
  validate_string!(@environment, "environment")
@@ -40,6 +24,10 @@ module Skylight
40
24
  "#{name}:#{environment}"
41
25
  end
42
26
 
27
+ def to_encoded_s
28
+ @to_encoded_s ||= URI.encode_www_form_component(to_s)
29
+ end
30
+
43
31
  def web?
44
32
  name == DEFAULT_NAME
45
33
  end
@@ -66,42 +54,18 @@ module Skylight
66
54
  ARGV
67
55
  end
68
56
 
69
- def resolve_name(given_name)
70
- return DEFAULT_NAME if known_web_context?
71
- return given_name if given_name
72
- return WORKER_NAME if known_worker_context?
73
- DEFAULT_NAME
57
+ def resolve_name(given_name, force_worker)
58
+ # don't allow workers to be called 'web'
59
+ return WORKER_NAME if force_worker && (given_name.nil? || given_name == DEFAULT_NAME)
60
+ return DEFAULT_NAME if given_name.nil?
61
+
62
+ given_name
74
63
  end
75
64
 
76
65
  def validate_string!(string, kind)
77
66
  return true if string =~ NAME_FORMAT
78
67
  raise ArgumentError, "#{kind} can only contain lowercase letters, numbers, and dashes"
79
68
  end
80
-
81
- def known_web_context?
82
- rails_server? || rack_server? || passenger? || unicorn?
83
- end
84
-
85
- def known_worker_context?
86
- return true if program_name =~ WORKER_PROGRAM_MATCHER
87
- program_name[/rake$/] && argv.any? { |arg| arg =~ WORKER_RAKE_MATCHER }
88
- end
89
-
90
- def rails_server?
91
- defined?(Rails::Server)
92
- end
93
-
94
- def rack_server?
95
- program_name[/(?<!\w)(falcon|puma|rackup|thin)$/]
96
- end
97
-
98
- def unicorn?
99
- program_name[/\Aunicorn/]
100
- end
101
-
102
- def passenger?
103
- program_name[/\APassenger AppPreloader/]
104
- end
105
69
  end
106
70
  end
107
71
  end
@@ -0,0 +1,78 @@
1
+ require "rbconfig"
2
+
3
+ # Used from extconf and to load libskylight
4
+ module Skylight
5
+ module Util
6
+ module Platform
7
+ # Normalize the platform OS
8
+ OS =
9
+ case os = RbConfig::CONFIG["host_os"].downcase
10
+ when /linux/
11
+ # The official ruby-alpine Docker containers pre-build Ruby. As a result,
12
+ # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
13
+ # only reliable way to detect musl that we've found.
14
+ # See https://github.com/skylightio/skylight-ruby/issues/92
15
+ if ENV["SKYLIGHT_MUSL"] || `ldd --version 2>&1` =~ /musl/
16
+ "linux-musl"
17
+ else
18
+ "linux"
19
+ end
20
+ when /darwin/
21
+ "darwin"
22
+ when /freebsd/
23
+ "freebsd"
24
+ when /netbsd/
25
+ "netbsd"
26
+ when /openbsd/
27
+ "openbsd"
28
+ when /sunos|solaris/
29
+ "solaris"
30
+ when /mingw|mswin/
31
+ "windows"
32
+ else
33
+ os
34
+ end
35
+
36
+ # Normalize the platform CPU
37
+ ARCH =
38
+ case cpu = RbConfig::CONFIG["host_cpu"].downcase
39
+ when /amd64|x86_64/
40
+ "x86_64"
41
+ when /i?86|x86|i86pc/
42
+ "x86"
43
+ when /ppc|powerpc/
44
+ "powerpc"
45
+ when /^arm/
46
+ "arm"
47
+ else
48
+ cpu
49
+ end
50
+
51
+ LIBEXT =
52
+ case OS
53
+ when /darwin/
54
+ "dylib"
55
+ when /linux|bsd|solaris/
56
+ "so"
57
+ when /windows|cygwin/
58
+ "dll"
59
+ else
60
+ "so"
61
+ end
62
+
63
+ TUPLE = "#{ARCH}-#{OS}".freeze
64
+
65
+ def self.tuple
66
+ TUPLE
67
+ end
68
+
69
+ def self.libext
70
+ LIBEXT
71
+ end
72
+
73
+ def self.dlext
74
+ RbConfig::CONFIG["DLEXT"]
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,13 @@
1
+ module Skylight
2
+ module Util
3
+ module Proxy
4
+ def self.detect_url(env)
5
+ u = env["HTTP_PROXY"] || env["http_proxy"]
6
+ if u && !u.empty?
7
+ u = "http://#{u}" unless u =~ %r{://}
8
+ u
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Skylight
2
- VERSION = "4.1.1-beta".freeze
2
+ VERSION = "4.2.0-beta".freeze
3
3
  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: 4.1.1.beta
4
+ version: 4.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: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: skylight-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.1.beta
19
+ version: 4.2.0.beta
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.1.1.beta
26
+ version: 4.2.0.beta
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: beefcake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -207,6 +207,8 @@ files:
207
207
  - lib/skylight/util/deploy.rb
208
208
  - lib/skylight/util/hostname.rb
209
209
  - lib/skylight/util/http.rb
210
+ - lib/skylight/util/platform.rb
211
+ - lib/skylight/util/proxy.rb
210
212
  - lib/skylight/util/ssl.rb
211
213
  - lib/skylight/vendor/cli/highline.rb
212
214
  - lib/skylight/vendor/cli/highline/color_scheme.rb