instana 1.13.0 → 1.193.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +200 -133
- data/.editorconfig +10 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -1147
- data/.rubocop_todo.yml +1140 -0
- data/Appraisals +100 -0
- data/Gemfile +11 -32
- data/Rakefile +16 -39
- data/bin/console +5 -4
- data/gemfiles/.bundle/config +1 -2
- data/gemfiles/cuba_30.gemfile +15 -0
- data/gemfiles/dalli_20.gemfile +15 -0
- data/gemfiles/excon_02.gemfile +15 -0
- data/gemfiles/graphql_10.gemfile +15 -0
- data/gemfiles/grpc_10.gemfile +15 -0
- data/gemfiles/net_http_01.gemfile +14 -0
- data/gemfiles/rack_16.gemfile +15 -0
- data/gemfiles/rack_20.gemfile +15 -0
- data/gemfiles/rails_42.gemfile +18 -0
- data/gemfiles/rails_50.gemfile +18 -0
- data/gemfiles/rails_52.gemfile +18 -0
- data/gemfiles/rails_60.gemfile +18 -0
- data/gemfiles/redis_40.gemfile +15 -0
- data/gemfiles/resque_122.gemfile +16 -0
- data/gemfiles/resque_20.gemfile +15 -0
- data/gemfiles/rest_client_16.gemfile +15 -0
- data/gemfiles/rest_client_20.gemfile +15 -0
- data/gemfiles/roda_20.gemfile +15 -0
- data/gemfiles/roda_30.gemfile +15 -0
- data/gemfiles/sidekiq_42.gemfile +15 -0
- data/gemfiles/sidekiq_50.gemfile +15 -0
- data/gemfiles/sinatra_14.gemfile +15 -0
- data/instana.gemspec +1 -7
- data/lib/instana/activator.rb +41 -0
- data/lib/instana/activators/action_controller_api.rb +18 -0
- data/lib/instana/activators/action_controller_base.rb +18 -0
- data/lib/instana/activators/action_view.rb +18 -0
- data/lib/instana/activators/active_record.rb +18 -0
- data/lib/instana/activators/cuba.rb +18 -0
- data/lib/instana/activators/dalli.rb +20 -0
- data/lib/instana/activators/excon.rb +17 -0
- data/lib/instana/activators/graphql.rb +19 -0
- data/lib/instana/activators/grpc_client.rb +17 -0
- data/lib/instana/activators/grpc_server.rb +17 -0
- data/lib/instana/activators/net_http.rb +17 -0
- data/lib/instana/activators/rack.rb +13 -0
- data/lib/instana/activators/rails.rb +15 -0
- data/lib/instana/activators/redis.rb +17 -0
- data/lib/instana/activators/resque_client.rb +18 -0
- data/lib/instana/activators/resque_worker.rb +30 -0
- data/lib/instana/activators/rest_client.rb +17 -0
- data/lib/instana/activators/roda.rb +18 -0
- data/lib/instana/activators/sidekiq_client.rb +21 -0
- data/lib/instana/activators/sidekiq_worker.rb +21 -0
- data/lib/instana/activators/sinatra.rb +18 -0
- data/lib/instana/config.rb +11 -0
- data/lib/instana/frameworks/cuba.rb +6 -13
- data/lib/instana/frameworks/rails.rb +20 -33
- data/lib/instana/frameworks/roda.rb +7 -13
- data/lib/instana/frameworks/sinatra.rb +1 -8
- data/lib/instana/instrumentation/action_controller.rb +81 -0
- data/lib/instana/instrumentation/action_view.rb +27 -0
- data/lib/instana/instrumentation/active_record.rb +47 -0
- data/lib/instana/instrumentation/dalli.rb +7 -18
- data/lib/instana/instrumentation/excon.rb +51 -57
- data/lib/instana/instrumentation/graphql.rb +75 -0
- data/lib/instana/instrumentation/grpc.rb +70 -66
- data/lib/instana/instrumentation/instrumented_request.rb +69 -0
- data/lib/instana/instrumentation/net-http.rb +43 -47
- data/lib/instana/instrumentation/rack.rb +14 -53
- data/lib/instana/instrumentation/redis.rb +10 -18
- data/lib/instana/instrumentation/resque.rb +14 -50
- data/lib/instana/instrumentation/rest-client.rb +2 -17
- data/lib/instana/instrumentation/sidekiq-client.rb +0 -9
- data/lib/instana/instrumentation/sidekiq-worker.rb +0 -9
- data/lib/instana/secrets.rb +7 -7
- data/lib/instana/setup.rb +3 -1
- data/lib/instana/tracer.rb +6 -0
- data/lib/instana/tracing/span.rb +14 -10
- data/lib/instana/util.rb +15 -69
- data/lib/instana/version.rb +1 -1
- data/test/activator_test.rb +27 -0
- data/test/frameworks/cuba_test.rb +38 -40
- data/test/frameworks/roda_test.rb +39 -41
- data/test/frameworks/sinatra_test.rb +61 -64
- data/test/instrumentation/excon_test.rb +1 -2
- data/test/instrumentation/graphql_test.rb +116 -0
- data/test/instrumentation/grpc_test.rb +2 -1
- data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +1 -0
- data/test/instrumentation/rack_instrumented_request_test.rb +84 -0
- data/test/{frameworks → instrumentation}/rack_test.rb +32 -20
- data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +37 -21
- data/test/instrumentation/rails_action_view_test.rb +138 -0
- data/test/instrumentation/rails_active_record_test.rb +121 -0
- data/test/instrumentation/redis_test.rb +10 -0
- data/test/instrumentation/resque_test.rb +3 -11
- data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +6 -0
- data/test/instrumentation/sidekiq-client_test.rb +1 -0
- data/test/instrumentation/sidekiq-worker_test.rb +1 -0
- data/test/support/apps/active_record/active_record.rb +21 -0
- data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +1 -1
- data/test/{apps → support/apps/grpc}/grpc_server.rb +0 -0
- data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +0 -0
- data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +8 -14
- data/test/{models → support/apps/rails/models}/block.rb +1 -1
- data/test/{models → support/apps/rails/models}/block6.rb +0 -0
- data/test/support/apps/resque/boot.rb +2 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +0 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +0 -0
- data/test/support/apps/sidekiq/boot.rb +21 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +0 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +0 -0
- data/test/{servers → support/apps}/sidekiq/worker.rb +2 -2
- data/test/support/helpers.rb +94 -0
- data/test/test_helper.rb +24 -144
- data/test/tracing/id_management_test.rb +4 -66
- metadata +106 -95
- data/gemfiles/libraries.gemfile +0 -71
- data/gemfiles/rails32.gemfile +0 -51
- data/gemfiles/rails42.gemfile +0 -50
- data/gemfiles/rails50.gemfile +0 -52
- data/gemfiles/rails52.gemfile +0 -52
- data/gemfiles/rails60.gemfile +0 -72
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
- data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
- data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
- data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -81
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -56
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -85
- data/lib/instana/instrumentation.rb +0 -25
- data/lib/instana/test.rb +0 -43
- data/test/apps/cuba.rb +0 -19
- data/test/apps/roda.rb +0 -13
- data/test/apps/sinatra.rb +0 -9
- data/test/frameworks/rails/actionview3_test.rb +0 -210
- data/test/frameworks/rails/actionview4_test.rb +0 -208
- data/test/frameworks/rails/actionview5_test.rb +0 -221
- data/test/frameworks/rails/activerecord_test.rb +0 -227
- data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -34,12 +34,3 @@ module Instana
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
|
-
if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
|
39
|
-
::Sidekiq.configure_client do |cfg|
|
40
|
-
cfg.client_middleware do |chain|
|
41
|
-
::Instana.logger.debug "Instrumenting Sidekiq client"
|
42
|
-
chain.add ::Instana::Instrumentation::SidekiqClient
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -43,12 +43,3 @@ module Instana
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
|
48
|
-
::Sidekiq.configure_server do |cfg|
|
49
|
-
cfg.server_middleware do |chain|
|
50
|
-
::Instana.logger.debug "Instrumenting Sidekiq worker"
|
51
|
-
chain.add ::Instana::Instrumentation::SidekiqWorker
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/instana/secrets.rb
CHANGED
@@ -2,25 +2,25 @@ require 'uri'
|
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
module Instana
|
5
|
-
class Secrets
|
5
|
+
class Secrets
|
6
6
|
def remove_from_query(str, secret_values = Instana.agent.secret_values)
|
7
7
|
return str unless secret_values
|
8
|
-
|
8
|
+
|
9
9
|
url = URI(str)
|
10
|
-
params = CGI.parse(url.query)
|
11
|
-
|
10
|
+
params = CGI.parse(url.query || '')
|
11
|
+
|
12
12
|
redacted = params.map do |k, v|
|
13
13
|
needs_redaction = secret_values['list']
|
14
14
|
.any? { |t| matcher(secret_values['matcher']).(t,k) }
|
15
15
|
[k, needs_redaction ? '<redacted>' : v]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
url.query = URI.encode_www_form(redacted)
|
19
19
|
CGI.unescape(url.to_s)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
private
|
23
|
-
|
23
|
+
|
24
24
|
def matcher(name)
|
25
25
|
case name
|
26
26
|
when 'equals-ignore-case'
|
data/lib/instana/setup.rb
CHANGED
@@ -7,10 +7,12 @@ require "instana/collector"
|
|
7
7
|
require "instana/secrets"
|
8
8
|
require "instana/tracer"
|
9
9
|
require "instana/tracing/processor"
|
10
|
-
|
10
|
+
|
11
|
+
require 'instana/activator'
|
11
12
|
|
12
13
|
::Instana.setup
|
13
14
|
::Instana.agent.setup
|
15
|
+
::Instana::Activator.start
|
14
16
|
|
15
17
|
# Register the metric collectors
|
16
18
|
unless RUBY_PLATFORM == 'java'.freeze
|
data/lib/instana/tracer.rb
CHANGED
@@ -100,6 +100,12 @@ module Instana
|
|
100
100
|
else
|
101
101
|
self.current_span = Span.new(name)
|
102
102
|
end
|
103
|
+
|
104
|
+
if incoming_context.is_a?(Hash) && incoming_context[:correlation] && !incoming_context[:correlation].empty?
|
105
|
+
self.current_span[:crid] = incoming_context[:correlation][:id]
|
106
|
+
self.current_span[:crtp] = incoming_context[:correlation][:type]
|
107
|
+
end
|
108
|
+
|
103
109
|
self.current_span.set_tags(kvs) unless kvs.empty?
|
104
110
|
self.current_span
|
105
111
|
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -3,8 +3,8 @@ module Instana
|
|
3
3
|
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
4
4
|
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
5
5
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
6
|
-
:redis, :'resque-client', :'resque-worker' ].freeze
|
7
|
-
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker' ].freeze
|
6
|
+
:redis, :'resque-client', :'resque-worker', :'graphql.server' ].freeze
|
7
|
+
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze
|
8
8
|
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
|
9
9
|
:'rpc-client', :'sidekiq-client', :redis ].freeze
|
10
10
|
HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
|
@@ -57,9 +57,6 @@ module Instana
|
|
57
57
|
end
|
58
58
|
|
59
59
|
if ::Instana.config[:collect_backtraces]
|
60
|
-
# For entry spans, add a backtrace fingerprint
|
61
|
-
add_stack(limit: 2) if ENTRY_SPANS.include?(name)
|
62
|
-
|
63
60
|
# Attach a backtrace to all exit spans
|
64
61
|
add_stack if EXIT_SPANS.include?(name)
|
65
62
|
end
|
@@ -76,9 +73,11 @@ module Instana
|
|
76
73
|
#
|
77
74
|
# @param limit [Integer] Limit the backtrace to the top <limit> frames
|
78
75
|
#
|
79
|
-
def add_stack(limit:
|
76
|
+
def add_stack(limit: 30, stack: Kernel.caller)
|
80
77
|
frame_count = 0
|
78
|
+
sanitized_stack = []
|
81
79
|
@data[:stack] = []
|
80
|
+
limit = 40 if limit > 40
|
82
81
|
|
83
82
|
stack.each do |i|
|
84
83
|
# If the stack has the full instana gem version in it's path
|
@@ -86,18 +85,23 @@ module Instana
|
|
86
85
|
if !i.match(/instana\/instrumentation\/rack.rb/).nil? ||
|
87
86
|
(i.match(::Instana::VERSION_FULL).nil? && i.match('lib/instana/').nil?)
|
88
87
|
|
89
|
-
break if limit && frame_count >= limit
|
90
|
-
|
91
88
|
x = i.split(':')
|
92
89
|
|
93
|
-
|
90
|
+
sanitized_stack << {
|
94
91
|
:c => x[0],
|
95
92
|
:n => x[1],
|
96
93
|
:m => x[2]
|
97
94
|
}
|
98
|
-
frame_count = frame_count + 1 if limit
|
99
95
|
end
|
100
96
|
end
|
97
|
+
|
98
|
+
if sanitized_stack.length > limit
|
99
|
+
# (limit * -1) gives us negative form of <limit> used for
|
100
|
+
# slicing from the end of the list. e.g. stack[-30, 30]
|
101
|
+
@data[:stack] = sanitized_stack[limit*-1, limit]
|
102
|
+
else
|
103
|
+
@data[:stack] = sanitized_stack
|
104
|
+
end
|
101
105
|
end
|
102
106
|
|
103
107
|
# Log an error into the span
|
data/lib/instana/util.rb
CHANGED
@@ -2,46 +2,6 @@ module Instana
|
|
2
2
|
module Util
|
3
3
|
class << self
|
4
4
|
ID_RANGE = -2**63..2**63-1
|
5
|
-
|
6
|
-
# An agnostic approach to method aliasing.
|
7
|
-
#
|
8
|
-
# @param klass [Object] The class or module that holds the method to be alias'd.
|
9
|
-
# @param method [Symbol] The name of the method to be aliased.
|
10
|
-
#
|
11
|
-
def method_alias(klass, method)
|
12
|
-
if klass.method_defined?(method.to_sym) ||
|
13
|
-
klass.private_method_defined?(method.to_sym)
|
14
|
-
|
15
|
-
with = "#{method}_with_instana"
|
16
|
-
without = "#{method}_without_instana"
|
17
|
-
|
18
|
-
klass.class_eval do
|
19
|
-
alias_method without, method.to_s
|
20
|
-
alias_method method.to_s, with
|
21
|
-
end
|
22
|
-
else
|
23
|
-
::Instana.logger.debug "No such method (#{method}) to alias on #{klass}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Calls on target_class to 'extend' cls
|
28
|
-
#
|
29
|
-
# @param target_cls [Object] the class/module to do the 'extending'
|
30
|
-
# @param cls [Object] the class/module to be 'extended'
|
31
|
-
#
|
32
|
-
def send_extend(target_cls, cls)
|
33
|
-
target_cls.send(:extend, cls) if defined?(target_cls)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Calls on <target_cls> to include <cls> into itself.
|
37
|
-
#
|
38
|
-
# @param target_cls [Object] the class/module to do the 'including'
|
39
|
-
# @param cls [Object] the class/module to be 'included'
|
40
|
-
#
|
41
|
-
def send_include(target_cls, cls)
|
42
|
-
target_cls.send(:include, cls) if defined?(target_cls)
|
43
|
-
end
|
44
|
-
|
45
5
|
# Debugging helper method
|
46
6
|
#
|
47
7
|
def pry!
|
@@ -225,53 +185,39 @@ module Instana
|
|
225
185
|
(time.to_f * 1000).floor
|
226
186
|
end
|
227
187
|
|
228
|
-
# Generate a random 64bit ID
|
188
|
+
# Generate a random 64bit/128bit ID
|
189
|
+
#
|
190
|
+
# @param size [Integer] Number of 64 bit integers used to generate the id
|
229
191
|
#
|
230
|
-
# @return [
|
192
|
+
# @return [String] a random 64bit/128bit hex encoded string
|
231
193
|
#
|
232
|
-
def generate_id
|
233
|
-
|
234
|
-
|
194
|
+
def generate_id(size = 1)
|
195
|
+
Array.new(size) { rand(ID_RANGE) }
|
196
|
+
.pack('q>*')
|
197
|
+
.unpack('H*')
|
198
|
+
.first
|
235
199
|
end
|
236
200
|
|
237
201
|
# Convert an ID to a value appropriate to pass in a header.
|
238
202
|
#
|
239
|
-
# @param id [
|
203
|
+
# @param id [String] the id to be converted
|
240
204
|
#
|
241
205
|
# @return [String]
|
242
206
|
#
|
243
207
|
def id_to_header(id)
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
end
|
248
|
-
[id.to_i].pack('q>').unpack('H*')[0].gsub(/^0+/, '')
|
249
|
-
rescue => e
|
250
|
-
Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
251
|
-
Instana.logger.debug { e.backtrace.join("\r\n") }
|
208
|
+
return '' unless id.is_a?(String)
|
209
|
+
# Only send 64bit IDs downstream for now
|
210
|
+
id.length == 32 ? id[16..-1] : id
|
252
211
|
end
|
253
212
|
|
254
213
|
# Convert a received header value into a valid ID
|
255
214
|
#
|
256
215
|
# @param header_id [String] the header value to be converted
|
257
216
|
#
|
258
|
-
# @return [
|
217
|
+
# @return [String]
|
259
218
|
#
|
260
219
|
def header_to_id(header_id)
|
261
|
-
|
262
|
-
Instana.logger.debug "header_to_id received a #{header_id.class}: returning 0"
|
263
|
-
return 0
|
264
|
-
end
|
265
|
-
if header_id.length < 16
|
266
|
-
# The header is less than 16 chars. Prepend
|
267
|
-
# zeros so we can convert correctly
|
268
|
-
missing = 16 - header_id.length
|
269
|
-
header_id = ("0" * missing) + header_id
|
270
|
-
end
|
271
|
-
[header_id].pack("H*").unpack("q>")[0]
|
272
|
-
rescue => e
|
273
|
-
Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
274
|
-
Instana.logger.debug { e.backtrace.join("\r\n") }
|
220
|
+
header_id.is_a?(String) && header_id.match(/\A[a-z\d]{16,32}\z/i) ? header_id : ''
|
275
221
|
end
|
276
222
|
end
|
277
223
|
end
|
data/lib/instana/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActivatorTest < Minitest::Test
|
4
|
+
def test_start
|
5
|
+
refute_nil Instana::Activator.trace_point
|
6
|
+
assert Instana::Activator.trace_point.enabled?
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_klass_call
|
10
|
+
assert_equal [], Instana::Activator.call
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_instance_call
|
14
|
+
subject = Class.new(Instana::Activator) do
|
15
|
+
def can_instrument?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def instrument
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_equal 1, Instana::Activator.call.length
|
25
|
+
assert subject.call
|
26
|
+
end
|
27
|
+
end
|
@@ -1,57 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../apps/cuba')
|
4
|
-
require 'rack/test'
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rack/test'
|
5
3
|
|
6
|
-
|
7
|
-
|
4
|
+
class CubaTest < Minitest::Test
|
5
|
+
include Rack::Test::Methods
|
6
|
+
APP = Rack::Builder.parse_file('test/support/apps/cuba/config.ru').first
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def app
|
9
|
+
APP
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
def test_basic_get
|
13
|
+
clear_all!
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
r = get '/hello'
|
16
|
+
assert last_response.ok?
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
assert r.headers.key?("X-Instana-T")
|
19
|
+
assert r.headers.key?("X-Instana-S")
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
spans = ::Instana.processor.queued_spans
|
22
|
+
assert_equal 1, spans.count
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
first_span = spans.first
|
25
|
+
assert_equal :rack, first_span[:n]
|
26
|
+
assert first_span.key?(:data)
|
27
|
+
assert first_span[:data].key?(:http)
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
assert first_span[:data][:http].key?(:method)
|
30
|
+
assert_equal "GET", first_span[:data][:http][:method]
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
assert first_span[:data][:http].key?(:url)
|
33
|
+
assert_equal "/hello", first_span[:data][:http][:url]
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
assert first_span[:data][:http].key?(:status)
|
36
|
+
assert_equal 200, first_span[:data][:http][:status]
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
assert first_span[:data][:http].key?(:host)
|
39
|
+
assert_equal "example.org", first_span[:data][:http][:host]
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
42
|
+
def test_path_template
|
43
|
+
clear_all!
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
r = get '/greet/instana'
|
46
|
+
assert last_response.ok?
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
spans = ::Instana.processor.queued_spans
|
49
|
+
assert_equal 1, spans.count
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
51
|
+
first_span = spans.first
|
52
|
+
assert_equal :rack, first_span[:n]
|
53
|
+
assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
|
56
54
|
end
|
57
55
|
end
|
@@ -1,58 +1,56 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + '/../apps/roda')
|
5
|
-
require 'rack/test'
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rack/test'
|
6
4
|
|
7
|
-
|
8
|
-
|
5
|
+
class RodaTest < Minitest::Test
|
6
|
+
include Rack::Test::Methods
|
7
|
+
APP = Rack::Builder.parse_file('test/support/apps/roda/config.ru').first
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def app
|
10
|
+
APP
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_basic_get
|
14
|
+
clear_all!
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
r = get '/hello'
|
17
|
+
assert last_response.ok?
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
assert r.headers.key?("X-Instana-T")
|
20
|
+
assert r.headers.key?("X-Instana-S")
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
spans = ::Instana.processor.queued_spans
|
23
|
+
assert_equal 1, spans.count
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
first_span = spans.first
|
26
|
+
assert_equal :rack, first_span[:n]
|
27
|
+
assert first_span.key?(:data)
|
28
|
+
assert first_span[:data].key?(:http)
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
assert first_span.key?(:data)
|
29
|
-
assert first_span[:data].key?(:http)
|
30
|
+
assert first_span[:data][:http].key?(:method)
|
31
|
+
assert_equal "GET", first_span[:data][:http][:method]
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
assert first_span[:data][:http].key?(:url)
|
34
|
+
assert_equal "/hello", first_span[:data][:http][:url]
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
assert first_span[:data][:http].key?(:status)
|
37
|
+
assert_equal 200, first_span[:data][:http][:status]
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
assert first_span[:data][:http].key?(:host)
|
40
|
+
assert_equal "example.org", first_span[:data][:http][:host]
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_path_template
|
45
|
-
clear_all!
|
43
|
+
def test_path_template
|
44
|
+
clear_all!
|
46
45
|
|
47
|
-
|
48
|
-
|
46
|
+
r = get '/greet/instana'
|
47
|
+
assert last_response.ok?
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
spans = ::Instana.processor.queued_spans
|
50
|
+
assert_equal 1, spans.count
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
52
|
+
first_span = spans.first
|
53
|
+
assert_equal :rack, first_span[:n]
|
54
|
+
assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
|
57
55
|
end
|
58
56
|
end
|