Skip to content

Commit a8baee4

Browse files
authored
Merge pull request #94 from appoptics/AO-11710_AO-9152_padrino
AO-11710 AO-9152 padrino AO-14223 faraday AO-14045 azure
2 parents 8b09fa5 + 5054307 commit a8baee4

File tree

11 files changed

+37
-39
lines changed

11 files changed

+37
-39
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ rvm:
1414
- 2.6.4
1515
- 2.5.5
1616
- 2.4.5
17-
- ruby-head
17+
- 2.7.0-preview1
18+
# - ruby-head
1819
# - jruby-9.0.5.0
1920

2021
gemfile:
@@ -86,6 +87,7 @@ matrix:
8687
env: DBTYPE=mysql2
8788
allow_failures:
8889
- rvm: ruby-head
90+
- rvm: 2.7.0-preview1
8991

9092
# FIXME: Figure out if this is still an issue when reviewing cassandra test setup
9193
# Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484

Gemfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
2+
gem 'rake'
23

34
group :development, :test do
4-
gem 'rake'
55
gem 'minitest'
66
gem 'minitest-reporters', '< 1.0.18'
77
gem 'minitest-debugger', :require => false
@@ -18,12 +18,12 @@ group :development, :test do
1818
gem 'byebug'
1919
gem 'get_process_mem'
2020
gem 'memory_profiler'
21-
end
2221

23-
if defined?(JRUBY_VERSION)
24-
gem 'sinatra', :require => false
25-
else
26-
gem 'sinatra'
22+
if defined?(JRUBY_VERSION)
23+
gem 'sinatra', :require => false
24+
else
25+
gem 'sinatra'
26+
end
2727
end
2828

2929
gemspec

build_gem.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# we currently only build for MRI, no JRuby
55
echo -e "\n=== building for MRI ===\n"
66
rm -f Gemfile.lock
7-
bundle install
7+
bundle install --without development --without test
88
bundle exec rake distclean
99
bundle exec rake fetch_ext_deps
1010
gem build appoptics_apm.gemspec

ext/oboe_metal/src/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.0.0
1+
7.0.0

gemfiles/instrumentation_mocked.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ group :development, :test do
1414
gem 'mocha'
1515
end
1616

17-
gem 'curb', '0.9.7' # temporarily freeze version, TODO find fix for 0.9.8
17+
gem 'curb'
1818
gem 'excon'
1919
gem 'faraday'
2020
gem 'httpclient'

lib/appoptics_apm/frameworks/padrino.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ def render_with_appoptics(engine, data = nil, options = {}, locals = {}, &block)
4646
report_kvs[:engine] = engine
4747
report_kvs[:template] = data
4848

49-
begin
50-
report_kvs[:File] = __FILE__
51-
report_kvs[:LineNumber] = __LINE__
52-
rescue StandardError => e
53-
AppOpticsAPM.logger.debug "[appoptics_apm/padrino] #{e.message}"
54-
AppOpticsAPM.logger.debug e.backtrace.join(', ')
55-
end
56-
5749
AppOpticsAPM::SDK.trace(:padrino_render, report_kvs, :padrino_render) do
5850
report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:padrino][:collect_backtraces]
5951
render_without_appoptics(engine, data, options, locals, &block)

lib/appoptics_apm/frameworks/sinatra.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ def render_with_appoptics(engine, data, options = {}, locals = {}, &block)
6161
report_kvs[:engine] = engine
6262
report_kvs[:template] = data
6363

64-
begin
65-
report_kvs[:File] = __FILE__
66-
report_kvs[:LineNumber] = __LINE__
67-
rescue StandardError => e
68-
AppOpticsAPM.logger.debug "[appoptics_apm/sinatra] #{e.message}"
69-
AppOpticsAPM.logger.debug e.backtrace.join(', ')
70-
end
71-
7264
AppOpticsAPM::SDK.trace(:sinatra_render, report_kvs, :sinatra_render) do
7365
report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:sinatra][:collect_backtraces]
7466
render_without_appoptics(engine, data, options, locals, &block)

lib/appoptics_apm/inst/faraday.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ def run_request_with_appoptics(method, url, body, headers, &block)
3737
AppOpticsAPM::XTrace.continue_service_context(xtrace, xtrace_new)
3838
end
3939
kvs = {}
40-
kvs[:Middleware] = @builder.handlers
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
4149
kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:faraday][:collect_backtraces]
4250

4351
# Only send service KVs if we're not using an adapter
@@ -68,16 +76,20 @@ def url_blacklisted?
6876

6977
# This is only considered a remote service call if the middleware/adapter is not instrumented
7078
def remote_call?
71-
(@builder.handlers.map(&:name) & APPOPTICS_INSTR_ADAPTERS).count == 0
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
7284
end
7385

74-
def rsc_kvs(url, method, result)
86+
def rsc_kvs(_url, method, result)
7587
kvs = { :Spec => 'rsc',
7688
:IsService => 1,
7789
:HTTPMethod => method.upcase,
7890
:HTTPStatus => result.status, }
7991
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
8193
kvs[:RemoteURL].split('?').first unless AppOpticsAPM::Config[:faraday][:log_args]
8294

8395
kvs

lib/appoptics_apm/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module AppOpticsAPM
77
# appoptics_apm.gemspec during gem build process
88
module Version
99
MAJOR = 4 # breaking,
10-
MINOR = 9 # feature,
10+
MINOR = 10 # feature,
1111
PATCH = 0 # fix => BFF
1212

1313
STRING = [MAJOR, MINOR, PATCH].compact.join('.')

lib/appoptics_apm/xtrace.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ def edge_id(xtrace)
9797
# +finish+ is the context returned to us (as an HTTP response header
9898
# if that be the case)
9999
#
100-
def continue_service_context(start, finish)
101-
if AppOpticsAPM::XTrace.valid?(finish) && AppOpticsAPM.tracing?
100+
def continue_service_context(start_xtrace, end_xtrace)
101+
if AppOpticsAPM::XTrace.valid?(end_xtrace) && AppOpticsAPM.tracing?
102102

103-
# Assure that we received back a valid X-Trace with the same task_id
103+
# Make sure that we received back a valid X-Trace with the same task_id
104104
# and the sampling bit is set, otherwise it is a response from a non-sampling service
105-
if AppOpticsAPM::XTrace.task_id(start) == AppOpticsAPM::XTrace.task_id(finish) &&
106-
AppOpticsAPM::XTrace.sampled?(finish)
107-
AppOpticsAPM::Context.fromString(finish)
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)
108108
else
109-
AppOpticsAPM.logger.debug "[XTrace] Sampling flag unset or mismatched start and finish ids:\n#{start}\n#{finish}"
109+
AppOpticsAPM.logger.debug "[XTrace] Sampling flag unset or mismatched start and finish ids:\n#{start_xtrace}\n#{end_xtrace}"
110110
end
111111
end
112112
end

0 commit comments

Comments
 (0)