skylight 4.1.2 → 4.2.0

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: 134531d673ae33832e5440d2ef1d5afe6eb9ff96e292409fd44db5ead29abf0d
4
- data.tar.gz: da2318898d8c94a8aaec66fb3ea6300c1e7c41fa6257aca0cbf1c0b4562ecfde
3
+ metadata.gz: 9ec54d064a7d0ee23b34d01446857ce5d5d01e70820d7b95d325065d7c34682e
4
+ data.tar.gz: 78b4328f0daa411f6927a48d81a23484e378ee9bdc56fd320c8bce502392c41b
5
5
  SHA512:
6
- metadata.gz: 64f1827700b7bf7d916cbcfff72c9025d71eb94dab81ecd8ad09031f4e6ba6dd2fcee6e9e5c0d762ff83816df82073cbeb6598916e4be3192e44f9f01445c913
7
- data.tar.gz: 2c57c2acd3b754bd88f1155fed8e93c1a978f8d1d9c2a032cacc92e4338f89e2d19437f1e6c36cf5b9e87664d763e43fe6c260cd34e3fd27bbd486918629be1c
6
+ metadata.gz: 7e91e0f540bb96cfb27255858839b0fb458a89b79558977bd71f0023eeef4eaf41423aa5f6ee4debfaf6b558936e0fd22d72ef5022cb6c1009332265f2ab6ca3
7
+ data.tar.gz: 37d172168416b3926627ddb481b2fdbf16131c38feb09fd401c0428cb1251cf36f1070a69c4334bc7c00d6fef09319922fd551221e3131fa1c2eebe438e4bba3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 4.2.0
2
+ * [FEATURE] Add GraphQL probe
3
+ * [FEATURE] Optionally add Rack mount point to Sinatra endpoint names
4
+ * [FEATURE] Add `Skylight.mute` and `Skylight.unmute` blocks to selectively disable and re-enable
5
+ * [IMPROVEMENT] Shut down the native instrumenter when the remote daemon is unreachable
6
+ instrumentation
7
+ * [IMPROVEMENT] Revise agent authorization strategy (fixes some issues related to activation for background jobs)
8
+ * [IMPROVEMENT] Fix Rails 6 deprecation warnings
9
+ * [BUGFIX] Skip the Sidekiq probe if Sidekiq is not present
10
+
1
11
  ## 4.1.2
2
12
  * [BUGFIX] Correct an issue where the delayed_job probe may not be activated on startup
3
13
 
data/ext/libskylight.yml CHANGED
@@ -1,7 +1,7 @@
1
- version: "4.0.0-4f6f5da"
1
+ version: "4.1.0-46806f5"
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: "4054632757516aa44e812860601fcb7f21c8c5d412b2d585868b46c7a8e3cae6"
4
+ x86_64-linux: "4675694fba4448ba14787551237bd4e388443895d5c9e5d8a71c550eccd203db"
5
+ x86_64-linux-musl: "7a81880830d0a409a6f0f39ff42f90a1422542b05384e2480ae05515f6b5f831"
6
+ x86_64-darwin: "84eef6c330818c2bad1628ff189b9cb88275c9d72a28afac88a0d054d8002230"
7
+ x86_64-freebsd: "a86a52203fab4f9a56ad91d5700e14823e6e997b4df1bcb3ae2d9e4296c50b1f"
@@ -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);
@@ -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(*)
@@ -51,5 +51,8 @@ module Skylight
51
51
 
52
52
  # E0004
53
53
  register(4, "SqlLex", "Failed to lex SQL query.")
54
+
55
+ # E0005
56
+ register(5, "InstrumenterUnrecoverable", "Instrumenter is not running.")
54
57
  end
55
58
  end
@@ -27,5 +27,10 @@ module Skylight
27
27
  end
28
28
  nil
29
29
  end
30
+
31
+ def handle_instrumenter_error(trace, e)
32
+ poison! if e.is_a?(Skylight::InstrumenterUnrecoverableError)
33
+ super
34
+ end
30
35
  end
31
36
  end
@@ -35,13 +35,12 @@ 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")
47
46
  reasons << "the 'delayed_job' probe is enabled" if sk_rails_config.probes.include?("delayed_job")
@@ -50,11 +49,6 @@ module Skylight
50
49
  return if reasons.empty?
51
50
 
52
51
  sk_config.logger.warn("Activating Skylight for Background Jobs because #{reasons.to_sentence}")
53
- true
54
- end
55
-
56
- def activate_for_web?(sk_config)
57
- sk_config.web_context?
58
52
  end
59
53
 
60
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
@@ -1,3 +1,3 @@
1
1
  module Skylight
2
- VERSION = "4.1.2".freeze
2
+ VERSION = "4.2.0".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.2
4
+ version: 4.2.0
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-27 00:00:00.000000000 Z
11
+ date: 2019-10-30 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.2
19
+ version: 4.2.0
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.2
26
+ version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: beefcake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 3.0.3
272
+ rubyforge_project:
273
+ rubygems_version: 2.7.6
273
274
  signing_key:
274
275
  specification_version: 4
275
276
  summary: Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps.