@@ -37,7 +37,15 @@ def run_request_with_appoptics(method, url, body, headers, &block)
37
37
AppOpticsAPM ::XTrace . continue_service_context ( xtrace , xtrace_new )
38
38
end
39
39
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
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 @@ def url_blacklisted?
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
- ( @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
72
84
end
73
85
74
- def rsc_kvs ( url , method , result )
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
0 commit comments