skylight-core 3.1.5 → 4.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skylight/core/config.rb +103 -108
- data/lib/skylight/core/deprecation.rb +3 -3
- data/lib/skylight/core/fanout.rb +3 -3
- data/lib/skylight/core/formatters/http.rb +1 -2
- data/lib/skylight/core/gc.rb +31 -36
- data/lib/skylight/core/instrumentable.rb +17 -16
- data/lib/skylight/core/instrumenter.rb +25 -23
- data/lib/skylight/core/middleware.rb +11 -10
- data/lib/skylight/core/normalizers/action_controller/process_action.rb +9 -9
- data/lib/skylight/core/normalizers/action_controller/send_file.rb +16 -16
- data/lib/skylight/core/normalizers/action_view/render_collection.rb +2 -2
- data/lib/skylight/core/normalizers/action_view/render_partial.rb +2 -2
- data/lib/skylight/core/normalizers/action_view/render_template.rb +2 -2
- data/lib/skylight/core/normalizers/active_job/perform.rb +11 -23
- data/lib/skylight/core/normalizers/active_model_serializers/render.rb +6 -6
- data/lib/skylight/core/normalizers/active_record/instantiation.rb +2 -3
- data/lib/skylight/core/normalizers/active_record/sql.rb +1 -2
- data/lib/skylight/core/normalizers/active_support/cache.rb +12 -10
- data/lib/skylight/core/normalizers/active_support/cache_clear.rb +2 -2
- data/lib/skylight/core/normalizers/active_support/cache_decrement.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_delete.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_exist.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_fetch_hit.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_generate.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_increment.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_read.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_read_multi.rb +3 -3
- data/lib/skylight/core/normalizers/active_support/cache_write.rb +3 -3
- data/lib/skylight/core/normalizers/coach/handler_finish.rb +6 -6
- data/lib/skylight/core/normalizers/coach/middleware_finish.rb +2 -2
- data/lib/skylight/core/normalizers/couch_potato/query.rb +20 -0
- data/lib/skylight/core/normalizers/data_mapper/sql.rb +1 -1
- data/lib/skylight/core/normalizers/default.rb +1 -4
- data/lib/skylight/core/normalizers/elasticsearch/request.rb +5 -5
- data/lib/skylight/core/normalizers/grape/endpoint.rb +6 -5
- data/lib/skylight/core/normalizers/grape/endpoint_render.rb +3 -4
- data/lib/skylight/core/normalizers/grape/endpoint_run.rb +2 -3
- data/lib/skylight/core/normalizers/grape/endpoint_run_filters.rb +1 -2
- data/lib/skylight/core/normalizers/grape/format_response.rb +1 -2
- data/lib/skylight/core/normalizers/moped/query.rb +38 -43
- data/lib/skylight/core/normalizers/render.rb +26 -25
- data/lib/skylight/core/normalizers/sequel/sql.rb +1 -1
- data/lib/skylight/core/normalizers/sql.rb +5 -5
- data/lib/skylight/core/normalizers.rb +11 -12
- data/lib/skylight/core/probes/action_controller.rb +15 -14
- data/lib/skylight/core/probes/action_dispatch/request_id.rb +2 -3
- data/lib/skylight/core/probes/action_dispatch/routing/route_set.rb +2 -3
- data/lib/skylight/core/probes/action_dispatch.rb +2 -2
- data/lib/skylight/core/probes/action_view.rb +11 -17
- data/lib/skylight/core/probes/active_job.rb +8 -4
- data/lib/skylight/core/probes/active_job_enqueue.rb +2 -2
- data/lib/skylight/core/probes/active_model_serializers.rb +7 -6
- data/lib/skylight/core/probes/delayed_job.rb +46 -0
- data/lib/skylight/core/probes/elasticsearch.rb +3 -4
- data/lib/skylight/core/probes/excon/middleware.rb +4 -7
- data/lib/skylight/core/probes/excon.rb +2 -2
- data/lib/skylight/core/probes/faraday.rb +1 -2
- data/lib/skylight/core/probes/httpclient.rb +4 -4
- data/lib/skylight/core/probes/middleware.rb +1 -1
- data/lib/skylight/core/probes/mongo.rb +29 -34
- data/lib/skylight/core/probes/mongoid.rb +2 -3
- data/lib/skylight/core/probes/moped.rb +10 -11
- data/lib/skylight/core/probes/net_http.rb +5 -5
- data/lib/skylight/core/probes/redis.rb +3 -4
- data/lib/skylight/core/probes/sequel.rb +4 -4
- data/lib/skylight/core/probes/sinatra.rb +6 -11
- data/lib/skylight/core/probes/tilt.rb +1 -1
- data/lib/skylight/core/probes.rb +16 -17
- data/lib/skylight/core/railtie.rb +120 -119
- data/lib/skylight/core/sidekiq.rb +8 -4
- data/lib/skylight/core/subscriber.rb +25 -29
- data/lib/skylight/core/test.rb +13 -17
- data/lib/skylight/core/trace.rb +76 -76
- data/lib/skylight/core/user_config.rb +9 -11
- data/lib/skylight/core/util/allocation_free.rb +0 -1
- data/lib/skylight/core/util/clock.rb +16 -16
- data/lib/skylight/core/util/gzip.rb +1 -2
- data/lib/skylight/core/util/inflector.rb +5 -4
- data/lib/skylight/core/util/logging.rb +11 -14
- data/lib/skylight/core/util/platform.rb +52 -49
- data/lib/skylight/core/util/proxy.rb +3 -3
- data/lib/skylight/core/util.rb +5 -5
- data/lib/skylight/core/version.rb +1 -2
- data/lib/skylight/core/vm/gc.rb +1 -3
- data/lib/skylight/core.rb +21 -21
- metadata +47 -44
data/lib/skylight/core/probes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "pathname"
|
2
2
|
|
3
3
|
module Skylight::Core
|
4
4
|
# @api private
|
@@ -19,7 +19,6 @@ module Skylight::Core
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class << self
|
22
|
-
|
23
22
|
def paths
|
24
23
|
@paths ||= []
|
25
24
|
end
|
@@ -27,7 +26,7 @@ module Skylight::Core
|
|
27
26
|
def add_path(path)
|
28
27
|
root = Pathname.new(path)
|
29
28
|
Pathname.glob(root.join("./**/*.rb")).each do |f|
|
30
|
-
name = f.relative_path_from(root).sub_ext(
|
29
|
+
name = f.relative_path_from(root).sub_ext("").to_s
|
31
30
|
if available.key?(name)
|
32
31
|
raise "duplicate probe name: #{name}; original=#{available[name]}; new=#{f}"
|
33
32
|
end
|
@@ -58,14 +57,14 @@ module Skylight::Core
|
|
58
57
|
@installed ||= {}
|
59
58
|
end
|
60
59
|
|
61
|
-
def
|
60
|
+
def available?(klass_name)
|
62
61
|
!!Skylight::Core::Util::Inflector.safe_constantize(klass_name)
|
63
62
|
end
|
64
63
|
|
65
64
|
def register(name, *args)
|
66
65
|
registration = ProbeRegistration.new(name, *args)
|
67
66
|
|
68
|
-
if
|
67
|
+
if available?(registration.klass_name)
|
69
68
|
installed[registration.klass_name] = registration
|
70
69
|
registration.install
|
71
70
|
else
|
@@ -78,7 +77,7 @@ module Skylight::Core
|
|
78
77
|
return unless registration
|
79
78
|
|
80
79
|
# Double check constant is available
|
81
|
-
if
|
80
|
+
if available?(registration.klass_name)
|
82
81
|
installed[registration.klass_name] = registration
|
83
82
|
registration.install
|
84
83
|
|
@@ -113,17 +112,17 @@ end
|
|
113
112
|
module ::Kernel
|
114
113
|
private
|
115
114
|
|
116
|
-
|
115
|
+
alias require_without_sk require
|
117
116
|
|
118
|
-
|
119
|
-
|
117
|
+
def require(name)
|
118
|
+
ret = require_without_sk(name)
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
120
|
+
begin
|
121
|
+
Skylight::Core::Probes.require_hook(name)
|
122
|
+
rescue Exception
|
123
|
+
# FIXME: Log these errors
|
124
|
+
end
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
126
|
+
ret
|
127
|
+
end
|
128
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "skylight/core"
|
2
|
+
require "rails"
|
3
3
|
|
4
4
|
module Skylight::Core
|
5
5
|
# @api private
|
@@ -7,160 +7,161 @@ module Skylight::Core
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
+
# rubocop:disable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs
|
10
11
|
def self.root_key; :skylight end
|
11
12
|
def self.config_class; Config end
|
12
13
|
def self.middleware_class; Middleware end
|
13
|
-
def self.gem_name;
|
14
|
-
def self.log_file_name;
|
14
|
+
def self.gem_name; "Skylight" end
|
15
|
+
def self.log_file_name; "skylight" end
|
15
16
|
def self.namespace; Skylight end
|
16
17
|
def self.version; Skylight::Core::VERSION end
|
18
|
+
# rubocop:enable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
private
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def development_warning
|
26
|
-
"#{log_prefix} Running #{self.class.gem_name} in development mode. No data will be reported until you deploy your app."
|
27
|
-
end
|
28
|
-
|
29
|
-
def run_initializer(app)
|
30
|
-
# Load probes even when agent is inactive to catch probe related bugs sooner
|
31
|
-
load_probes
|
23
|
+
def log_prefix
|
24
|
+
"[#{self.class.gem_name.upcase}] [#{self.class.version}]"
|
25
|
+
end
|
32
26
|
|
33
|
-
|
27
|
+
def development_warning
|
28
|
+
"#{log_prefix} Running #{self.class.gem_name} in development mode. No data will be reported until you deploy your app."
|
29
|
+
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
def run_initializer(app)
|
32
|
+
# Load probes even when agent is inactive to catch probe related bugs sooner
|
33
|
+
load_probes
|
34
|
+
|
35
|
+
config = load_skylight_config(app)
|
36
|
+
|
37
|
+
if activate?(config)
|
38
|
+
if config
|
39
|
+
begin
|
40
|
+
if self.class.namespace.start!(config)
|
41
|
+
set_middleware_position(app, config)
|
42
|
+
Rails.logger.info "#{log_prefix} #{self.class.gem_name} agent enabled"
|
43
|
+
else
|
44
|
+
Rails.logger.info "#{log_prefix} Unable to start, see the #{self.class.gem_name} logs for more details"
|
45
|
+
end
|
46
|
+
rescue ConfigError => e
|
47
|
+
Rails.logger.error "#{log_prefix} #{e.message}; disabling #{self.class.gem_name} agent"
|
43
48
|
end
|
44
|
-
rescue ConfigError => e
|
45
|
-
Rails.logger.error "#{log_prefix} #{e.message}; disabling #{self.class.gem_name} agent"
|
46
49
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
elsif Rails.env.development?
|
51
|
+
# FIXME: The CLI isn't part of core so we should change this message
|
52
|
+
unless config.user_config.disable_dev_warning?
|
53
|
+
log_warning config, development_warning
|
54
|
+
end
|
55
|
+
elsif !Rails.env.test?
|
56
|
+
unless config.user_config.disable_env_warning?
|
57
|
+
log_warning config, "#{log_prefix} You are running in the #{Rails.env} environment but haven't added it to config.#{self.class.root_key}.environments, so no data will be sent to #{config.class.service_name} servers."
|
58
|
+
end
|
56
59
|
end
|
57
60
|
end
|
58
|
-
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
def log_warning(config, msg)
|
63
|
+
if config
|
64
|
+
config.alert_logger.warn(msg)
|
65
|
+
else
|
66
|
+
Rails.logger.warn(msg)
|
67
|
+
end
|
65
68
|
end
|
66
|
-
end
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
def existent_paths(paths)
|
71
|
+
paths.respond_to?(:existent) ? paths.existent : paths.select { |f| File.exist?(f) }
|
72
|
+
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
def load_skylight_config(app)
|
75
|
+
path = config_path(app)
|
76
|
+
path = nil unless File.exist?(path)
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
78
|
+
unless (tmp = app.config.paths["tmp"].first)
|
79
|
+
Rails.logger.error "#{log_prefix} tmp directory missing from rails configuration"
|
80
|
+
return nil
|
81
|
+
end
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
+
config = self.class.config_class.load(file: path, environment: Rails.env.to_s)
|
84
|
+
config[:root] = Rails.root
|
83
85
|
|
84
|
-
|
86
|
+
configure_logging(config, app)
|
85
87
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
config[:'daemon.sockdir_path'] ||= tmp
|
89
|
+
config[:'normalizers.render.view_paths'] = existent_paths(app.config.paths["app/views"]) + [Rails.root.to_s]
|
90
|
+
config
|
91
|
+
end
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
def configure_logging(config, app)
|
94
|
+
if (logger = sk_rails_config(app).logger)
|
95
|
+
config.logger = logger
|
96
|
+
else
|
97
|
+
# Configure the log file destination
|
98
|
+
if (log_file = sk_rails_config(app).log_file)
|
99
|
+
config["log_file"] = log_file
|
100
|
+
elsif !config.key?("log_file") && !config.on_heroku?
|
101
|
+
config["log_file"] = File.join(Rails.root, "log/#{self.class.log_file_name}.log")
|
102
|
+
end
|
101
103
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
# Configure the log level
|
105
|
+
if (level = sk_rails_config(app).log_level)
|
106
|
+
config["log_level"] = level
|
107
|
+
elsif !config.key?("log_level")
|
108
|
+
if (level = app.config.log_level)
|
109
|
+
config["log_level"] = level
|
110
|
+
end
|
108
111
|
end
|
109
112
|
end
|
110
113
|
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def config_path(app)
|
114
|
-
File.expand_path(skylight_config.config_path, app.root)
|
115
|
-
end
|
116
114
|
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
def config_path(app)
|
116
|
+
File.expand_path(sk_rails_config.config_path, app.root)
|
117
|
+
end
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
if ENV.key?(key)
|
124
|
-
ENV[key] !~ /^false$/i
|
125
|
-
else
|
126
|
-
environments.include?(Rails.env.to_s)
|
119
|
+
def environments
|
120
|
+
Array(sk_rails_config.environments).map { |e| e && e.to_s }.compact
|
127
121
|
end
|
128
|
-
end
|
129
122
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
123
|
+
def activate?(_sk_config)
|
124
|
+
key = "#{self.class.config_class.env_prefix}ENABLED"
|
125
|
+
if ENV.key?(key)
|
126
|
+
ENV[key] !~ /^false$/i
|
127
|
+
else
|
128
|
+
environments.include?(Rails.env.to_s)
|
129
|
+
end
|
130
|
+
end
|
134
131
|
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
def load_probes
|
133
|
+
probes = sk_rails_config.probes || []
|
134
|
+
Probes.probe(*probes)
|
135
|
+
end
|
138
136
|
|
139
|
-
|
140
|
-
|
141
|
-
app.middleware.insert_after(middleware_position[:after], self.class.middleware_class, config: config)
|
142
|
-
elsif middleware_position.has_key?(:before)
|
143
|
-
app.middleware.insert_before(middleware_position[:before], self.class.middleware_class, config: config)
|
144
|
-
else
|
145
|
-
raise "The middleware position you have set is invalid. Please be sure `config.#{self.class.root_key}.middleware_position` is set up correctly."
|
137
|
+
def middleware_position
|
138
|
+
sk_rails_config.middleware_position.is_a?(Hash) ? sk_rails_config.middleware_position.symbolize_keys : sk_rails_config.middleware_position
|
146
139
|
end
|
147
|
-
end
|
148
140
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
raise "The middleware position you have set is invalid. Please be sure `config.#{self.class.root_key}.middleware_position` is set up correctly."
|
141
|
+
def insert_middleware(app, config)
|
142
|
+
if middleware_position.key?(:after)
|
143
|
+
app.middleware.insert_after(middleware_position[:after], self.class.middleware_class, config: config)
|
144
|
+
elsif middleware_position.key?(:before)
|
145
|
+
app.middleware.insert_before(middleware_position[:before], self.class.middleware_class, config: config)
|
146
|
+
else
|
147
|
+
raise "The middleware position you have set is invalid. Please be sure `config.#{self.class.root_key}.middleware_position` is set up correctly."
|
148
|
+
end
|
158
149
|
end
|
159
|
-
end
|
160
150
|
|
161
|
-
|
162
|
-
|
163
|
-
|
151
|
+
def set_middleware_position(app, config)
|
152
|
+
if middleware_position.is_a?(Integer)
|
153
|
+
app.middleware.insert middleware_position, self.class.middleware_class, config: config
|
154
|
+
elsif middleware_position.is_a?(Hash) && middleware_position.keys.count == 1
|
155
|
+
insert_middleware(app, config)
|
156
|
+
elsif middleware_position.nil?
|
157
|
+
app.middleware.insert 0, self.class.middleware_class, config: config
|
158
|
+
else
|
159
|
+
raise "The middleware position you have set is invalid. Please be sure `config.#{self.class.root_key}.middleware_position` is set up correctly."
|
160
|
+
end
|
161
|
+
end
|
164
162
|
|
163
|
+
def sk_rails_config(target = self)
|
164
|
+
target.config.send(self.class.root_key)
|
165
|
+
end
|
165
166
|
end
|
166
167
|
end
|
@@ -21,10 +21,14 @@ module Skylight
|
|
21
21
|
|
22
22
|
def call(_worker, job, queue)
|
23
23
|
t { "Sidekiq middleware beginning trace" }
|
24
|
-
title = job[
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
title = job["wrapped"] || job["class"]
|
25
|
+
@instrumentable.trace(title, "app.sidekiq.worker", title, segment: queue) do |trace|
|
26
|
+
begin
|
27
|
+
yield
|
28
|
+
rescue Exception # includes Sidekiq::Shutdown
|
29
|
+
trace.segment = "error" if trace
|
30
|
+
raise
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
@@ -20,9 +20,7 @@ module Skylight::Core
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def unregister!
|
23
|
-
until @subscribers.empty?
|
24
|
-
ActiveSupport::Notifications.unsubscribe @subscribers.shift
|
25
|
-
end
|
23
|
+
ActiveSupport::Notifications.unsubscribe @subscribers.shift until @subscribers.empty?
|
26
24
|
end
|
27
25
|
|
28
26
|
#
|
@@ -35,13 +33,14 @@ module Skylight::Core
|
|
35
33
|
attr_reader :name, :span
|
36
34
|
|
37
35
|
def initialize(name, span)
|
38
|
-
@name
|
36
|
+
@name = name
|
37
|
+
@span = span
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
def start(name,
|
41
|
+
def start(name, _id, payload)
|
43
42
|
return if @instrumenter.disabled?
|
44
|
-
return unless trace = @instrumenter.current_trace
|
43
|
+
return unless (trace = @instrumenter.current_trace)
|
45
44
|
|
46
45
|
result = normalize(trace, name, payload)
|
47
46
|
|
@@ -67,24 +66,22 @@ module Skylight::Core
|
|
67
66
|
nil
|
68
67
|
end
|
69
68
|
|
70
|
-
def finish(name,
|
69
|
+
def finish(name, _id, payload)
|
71
70
|
return if @instrumenter.disabled?
|
72
|
-
return unless trace = @instrumenter.current_trace
|
73
|
-
|
74
|
-
while curr = trace.notifications.pop
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
return
|
71
|
+
return unless (trace = @instrumenter.current_trace)
|
72
|
+
|
73
|
+
while (curr = trace.notifications.pop)
|
74
|
+
next unless curr.name == name
|
75
|
+
begin
|
76
|
+
normalize_after(trace, curr.span, name, payload)
|
77
|
+
ensure
|
78
|
+
meta = {}
|
79
|
+
meta[:exception] = payload[:exception] if payload[:exception]
|
80
|
+
meta[:exception_object] = payload[:exception_object] if payload[:exception_object]
|
81
|
+
trace.done(curr.span, meta) if curr.span
|
85
82
|
end
|
83
|
+
return
|
86
84
|
end
|
87
|
-
|
88
85
|
rescue Exception => e
|
89
86
|
error "Subscriber#finish error; msg=%s", e.message
|
90
87
|
debug "trace=%s", trace.inspect
|
@@ -98,15 +95,14 @@ module Skylight::Core
|
|
98
95
|
# Ignored for now because nothing in rails uses it
|
99
96
|
end
|
100
97
|
|
101
|
-
|
102
|
-
|
103
|
-
def normalize(*args)
|
104
|
-
@normalizers.normalize(*args)
|
105
|
-
end
|
98
|
+
private
|
106
99
|
|
107
|
-
|
108
|
-
|
109
|
-
|
100
|
+
def normalize(*args)
|
101
|
+
@normalizers.normalize(*args)
|
102
|
+
end
|
110
103
|
|
104
|
+
def normalize_after(*args)
|
105
|
+
@normalizers.normalize_after(*args)
|
106
|
+
end
|
111
107
|
end
|
112
108
|
end
|
data/lib/skylight/core/test.rb
CHANGED
@@ -2,15 +2,14 @@ module Skylight
|
|
2
2
|
module Core
|
3
3
|
module Test
|
4
4
|
module Mocking
|
5
|
-
|
6
|
-
def mock!(config_opts={}, &callback)
|
5
|
+
def mock!(config_opts = {}, &callback)
|
7
6
|
config_opts[:mock_submission] ||= callback || proc {}
|
8
7
|
config = config_class.load(config_opts)
|
9
8
|
|
10
9
|
unless respond_to?(:__original_instrumenter_class)
|
11
10
|
class_eval do
|
12
11
|
class << self
|
13
|
-
|
12
|
+
alias_method :__original_instrumenter_class, :instrumenter_class
|
14
13
|
|
15
14
|
def instrumenter_class
|
16
15
|
@instrumenter_class ||= Class.new(__original_instrumenter_class) do
|
@@ -57,25 +56,23 @@ module Skylight
|
|
57
56
|
mock_spans.index(span)
|
58
57
|
end
|
59
58
|
|
60
|
-
def native_span_set_title(
|
61
|
-
mock_spans[
|
62
|
-
|
59
|
+
def native_span_set_title(span, title)
|
60
|
+
mock_spans[span][:title] = title
|
63
61
|
end
|
64
62
|
|
65
|
-
def native_span_set_description(
|
66
|
-
mock_spans[
|
63
|
+
def native_span_set_description(span, desc)
|
64
|
+
mock_spans[span][:desc] = desc
|
67
65
|
end
|
68
66
|
|
69
|
-
def native_span_set_meta(
|
70
|
-
mock_spans[
|
67
|
+
def native_span_set_meta(span, meta)
|
68
|
+
mock_spans[span][:meta] = meta
|
71
69
|
end
|
72
70
|
|
73
|
-
def native_span_started(
|
74
|
-
end
|
71
|
+
def native_span_started(span); end
|
75
72
|
|
76
|
-
def native_span_set_exception(
|
77
|
-
mock_spans[
|
78
|
-
mock_spans[
|
73
|
+
def native_span_set_exception(span, exception_object, exception)
|
74
|
+
mock_spans[span][:exception_object] = exception_object
|
75
|
+
mock_spans[span][:exception] = exception
|
79
76
|
end
|
80
77
|
|
81
78
|
def native_stop_span(span, time)
|
@@ -94,8 +91,7 @@ module Skylight
|
|
94
91
|
config[:mock_submission].call(trace)
|
95
92
|
end
|
96
93
|
|
97
|
-
def native_stop
|
98
|
-
end
|
94
|
+
def native_stop; end
|
99
95
|
|
100
96
|
def limited_description(description)
|
101
97
|
description
|