appoptics_apm 4.9.0 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.travis.yml +11 -4
- data/Gemfile +6 -6
- data/appoptics_apm.gemspec +3 -0
- data/ext/oboe_metal/noop/noop.c +2 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/lib/appoptics_apm.rb +0 -3
- data/lib/appoptics_apm/api.rb +0 -1
- data/lib/appoptics_apm/api/tracing.rb +4 -0
- data/lib/appoptics_apm/config.rb +6 -2
- data/lib/appoptics_apm/frameworks/padrino.rb +6 -36
- data/lib/appoptics_apm/frameworks/rails.rb +0 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +12 -25
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
- data/lib/appoptics_apm/frameworks/sinatra.rb +3 -32
- data/lib/appoptics_apm/inst/curb.rb +6 -6
- data/lib/appoptics_apm/inst/faraday.rb +16 -4
- data/lib/appoptics_apm/sdk/tracing.rb +118 -0
- data/lib/appoptics_apm/support/transaction_metrics.rb +1 -0
- data/lib/appoptics_apm/version.rb +1 -1
- data/lib/appoptics_apm/xtrace.rb +7 -7
- metadata +2 -18
- data/Rakefile +0 -236
- data/build_gem.sh +0 -15
- data/build_gem_upload_to_packagecloud.sh +0 -15
- data/lib/appoptics_apm/api/profiling.rb +0 -203
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb +0 -55
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb +0 -50
- data/lib/appoptics_apm/legacy_method_profiling.rb +0 -90
- data/lib/appoptics_apm/method_profiling.rb +0 -33
- data/lib/oboe/README +0 -2
- data/lib/oboe/backward_compatibility.rb +0 -80
- data/lib/oboe/inst/rack.rb +0 -11
- data/scrap_gemfile +0 -5
@@ -37,7 +37,15 @@ module AppOpticsAPM
|
|
37
37
|
AppOpticsAPM::XTrace.continue_service_context(xtrace, xtrace_new)
|
38
38
|
end
|
39
39
|
kvs = {}
|
40
|
-
|
40
|
+
|
41
|
+
# this seems the safer condition than trying to identify the
|
42
|
+
# faraday version when adapter started to work without arg
|
43
|
+
# and handlers don't include the adapter anymore
|
44
|
+
if @builder.method(:adapter).parameters.find { |ele| ele[0] == :req }
|
45
|
+
kvs[:Middleware] = @builder.handlers
|
46
|
+
else
|
47
|
+
kvs[:Middleware] = [@builder.adapter] + @builder.handlers
|
48
|
+
end
|
41
49
|
kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
42
50
|
|
43
51
|
# Only send service KVs if we're not using an adapter
|
@@ -68,16 +76,20 @@ module AppOpticsAPM
|
|
68
76
|
|
69
77
|
# This is only considered a remote service call if the middleware/adapter is not instrumented
|
70
78
|
def remote_call?
|
71
|
-
|
79
|
+
if @builder.method(:adapter).parameters.find { |ele| ele[0] == :req }
|
80
|
+
(@builder.handlers.map(&:name) & APPOPTICS_INSTR_ADAPTERS).count == 0
|
81
|
+
else
|
82
|
+
((@builder.handlers.map(&:name) << @builder.adapter.name) & APPOPTICS_INSTR_ADAPTERS).count == 0
|
83
|
+
end
|
72
84
|
end
|
73
85
|
|
74
|
-
def rsc_kvs(
|
86
|
+
def rsc_kvs(_url, method, result)
|
75
87
|
kvs = { :Spec => 'rsc',
|
76
88
|
:IsService => 1,
|
77
89
|
:HTTPMethod => method.upcase,
|
78
90
|
:HTTPStatus => result.status, }
|
79
91
|
kvs[:Blacklisted] = true if url_blacklisted?
|
80
|
-
kvs[:RemoteURL] = result.to_hash[:url].to_s
|
92
|
+
kvs[:RemoteURL] = result.env.to_hash[:url].to_s
|
81
93
|
kvs[:RemoteURL].split('?').first unless AppOpticsAPM::Config[:faraday][:log_args]
|
82
94
|
|
83
95
|
kvs
|
@@ -32,6 +32,7 @@ module AppOpticsAPM
|
|
32
32
|
# * +AppOpticsAPM::SDK.start_trace+
|
33
33
|
# * +AppOpticsAPM::SDK.start_trace_with_target+
|
34
34
|
# * +AppOpticsAPM::SDK.trace+
|
35
|
+
# * +AppOpticsAPM::SDK.trace_method+
|
35
36
|
# * +AppOpticsAPM::SDK.tracing?+
|
36
37
|
#
|
37
38
|
# === Example:
|
@@ -207,6 +208,123 @@ module AppOpticsAPM
|
|
207
208
|
result
|
208
209
|
end
|
209
210
|
|
211
|
+
##
|
212
|
+
# Add tracing to a given method
|
213
|
+
#
|
214
|
+
# This instruments the given method so that every time it is called it
|
215
|
+
# will create a span depending on the current context.
|
216
|
+
#
|
217
|
+
# The method can be of any (accessible) type (instance, singleton,
|
218
|
+
# private, protected etc.).
|
219
|
+
#
|
220
|
+
# The motivating use case for this is MetalController methods in Rails,
|
221
|
+
# which can't be auto-instrumented.
|
222
|
+
#
|
223
|
+
# === Arguments:
|
224
|
+
# * +klass+ - The module/class the method belongs to.
|
225
|
+
# * +method+ - The method name as symbol
|
226
|
+
# * +config+ - (optional) possible keys are:
|
227
|
+
# :name the name of the span (default: the method name)
|
228
|
+
# :backtrace true/false (default: false) if true the backtrace will be added to the space
|
229
|
+
# * +opts+ - (optional) hash containing key/value pairs that will be reported with this span.
|
230
|
+
#
|
231
|
+
# === Example:
|
232
|
+
#
|
233
|
+
# module ExampleModule
|
234
|
+
# def do_sum(a, b)
|
235
|
+
# a + b
|
236
|
+
# end
|
237
|
+
# end
|
238
|
+
#
|
239
|
+
# AppOpticsAPM::SDK.trace_method(ExampleModule, :do_sum, {name: 'computation', backtrace: true}, { CustomKey: "some_info"})
|
240
|
+
#
|
241
|
+
def trace_method(klass, method, config = {}, opts = {})
|
242
|
+
# If we're on an unsupported platform (ahem Mac), just act
|
243
|
+
# like we did something to nicely play the no-op part.
|
244
|
+
return true unless AppOpticsAPM.loaded
|
245
|
+
|
246
|
+
if !klass.is_a?(Module)
|
247
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/error] trace_method: Not sure what to do with #{klass}. Send a class or module."
|
248
|
+
return false
|
249
|
+
end
|
250
|
+
|
251
|
+
if method.is_a?(String)
|
252
|
+
method = method.to_sym
|
253
|
+
elsif !method.is_a?(Symbol)
|
254
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/error] trace_method: Not sure what to do with #{method}. Send a string or symbol for method."
|
255
|
+
return false
|
256
|
+
end
|
257
|
+
|
258
|
+
instance_method = klass.instance_methods.include?(method) || klass.private_instance_methods.include?(method)
|
259
|
+
class_method = klass.singleton_methods.include?(method)
|
260
|
+
|
261
|
+
# Make sure the request klass::method exists
|
262
|
+
if !instance_method && !class_method
|
263
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/error] trace_method: Can't instrument #{klass}.#{method} as it doesn't seem to exist."
|
264
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/error] #{__FILE__}:#{__LINE__}"
|
265
|
+
return false
|
266
|
+
end
|
267
|
+
|
268
|
+
# Strip '!' or '?' from method if present
|
269
|
+
safe_method_name = method.to_s.chop if method.to_s =~ /\?$|\!$/
|
270
|
+
safe_method_name ||= method
|
271
|
+
|
272
|
+
without_appoptics = "#{safe_method_name}_without_appoptics"
|
273
|
+
with_appoptics = "#{safe_method_name}_with_appoptics"
|
274
|
+
|
275
|
+
# Check if already profiled
|
276
|
+
if instance_method && klass.instance_methods.include?(with_appoptics.to_sym) ||
|
277
|
+
class_method && klass.singleton_methods.include?(with_appoptics.to_sym)
|
278
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/error] trace_method: #{klass}::#{method} already instrumented.\n#{__FILE__}:#{__LINE__}"
|
279
|
+
return false
|
280
|
+
end
|
281
|
+
|
282
|
+
report_kvs = opts.dup
|
283
|
+
if defined?(::AbstractController::Base) && klass.ancestors.include?(::AbstractController::Base)
|
284
|
+
report_kvs[:Controller] = klass.to_s
|
285
|
+
report_kvs[:Action] = method.to_s
|
286
|
+
else
|
287
|
+
klass.is_a?(Class) ? report_kvs[:Class] = klass.to_s : report_kvs[:Module] = klass.to_s
|
288
|
+
report_kvs[:MethodName] = safe_method_name
|
289
|
+
end
|
290
|
+
backtrace = config[:backtrace]
|
291
|
+
|
292
|
+
span = config[:name] || method
|
293
|
+
if instance_method
|
294
|
+
klass.class_eval do
|
295
|
+
define_method(with_appoptics) do |*args, &block|
|
296
|
+
# if this is a rails controller we want to set the transaction for the outbound metrics
|
297
|
+
if report_kvs[:Controller] && defined?(request) && defined?(request.env)
|
298
|
+
request.env['appoptics_apm.controller'] = report_kvs[:Controller]
|
299
|
+
request.env['appoptics_apm.action'] = report_kvs[:Action]
|
300
|
+
end
|
301
|
+
|
302
|
+
AppOpticsAPM::SDK.trace(span, report_kvs) do
|
303
|
+
report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace(2) if backtrace
|
304
|
+
send(without_appoptics, *args, &block)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
alias_method without_appoptics, method.to_s
|
309
|
+
alias_method method.to_s, with_appoptics
|
310
|
+
end
|
311
|
+
elsif class_method
|
312
|
+
klass.define_singleton_method(with_appoptics) do |*args, &block|
|
313
|
+
AppOpticsAPM::SDK.trace(span, report_kvs) do
|
314
|
+
report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace(2) if backtrace
|
315
|
+
send(without_appoptics, *args, &block)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
klass.singleton_class.class_eval do
|
320
|
+
alias_method without_appoptics, method.to_s
|
321
|
+
alias_method method.to_s, with_appoptics
|
322
|
+
end
|
323
|
+
end
|
324
|
+
true
|
325
|
+
end
|
326
|
+
|
327
|
+
##
|
210
328
|
# Provide a custom transaction name
|
211
329
|
#
|
212
330
|
# The AppOpticsAPM gem tries to create meaningful transaction names from controller+action
|
@@ -15,6 +15,7 @@ module AppOpticsAPM
|
|
15
15
|
def metrics(env, settings)
|
16
16
|
if settings.do_metrics
|
17
17
|
req = ::Rack::Request.new(env)
|
18
|
+
# TODO rails 3x is not supported anymore ...
|
18
19
|
url = req.url # saving it here because rails3.2 overrides it when there is a 500 error
|
19
20
|
start = Time.now
|
20
21
|
|
data/lib/appoptics_apm/xtrace.rb
CHANGED
@@ -97,16 +97,16 @@ module AppOpticsAPM
|
|
97
97
|
# +finish+ is the context returned to us (as an HTTP response header
|
98
98
|
# if that be the case)
|
99
99
|
#
|
100
|
-
def continue_service_context(
|
101
|
-
if AppOpticsAPM::XTrace.valid?(
|
100
|
+
def continue_service_context(start_xtrace, end_xtrace)
|
101
|
+
if AppOpticsAPM::XTrace.valid?(end_xtrace) && AppOpticsAPM.tracing?
|
102
102
|
|
103
|
-
#
|
103
|
+
# Make sure that we received back a valid X-Trace with the same task_id
|
104
104
|
# and the sampling bit is set, otherwise it is a response from a non-sampling service
|
105
|
-
if AppOpticsAPM::XTrace.task_id(
|
106
|
-
AppOpticsAPM::XTrace.sampled?(
|
107
|
-
AppOpticsAPM::Context.fromString(
|
105
|
+
if AppOpticsAPM::XTrace.task_id(start_xtrace) == AppOpticsAPM::XTrace.task_id(end_xtrace) &&
|
106
|
+
AppOpticsAPM::XTrace.sampled?(end_xtrace)
|
107
|
+
AppOpticsAPM::Context.fromString(end_xtrace)
|
108
108
|
else
|
109
|
-
AppOpticsAPM.logger.debug "[XTrace] Sampling flag unset or mismatched start and finish ids:\n#{
|
109
|
+
AppOpticsAPM.logger.debug "[XTrace] Sampling flag unset or mismatched start and finish ids:\n#{start_xtrace}\n#{end_xtrace}"
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoptics_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maia Engeli
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -117,7 +117,6 @@ files:
|
|
117
117
|
- ".dockerignore"
|
118
118
|
- ".github/ISSUE_TEMPLATE/bug-or-feature-request.md"
|
119
119
|
- ".gitignore"
|
120
|
-
- ".irbrc"
|
121
120
|
- ".rubocop.yml"
|
122
121
|
- ".travis.yml"
|
123
122
|
- ".yardopts"
|
@@ -126,11 +125,8 @@ files:
|
|
126
125
|
- Gemfile
|
127
126
|
- LICENSE
|
128
127
|
- README.md
|
129
|
-
- Rakefile
|
130
128
|
- appoptics_apm.gemspec
|
131
129
|
- bin/appoptics_apm_config
|
132
|
-
- build_gem.sh
|
133
|
-
- build_gem_upload_to_packagecloud.sh
|
134
130
|
- examples/SDK/01_basic_tracing.rb
|
135
131
|
- examples/carrying_context.rb
|
136
132
|
- ext/oboe_metal/README.md
|
@@ -151,7 +147,6 @@ files:
|
|
151
147
|
- lib/appoptics_apm/api/logging.rb
|
152
148
|
- lib/appoptics_apm/api/memcache.rb
|
153
149
|
- lib/appoptics_apm/api/metrics.rb
|
154
|
-
- lib/appoptics_apm/api/profiling.rb
|
155
150
|
- lib/appoptics_apm/api/tracing.rb
|
156
151
|
- lib/appoptics_apm/api/util.rb
|
157
152
|
- lib/appoptics_apm/base.rb
|
@@ -160,13 +155,11 @@ files:
|
|
160
155
|
- lib/appoptics_apm/frameworks/padrino.rb
|
161
156
|
- lib/appoptics_apm/frameworks/rails.rb
|
162
157
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller.rb
|
163
|
-
- lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb
|
164
158
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb
|
165
159
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb
|
166
160
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb
|
167
161
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb
|
168
162
|
- lib/appoptics_apm/frameworks/rails/inst/action_view.rb
|
169
|
-
- lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb
|
170
163
|
- lib/appoptics_apm/frameworks/rails/inst/active_record.rb
|
171
164
|
- lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql.rb
|
172
165
|
- lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql2.rb
|
@@ -204,10 +197,8 @@ files:
|
|
204
197
|
- lib/appoptics_apm/inst/twitter-cassandra.rb
|
205
198
|
- lib/appoptics_apm/inst/typhoeus.rb
|
206
199
|
- lib/appoptics_apm/instrumentation.rb
|
207
|
-
- lib/appoptics_apm/legacy_method_profiling.rb
|
208
200
|
- lib/appoptics_apm/loading.rb
|
209
201
|
- lib/appoptics_apm/logger.rb
|
210
|
-
- lib/appoptics_apm/method_profiling.rb
|
211
202
|
- lib/appoptics_apm/noop/README.md
|
212
203
|
- lib/appoptics_apm/noop/context.rb
|
213
204
|
- lib/appoptics_apm/noop/metadata.rb
|
@@ -228,16 +219,9 @@ files:
|
|
228
219
|
- lib/appoptics_apm/xtrace.rb
|
229
220
|
- lib/joboe_metal.rb
|
230
221
|
- lib/oboe.rb
|
231
|
-
- lib/oboe/README
|
232
|
-
- lib/oboe/backward_compatibility.rb
|
233
|
-
- lib/oboe/inst/rack.rb
|
234
222
|
- lib/oboe_metal.rb
|
235
223
|
- lib/rails/generators/appoptics_apm/install_generator.rb
|
236
224
|
- lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb
|
237
|
-
- oboe.code-workspace
|
238
|
-
- scrap.rb
|
239
|
-
- scrap_gemfile
|
240
|
-
- scrap_gemfile.lock
|
241
225
|
- yardoc_frontpage.md
|
242
226
|
homepage: https://www.appoptics.com/
|
243
227
|
licenses:
|
data/Rakefile
DELETED
@@ -1,236 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'open-uri'
|
6
|
-
require 'bundler/setup'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'appoptics_apm/test'
|
9
|
-
|
10
|
-
Rake::TestTask.new do |t|
|
11
|
-
t.verbose = false
|
12
|
-
t.warning = false
|
13
|
-
t.ruby_opts = []
|
14
|
-
t.libs << 'test'
|
15
|
-
|
16
|
-
# Since we support so many libraries and frameworks, tests
|
17
|
-
# runs are segmented into gemfiles that have different
|
18
|
-
# sets and versions of gems (libraries and frameworks).
|
19
|
-
#
|
20
|
-
# Here we detect the Gemfile the tests are being run against
|
21
|
-
# and load the appropriate tests.
|
22
|
-
#
|
23
|
-
case AppOpticsAPM::Test.gemfile
|
24
|
-
when /delayed_job/
|
25
|
-
require 'delayed/tasks'
|
26
|
-
t.test_files = FileList['test/queues/delayed_job*_test.rb']
|
27
|
-
when /rails/
|
28
|
-
# Pre-load rails to get the major version number
|
29
|
-
require 'rails'
|
30
|
-
|
31
|
-
if Rails::VERSION::MAJOR == 5
|
32
|
-
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"] +
|
33
|
-
FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_api_test.rb"]
|
34
|
-
elsif Rails::VERSION::MAJOR == 6
|
35
|
-
t.test_files = FileList["test/frameworks/rails5x_test.rb"] +
|
36
|
-
FileList["test/frameworks/rails5x_api_test.rb"]
|
37
|
-
else
|
38
|
-
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"]
|
39
|
-
end
|
40
|
-
|
41
|
-
when /frameworks/
|
42
|
-
t.test_files = FileList['test/frameworks/sinatra*_test.rb'] +
|
43
|
-
FileList['test/frameworks/padrino*_test.rb'] +
|
44
|
-
FileList['test/frameworks/grape*_test.rb']
|
45
|
-
when /libraries/
|
46
|
-
t.test_files = FileList['test/support/*_test.rb'] +
|
47
|
-
FileList['test/reporter/*_test.rb'] +
|
48
|
-
FileList['test/instrumentation/*_test.rb'] +
|
49
|
-
FileList['test/profiling/*_test.rb'] -
|
50
|
-
['test/instrumentation/twitter-cassandra_test.rb']
|
51
|
-
when /instrumentation_mocked/
|
52
|
-
# WebMock is interfering with other tests, so these have to run separately
|
53
|
-
t.test_files = FileList['test/mocked/*_test.rb']
|
54
|
-
when /noop/
|
55
|
-
t.test_files = FileList['test/noop/*_test.rb']
|
56
|
-
when /unit/
|
57
|
-
t.test_files = FileList['test/unit/*_test.rb'] +
|
58
|
-
FileList['test/unit/*/*_test.rb']
|
59
|
-
end
|
60
|
-
|
61
|
-
if defined?(JRUBY_VERSION)
|
62
|
-
t.ruby_opts << ['-J-javaagent:/usr/local/tracelytics/tracelyticsagent.jar']
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
desc "Run all test suites defined by travis"
|
68
|
-
task "docker_tests" do
|
69
|
-
Dir.chdir('test/run_tests')
|
70
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
71
|
-
end
|
72
|
-
|
73
|
-
desc "Start docker container for testing and debugging"
|
74
|
-
task "docker" do
|
75
|
-
Dir.chdir('test/run_tests')
|
76
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "Stop all containers that were started for testing and debugging"
|
80
|
-
task "docker_down" do
|
81
|
-
Dir.chdir('test/run_tests')
|
82
|
-
exec('docker-compose down')
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "Fetch extension dependency files"
|
86
|
-
task :fetch_ext_deps do
|
87
|
-
swig_version = %x{swig -version} rescue ''
|
88
|
-
swig_version = swig_version.scan(/swig version [34].0.\d*/i)
|
89
|
-
if swig_version.empty?
|
90
|
-
$stderr.puts '== ERROR ================================================================='
|
91
|
-
$stderr.puts "Could not find required swig version >3.0.8, found #{swig_version.inspect}"
|
92
|
-
$stderr.puts 'Please install swig "~ 3.0.12" and try again.'
|
93
|
-
$stderr.puts '=========================================================================='
|
94
|
-
raise
|
95
|
-
end
|
96
|
-
|
97
|
-
# The c-lib version is different from the gem version
|
98
|
-
oboe_version = ENV['OBOE_VERSION'] || 'latest'
|
99
|
-
oboe_s3_dir = "https://s3-us-west-2.amazonaws.com/rc-files-t2/c-lib/#{oboe_version}"
|
100
|
-
ext_src_dir = File.expand_path('ext/oboe_metal/src')
|
101
|
-
|
102
|
-
# VERSION is used by extconf.rb to download the correct liboboe when installing the gem
|
103
|
-
remote_file = File.join(oboe_s3_dir, 'VERSION')
|
104
|
-
local_file = File.join(ext_src_dir, 'VERSION')
|
105
|
-
puts "fetching #{remote_file} to #{local_file}"
|
106
|
-
open(remote_file, 'rb') do |rf|
|
107
|
-
content = rf.read
|
108
|
-
File.open(local_file, 'wb') { |f| f.puts content }
|
109
|
-
puts "!!!!!!! C-Lib VERSION: #{content.strip} !!!!!!!!"
|
110
|
-
end
|
111
|
-
|
112
|
-
# oboe and bson header files
|
113
|
-
FileUtils.mkdir_p(File.join(ext_src_dir, 'bson'))
|
114
|
-
%w(oboe.h oboe.hpp oboe_debug.h oboe.i bson/bson.h bson/platform_hacks.h).each do |filename|
|
115
|
-
# %w(oboe.h oboe_debug.h bson/bson.h bson/platform_hacks.h).each do |filename|
|
116
|
-
remote_file = File.join(oboe_s3_dir, 'include', filename)
|
117
|
-
local_file = File.join(ext_src_dir, filename)
|
118
|
-
|
119
|
-
puts "fetching #{remote_file} to #{local_file}"
|
120
|
-
open(remote_file, 'rb') do |rf|
|
121
|
-
content = rf.read
|
122
|
-
File.open(local_file, 'wb') { |f| f.puts content }
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
FileUtils.cd(ext_src_dir) do
|
127
|
-
system('swig -c++ -ruby -module oboe_metal oboe.i')
|
128
|
-
FileUtils.rm('oboe.i')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
task :fetch => :fetch_ext_deps
|
133
|
-
|
134
|
-
desc "Build the gem's c extension"
|
135
|
-
task :compile do
|
136
|
-
if !defined?(JRUBY_VERSION)
|
137
|
-
puts "== Building the c extension against Ruby #{RUBY_VERSION}"
|
138
|
-
|
139
|
-
pwd = Dir.pwd
|
140
|
-
ext_dir = File.expand_path('ext/oboe_metal')
|
141
|
-
final_so = File.expand_path('lib/oboe_metal.so')
|
142
|
-
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
|
143
|
-
|
144
|
-
Dir.chdir ext_dir
|
145
|
-
# ENV['APPOPTICS_FROM_S3'] = 'true'
|
146
|
-
cmd = [Gem.ruby, 'extconf.rb']
|
147
|
-
sh cmd.join(' ')
|
148
|
-
sh '/usr/bin/env make'
|
149
|
-
|
150
|
-
File.delete(final_so) if File.exist?(final_so)
|
151
|
-
|
152
|
-
if File.exist?(so_file)
|
153
|
-
FileUtils.mv(so_file, final_so)
|
154
|
-
Dir.chdir(pwd)
|
155
|
-
puts "== Extension built and moved to #{final_so}"
|
156
|
-
else
|
157
|
-
Dir.chdir(pwd)
|
158
|
-
puts '!! Extension failed to build (see above). Have the required binary and header files been fetched?'
|
159
|
-
puts '!! Try the tasks in this order: clean > fetch_ext_deps > compile.'
|
160
|
-
end
|
161
|
-
else
|
162
|
-
puts '== Nothing to do under JRuby.'
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
desc 'Clean up extension build files'
|
167
|
-
task :clean do
|
168
|
-
if !defined?(JRUBY_VERSION)
|
169
|
-
pwd = Dir.pwd
|
170
|
-
ext_dir = File.expand_path('ext/oboe_metal')
|
171
|
-
symlinks = [
|
172
|
-
File.expand_path('lib/oboe_metal.so'),
|
173
|
-
File.expand_path('ext/oboe_metal/lib/liboboe.so'),
|
174
|
-
File.expand_path('ext/oboe_metal/lib/liboboe-1.0.so.0')
|
175
|
-
]
|
176
|
-
|
177
|
-
symlinks.each do |symlink|
|
178
|
-
FileUtils.rm_f symlink
|
179
|
-
end
|
180
|
-
Dir.chdir ext_dir
|
181
|
-
sh '/usr/bin/env make clean' if File.exist? 'Makefile'
|
182
|
-
|
183
|
-
FileUtils.rm_f "src/oboe_wrap.cxx"
|
184
|
-
Dir.chdir pwd
|
185
|
-
else
|
186
|
-
puts '== Nothing to do under JRuby.'
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
desc 'Remove all built files and extensions'
|
191
|
-
task :distclean do
|
192
|
-
if !defined?(JRUBY_VERSION)
|
193
|
-
pwd = Dir.pwd
|
194
|
-
ext_dir = File.expand_path('ext/oboe_metal')
|
195
|
-
mkmf_log = File.expand_path('ext/oboe_metal/mkmf.log')
|
196
|
-
symlinks = [
|
197
|
-
File.expand_path('lib/oboe_metal.so'),
|
198
|
-
File.expand_path('ext/oboe_metal/lib/liboboe.so'),
|
199
|
-
File.expand_path('ext/oboe_metal/lib/liboboe-1.0.so.0')
|
200
|
-
]
|
201
|
-
|
202
|
-
if File.exist? mkmf_log
|
203
|
-
symlinks.each do |symlink|
|
204
|
-
FileUtils.rm_f symlink
|
205
|
-
end
|
206
|
-
Dir.chdir ext_dir
|
207
|
-
sh '/usr/bin/env make distclean' if File.exist? 'Makefile'
|
208
|
-
|
209
|
-
Dir.chdir pwd
|
210
|
-
else
|
211
|
-
puts 'Nothing to distclean. (nothing built yet?)'
|
212
|
-
end
|
213
|
-
else
|
214
|
-
puts '== Nothing to do under JRuby.'
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
desc "Rebuild the gem's c extension"
|
219
|
-
task :recompile => [:distclean, :compile]
|
220
|
-
|
221
|
-
task :environment do
|
222
|
-
ENV['APPOPTICS_GEM_VERBOSE'] = 'true'
|
223
|
-
|
224
|
-
Bundler.require(:default, :development)
|
225
|
-
AppOpticsAPM::Config[:tracing_mode] = :enabled
|
226
|
-
AppOpticsAPM::Test.load_extras
|
227
|
-
|
228
|
-
if AppOpticsAPM::Test.gemfile?(:delayed_job)
|
229
|
-
require 'delayed/tasks'
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
# Used when testing Resque locally
|
234
|
-
task 'resque:setup' => :environment do
|
235
|
-
require 'resque/tasks'
|
236
|
-
end
|