skylight 4.1.2 → 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: 134531d673ae33832e5440d2ef1d5afe6eb9ff96e292409fd44db5ead29abf0d
4
- data.tar.gz: da2318898d8c94a8aaec66fb3ea6300c1e7c41fa6257aca0cbf1c0b4562ecfde
3
+ metadata.gz: d91b4f08958f93027e62e1d08cc6047462c39c9df2c98de8e27f3dcb4d4f10ce
4
+ data.tar.gz: 3a35d4f4c300d77dd911d964f405d42a026c447d6dc8d1a0d69a1301f0ec5d3d
5
5
  SHA512:
6
- metadata.gz: 64f1827700b7bf7d916cbcfff72c9025d71eb94dab81ecd8ad09031f4e6ba6dd2fcee6e9e5c0d762ff83816df82073cbeb6598916e4be3192e44f9f01445c913
7
- data.tar.gz: 2c57c2acd3b754bd88f1155fed8e93c1a978f8d1d9c2a032cacc92e4338f89e2d19437f1e6c36cf5b9e87664d763e43fe6c260cd34e3fd27bbd486918629be1c
6
+ metadata.gz: eb320617e3176912f281b45ee47f7a09b3ac7f71d2acea26505beed0c3d05910249f6ced4e4c304addfa56a9cf1cf66ef199f0af1d0e378892ef4141e4830860
7
+ data.tar.gz: 3a86a8b24adda0054a4c3a8945df3f97559b44a42dfab2c954a6d361cd7e2a4c23407bd6a2db01480915a690e2ba60e4c47d706c99751810879973f699054247
@@ -1,3 +1,8 @@
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
+
1
6
  ## 4.1.2
2
7
  * [BUGFIX] Correct an issue where the delayed_job probe may not be activated on startup
3
8
 
@@ -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);
@@ -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(*)
@@ -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-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.2
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-27 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.2
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.2
26
+ version: 4.2.0.beta
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: beefcake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -265,9 +265,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
265
  version: '2.3'
266
266
  required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  requirements:
268
- - - ">="
268
+ - - ">"
269
269
  - !ruby/object:Gem::Version
270
- version: '0'
270
+ version: 1.3.1
271
271
  requirements: []
272
272
  rubygems_version: 3.0.3
273
273
  signing_key: