skylight-core 3.0.0 → 3.1.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: 42d97b6d1400373026e6e07e96ca90536f88970d610f0be6ff221742e49e8bdb
4
- data.tar.gz: af643c98b238ec0a2ac8e9c466c6a689063796f13e958647f4ca4ca4d9dcbc49
3
+ metadata.gz: e728cb584714e19aa0ccdc0922ac399c52e59b580033094eff49a478589da1fa
4
+ data.tar.gz: d0e4c19a788911437dd92e89a9161c00462aab63815490ea2818ae4c821e3e46
5
5
  SHA512:
6
- metadata.gz: 52466d912d7c7d50d3838160fa482a1623c72e1ee0291d437ff5e5f937dd4182e4b826db39ab8488904b07e819707dfd38023e5dd3c1d46d1e56538a85849015
7
- data.tar.gz: 33cacc4894854e077e26367039c355213dc7706108ac1182d086132b8e3f487fd5d3a4ceea63313b85363c80f28c3e166214a993442b34f974a6a1c43c8e4fa3
6
+ metadata.gz: f4489f1a54319bc0cdc05048d38b0f96e54caacce381893f16e8b3dcf55a043a8e4e0f65b6b65a53cf2509181fbe50f86d81870a43ec122b18a79acbe6ae42b6
7
+ data.tar.gz: b29c30f1beff1a30702513955ebcfc711acbb6677786f2eb28072845593f2824fee3a14ab8490f0c4d86f048bdc8b9ea7348b9c81e66aa5e39b0f20d64bf8f2b
@@ -1,7 +1,6 @@
1
1
  module Skylight
2
2
  module Core
3
3
  module Fanout
4
-
5
4
  def self.registered
6
5
  @registered ||= []
7
6
  end
@@ -21,10 +20,11 @@ module Skylight
21
20
  def self.instrument(*args)
22
21
  if block_given?
23
22
  spans = instrument(*args)
23
+ meta = {}
24
24
  begin
25
25
  yield spans
26
26
  ensure
27
- done(spans)
27
+ done(spans, meta)
28
28
  end
29
29
  else
30
30
  registered.map do |r|
@@ -42,6 +42,18 @@ module Skylight
42
42
  def self.broken!
43
43
  registered.each(&:broken!)
44
44
  end
45
+
46
+ def self.endpoint=(endpoint)
47
+ each_trace { |t| t.endpoint = endpoint }
48
+ end
49
+
50
+ def self.each_trace
51
+ return to_enum(__method__) unless block_given?
52
+ registered.each do |r|
53
+ next unless r.instrumenter && (trace = r.instrumenter.current_trace)
54
+ yield trace
55
+ end
56
+ end
45
57
  end
46
58
  end
47
59
  end
@@ -0,0 +1,27 @@
1
+ module Skylight::Core
2
+ module Probes
3
+ module ActionDispatch
4
+ module Routing
5
+ module RouteSet
6
+ class Probe
7
+ def install
8
+ ::ActionDispatch::Routing::RouteSet.class_eval do
9
+ alias call_without_sk call
10
+
11
+ def call(env)
12
+ Skylight::Core::Fanout.endpoint = self.class.name
13
+ Skylight::Core::Fanout.instrument(title: self.class.name, category: 'rack.app') do
14
+ call_without_sk(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ register(:rails_router, "ActionDispatch::Routing::RouteSet", "action_dispatch/routing/route_set", ActionDispatch::Routing::RouteSet::Probe.new)
26
+ end
27
+ end
@@ -1 +1,2 @@
1
1
  Skylight::Core::Probes.probe('action_dispatch/request_id')
2
+ Skylight::Core::Probes.probe('action_dispatch/routing/route_set')
@@ -22,10 +22,7 @@ module Skylight::Core
22
22
  def call(*args, &block)
23
23
  return call_without_sk(*args, &block) if Skylight::Core::Probes::Middleware::Probe.disabled?
24
24
 
25
- traces = Skylight::Core::Fanout.registered.map do |r|
26
- r.instrumenter ? r.instrumenter.current_trace : nil
27
- end.compact
28
-
25
+ traces = Skylight::Core::Fanout.each_trace.to_a
29
26
  return call_without_sk(*args, &block) if traces.empty?
30
27
 
31
28
  begin
@@ -57,26 +54,6 @@ module Skylight::Core
57
54
  end
58
55
 
59
56
  def install
60
- ::ActionDispatch::MiddlewareStack.class_eval do
61
- alias build_without_sk build
62
-
63
- if ::ActionPack.gem_version >= Gem::Version.new('5.x')
64
- # Rails 5
65
- def build(app = Proc.new)
66
- Skylight::Core::Probes::Middleware::Probe.add_instrumentation(app, default_name: "Rack App", category: "rack.app")
67
- build_without_sk(app)
68
- end
69
- else
70
- # Rails 3 and 4
71
- def build(app, &block)
72
- app ||= block
73
- raise "MiddlewareStack#build requires an app" unless app
74
- Skylight::Core::Probes::Middleware::Probe.add_instrumentation(app, default_name: "Rack App", category: "rack.app")
75
- build_without_sk(app)
76
- end
77
- end
78
- end
79
-
80
57
  ::ActionDispatch::MiddlewareStack::Middleware.class_eval do
81
58
  alias build_without_sk build
82
59
  def build(*args)
@@ -34,12 +34,7 @@ module Skylight::Core
34
34
 
35
35
  def dispatch!(*args, &block)
36
36
  dispatch_without_sk!(*args, &block).tap do
37
- Skylight::Core::Fanout.registered.each do |target|
38
- instrumenter = target.instrumenter
39
- next unless instrumenter
40
- trace = instrumenter.current_trace
41
- next unless trace
42
-
37
+ Skylight::Core::Fanout.each_trace do |trace|
43
38
  # Set the endpoint name to the route name
44
39
  route = env['sinatra.route']
45
40
  trace.endpoint = route if route
@@ -138,6 +138,10 @@ module Skylight::Core
138
138
  nil
139
139
  end
140
140
 
141
+ def inspect
142
+ to_s
143
+ end
144
+
141
145
  def release
142
146
  t { "release; is_current=#{@instrumenter.current_trace == self}" }
143
147
  return unless @instrumenter.current_trace == self
@@ -1,6 +1,6 @@
1
1
  module Skylight
2
2
  module Core
3
- VERSION = '3.0.0'
3
+ VERSION = '3.1.0-beta'
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.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: 2018-09-05 00:00:00.000000000 Z
11
+ date: 2018-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -206,6 +206,7 @@ files:
206
206
  - lib/skylight/core/probes/action_controller.rb
207
207
  - lib/skylight/core/probes/action_dispatch.rb
208
208
  - lib/skylight/core/probes/action_dispatch/request_id.rb
209
+ - lib/skylight/core/probes/action_dispatch/routing/route_set.rb
209
210
  - lib/skylight/core/probes/action_view.rb
210
211
  - lib/skylight/core/probes/active_job_enqueue.rb
211
212
  - lib/skylight/core/probes/active_model_serializers.rb
@@ -260,9 +261,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
261
  version: 2.2.7
261
262
  required_rubygems_version: !ruby/object:Gem::Requirement
262
263
  requirements:
263
- - - ">="
264
+ - - ">"
264
265
  - !ruby/object:Gem::Version
265
- version: '0'
266
+ version: 1.3.1
266
267
  requirements: []
267
268
  rubyforge_project:
268
269
  rubygems_version: 2.7.6