instana 1.10.2-java → 1.10.3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.fasterer.yml +23 -0
- data/Gemfile +1 -1
- data/benchmarks/10k-rack-traces.rb +92 -0
- data/benchmarks/Gemfile.lock +38 -0
- data/benchmarks/rack_vanilla_vs_traced.rb +9 -4
- data/gemfiles/rails52.gemfile +52 -0
- data/lib/instana/agent.rb +56 -32
- data/lib/instana/agent/helpers.rb +1 -1
- data/lib/instana/collector.rb +3 -3
- data/lib/instana/config.rb +2 -5
- data/lib/instana/frameworks/cuba.rb +1 -1
- data/lib/instana/frameworks/instrumentation/action_controller.rb +2 -2
- data/lib/instana/frameworks/instrumentation/action_view.rb +1 -1
- data/lib/instana/frameworks/instrumentation/active_record.rb +3 -3
- data/lib/instana/frameworks/rails.rb +2 -2
- data/lib/instana/frameworks/roda.rb +1 -1
- data/lib/instana/frameworks/sinatra.rb +1 -1
- data/lib/instana/instrumentation/dalli.rb +1 -1
- data/lib/instana/instrumentation/excon.rb +1 -1
- data/lib/instana/instrumentation/grpc.rb +2 -2
- data/lib/instana/instrumentation/net-http.rb +1 -1
- data/lib/instana/instrumentation/redis.rb +1 -1
- data/lib/instana/instrumentation/resque.rb +2 -2
- data/lib/instana/instrumentation/rest-client.rb +1 -1
- data/lib/instana/instrumentation/sidekiq-client.rb +1 -1
- data/lib/instana/instrumentation/sidekiq-worker.rb +1 -1
- data/lib/instana/tracing/span.rb +14 -6
- data/lib/instana/version.rb +1 -1
- data/test/agent/agent_test.rb +10 -5
- data/test/instrumentation/dalli_test.rb +7 -7
- data/test/instrumentation/excon_test.rb +3 -3
- data/test/instrumentation/rest-client_test.rb +1 -1
- data/test/instrumentation/sidekiq-client_test.rb +2 -2
- data/test/tracing/custom_test.rb +4 -0
- data/test/tracing/tracer_test.rb +36 -4
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dba3779f4bc86e26583716484fd49063e9e56ad27d19fb78c5a255544d44fac
|
4
|
+
data.tar.gz: 24f0f1fb3fe6d12d58b531a2e11f7e36f81a210758a51a794b464bb0fc554ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e5a55cd765dbaac1af1544b40a026be3f37aa73f9c2cf97b928b784b31e48cb30b021c5891b711ec4c96094fd3ae8c731229de13366865c71912e05716adbcd
|
7
|
+
data.tar.gz: 82a5504c73b5c04e7ae76f52c712920b06d5be10e0ccd36253d16576ccbe6e7d28a27a885e3ff845dd8b711177fd00a66588fa5c877f01be70151c20505d948c
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
speedups:
|
2
|
+
rescue_vs_respond_to: true
|
3
|
+
module_eval: true
|
4
|
+
shuffle_first_vs_sample: true
|
5
|
+
for_loop_vs_each: true
|
6
|
+
each_with_index_vs_while: false
|
7
|
+
map_flatten_vs_flat_map: true
|
8
|
+
reverse_each_vs_reverse_each: true
|
9
|
+
select_first_vs_detect: true
|
10
|
+
sort_vs_sort_by: true
|
11
|
+
fetch_with_argument_vs_block: true
|
12
|
+
keys_each_vs_each_key: true
|
13
|
+
hash_merge_bang_vs_hash_brackets: true
|
14
|
+
block_vs_symbol_to_proc: true
|
15
|
+
proc_call_vs_yield: true
|
16
|
+
gsub_vs_tr: true
|
17
|
+
select_last_vs_reverse_detect: true
|
18
|
+
getter_vs_attr_reader: true
|
19
|
+
setter_vs_attr_writer: true
|
20
|
+
|
21
|
+
exclude_paths:
|
22
|
+
- 'vendor/**/*.rb'
|
23
|
+
- 'db/schema.rb'
|
data/Gemfile
CHANGED
@@ -30,7 +30,7 @@ group :development do
|
|
30
30
|
gem 'byebug', '< 9.1.0', :platform => [:mri_19, :mri_20]
|
31
31
|
gem 'pry-byebug', :platform => [:mri_19, :mri_20]
|
32
32
|
else
|
33
|
-
gem 'pry-byebug', :platform =>
|
33
|
+
gem 'pry-byebug', :platform => :ruby
|
34
34
|
end
|
35
35
|
else
|
36
36
|
gem 'pry', '0.9.12.4'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "bundler"
|
2
|
+
|
3
|
+
require 'rack'
|
4
|
+
require 'rack/builder'
|
5
|
+
require 'rack/handler/puma'
|
6
|
+
require 'net/http'
|
7
|
+
require "cgi"
|
8
|
+
Bundler.require(:default)
|
9
|
+
require "instana/rack"
|
10
|
+
require 'ruby-prof'
|
11
|
+
|
12
|
+
Thread.new do
|
13
|
+
app = Rack::Builder.new {
|
14
|
+
map "/" do
|
15
|
+
run Proc.new {
|
16
|
+
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
map "/error" do
|
20
|
+
run Proc.new {
|
21
|
+
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7011})
|
27
|
+
end
|
28
|
+
|
29
|
+
Thread.new do
|
30
|
+
app = Rack::Builder.new {
|
31
|
+
use ::Instana::Rack
|
32
|
+
map "/" do
|
33
|
+
run Proc.new {
|
34
|
+
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
map "/error" do
|
38
|
+
run Proc.new {
|
39
|
+
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
40
|
+
}
|
41
|
+
end
|
42
|
+
}
|
43
|
+
|
44
|
+
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
|
45
|
+
end
|
46
|
+
|
47
|
+
puts ""
|
48
|
+
puts "Vanilla Rack server started in background thread on localhost:7011"
|
49
|
+
puts "Instrumented Rack server started in background thread on localhost:7012"
|
50
|
+
puts ""
|
51
|
+
puts "Waiting on successful announce to host agent..."
|
52
|
+
puts ""
|
53
|
+
|
54
|
+
#RubyProf.measure_mode = RubyProf::WALL_TIME
|
55
|
+
#RubyProf.measure_mode = RubyProf::PROCESS_TIME
|
56
|
+
RubyProf.measure_mode = RubyProf::ALLOCATIONS
|
57
|
+
#RubyProf.measure_mode = RubyProf::MEMORY
|
58
|
+
|
59
|
+
while !::Instana.agent.ready? do
|
60
|
+
sleep 2
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "Starting 10k Traces..."
|
64
|
+
|
65
|
+
# uri = URI.parse("http://127.0.0.1:7011/")
|
66
|
+
# ::Net::HTTP.start(uri.host, uri.port) do |hc|
|
67
|
+
# x.report("vanilla") {
|
68
|
+
# 10_000.times {
|
69
|
+
# req = Net::HTTP::Get.new(uri.request_uri)
|
70
|
+
# hc.request(req)
|
71
|
+
# }
|
72
|
+
# }
|
73
|
+
# end
|
74
|
+
|
75
|
+
uri = URI.parse("http://127.0.0.1:7012/")
|
76
|
+
result = RubyProf.profile do
|
77
|
+
1.times {
|
78
|
+
::Instana.tracer.start_or_continue_trace(:job, {:kind => :entry}) do
|
79
|
+
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
80
|
+
::Instana.tracer.start_or_continue_trace(:rack_call) do
|
81
|
+
req = Net::HTTP::Get.new(uri.request_uri)
|
82
|
+
hc.request(req)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "Done - displaying results..."
|
90
|
+
|
91
|
+
printer = RubyProf::FlatPrinter.new(result)
|
92
|
+
printer.print(STDOUT, {})
|
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
instana (1.9.6)
|
5
|
+
ffi (>= 1.0.11)
|
6
|
+
get_process_mem (>= 0.2.1)
|
7
|
+
oj (>= 3.0.11)
|
8
|
+
sys-proctable (>= 0.9.2)
|
9
|
+
timers (>= 4.0.0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
ffi (1.11.1)
|
15
|
+
get_process_mem (0.2.4)
|
16
|
+
ffi (~> 1.0)
|
17
|
+
nio4r (2.4.0)
|
18
|
+
oj (3.8.1)
|
19
|
+
puma (4.1.0)
|
20
|
+
nio4r (~> 2.0)
|
21
|
+
rack (2.0.7)
|
22
|
+
ruby-prof (1.0.0)
|
23
|
+
sys-proctable (1.2.2)
|
24
|
+
ffi
|
25
|
+
timers (4.3.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
x86_64-darwin-18
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
instana!
|
33
|
+
puma
|
34
|
+
rack
|
35
|
+
ruby-prof
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.0.2
|
@@ -44,11 +44,16 @@ Thread.new do
|
|
44
44
|
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
puts "Rack server started in background thread on localhost:7011"
|
49
|
-
puts "
|
50
|
-
|
47
|
+
puts ""
|
48
|
+
puts "Vanilla Rack server started in background thread on localhost:7011"
|
49
|
+
puts "Instrumented Rack server started in background thread on localhost:7012"
|
50
|
+
puts ""
|
51
|
+
puts "Waiting on successful announce to host agent..."
|
52
|
+
puts ""
|
51
53
|
|
54
|
+
while !::Instana.agent.ready? do
|
55
|
+
sleep 2
|
56
|
+
end
|
52
57
|
|
53
58
|
puts "Starting benchmarks"
|
54
59
|
Benchmark.bm do |x|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :development, :test do
|
4
|
+
gem 'rake'
|
5
|
+
gem 'minitest', '5.9.1'
|
6
|
+
gem 'minitest-reporters'
|
7
|
+
gem 'minitest-debugger', :require => false
|
8
|
+
gem 'rack-test'
|
9
|
+
gem 'webmock'
|
10
|
+
gem 'puma'
|
11
|
+
# public_suffix dropped support for Ruby 2.1 and earlier.
|
12
|
+
gem 'public_suffix', '< 3.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'ruby-debug', :platforms => [:mri_18, :jruby]
|
17
|
+
gem 'debugger', :platform => :mri_19
|
18
|
+
|
19
|
+
if RUBY_VERSION > '1.8.7'
|
20
|
+
gem 'pry'
|
21
|
+
|
22
|
+
if RUBY_VERSION < '2.2'
|
23
|
+
gem 'byebug', '< 9.1.0'
|
24
|
+
gem 'pry-byebug'
|
25
|
+
else
|
26
|
+
gem 'pry-byebug'
|
27
|
+
end
|
28
|
+
else
|
29
|
+
gem 'pry', '0.9.12.4'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
gem 'rails', '~> 5.2'
|
34
|
+
gem 'sass-rails', '~> 5.0'
|
35
|
+
gem 'uglifier', '>= 1.3.0'
|
36
|
+
gem 'coffee-rails', '~> 4.2'
|
37
|
+
# gem 'therubyracer', platforms: :ruby
|
38
|
+
|
39
|
+
gem 'jquery-rails'
|
40
|
+
gem 'turbolinks', '~> 5'
|
41
|
+
gem 'jbuilder', '~> 2.5'
|
42
|
+
|
43
|
+
gem 'pg'
|
44
|
+
gem 'mysql2', '0.4.10'
|
45
|
+
|
46
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
47
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
48
|
+
|
49
|
+
# Include the Instana Ruby gem's base set of gems
|
50
|
+
gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
|
51
|
+
|
52
|
+
# vim:syntax=ruby
|
data/lib/instana/agent.rb
CHANGED
@@ -26,11 +26,17 @@ module Instana
|
|
26
26
|
attr_accessor :thread_spawn_lock
|
27
27
|
attr_accessor :extra_headers
|
28
28
|
|
29
|
+
attr_accessor :testmode
|
30
|
+
|
29
31
|
LOCALHOST = '127.0.0.1'.freeze
|
30
32
|
MIME_JSON = 'application/json'.freeze
|
31
33
|
DISCOVERY_PATH = 'com.instana.plugin.ruby.discovery'.freeze
|
34
|
+
METRICS_PATH = "com.instana.plugin.ruby.%s"
|
35
|
+
TRACES_PATH = "com.instana.plugin.ruby/traces.%s"
|
32
36
|
|
33
37
|
def initialize
|
38
|
+
@testmode = ENV.key?('INSTANA_TEST')
|
39
|
+
|
34
40
|
# Supported two states (unannounced & announced)
|
35
41
|
@state = :unannounced
|
36
42
|
|
@@ -44,6 +50,7 @@ module Instana
|
|
44
50
|
# Two timers, one for each state (unannounced & announced)
|
45
51
|
@timers = ::Timers::Group.new
|
46
52
|
@announce_timer = nil
|
53
|
+
@pending_timer = nil
|
47
54
|
@collect_timer = nil
|
48
55
|
|
49
56
|
@thread_spawn_lock = Mutex.new
|
@@ -111,15 +118,31 @@ module Instana
|
|
111
118
|
# The announce timer
|
112
119
|
# We attempt to announce this ruby sensor to the host agent.
|
113
120
|
# In case of failure, we try again in 30 seconds.
|
114
|
-
@announce_timer = @timers.
|
121
|
+
@announce_timer = @timers.now_and_every(30) do
|
115
122
|
if @state == :unannounced
|
116
123
|
if host_agent_available? && announce_sensor
|
117
124
|
transition_to(:announced)
|
118
|
-
::Instana.logger.
|
125
|
+
::Instana.logger.debug "Announce successful. Waiting on ready. (#{@state} pid:#{Process.pid} #{@process[:name]})"
|
119
126
|
end
|
120
127
|
end
|
121
128
|
end
|
122
129
|
|
130
|
+
# The pending timer
|
131
|
+
# Handles the time between successful announce and when the host agent METRICS_PATH and TRACES_PATH
|
132
|
+
# no longer return 404s and are truly ready to accept data.
|
133
|
+
@pending_timer = @timers.now_and_every(1) do
|
134
|
+
path = sprintf(METRICS_PATH, @process[:report_pid])
|
135
|
+
uri = URI.parse("http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/#{path}")
|
136
|
+
req = Net::HTTP::Post.new(uri)
|
137
|
+
req.body = Oj.dump({}, OJ_OPTIONS)
|
138
|
+
|
139
|
+
response = make_host_agent_request(req)
|
140
|
+
if response && (response.code.to_i == 200)
|
141
|
+
transition_to(:ready)
|
142
|
+
::Instana.logger.info "Host agent available. We're in business. (#{@state} pid:#{Process.pid} #{@process[:name]})"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
123
146
|
# The collect timer
|
124
147
|
# If we are in announced state, send metric data (only delta reporting)
|
125
148
|
# every ::Instana.config[:collector][:interval] seconds.
|
@@ -129,7 +152,7 @@ module Instana
|
|
129
152
|
# then we just skip.
|
130
153
|
unless (Time.now - @last_collect_run) < ::Instana.config[:collector][:interval]
|
131
154
|
@last_collect_run = Time.now
|
132
|
-
if @state == :
|
155
|
+
if @state == :ready
|
133
156
|
if !::Instana.collector.collect_and_report
|
134
157
|
# If report has been failing for more than 1 minute,
|
135
158
|
# fall back to unannounced state
|
@@ -151,16 +174,22 @@ module Instana
|
|
151
174
|
def start
|
152
175
|
if !host_agent_available?
|
153
176
|
if !ENV.key?("INSTANA_QUIET")
|
154
|
-
::Instana.logger.
|
177
|
+
::Instana.logger.info "Instana host agent not available. Will retry periodically. (Set env INSTANA_QUIET=1 to shut these messages off)"
|
155
178
|
end
|
156
179
|
end
|
157
180
|
|
158
181
|
while true
|
159
182
|
if @state == :unannounced
|
160
|
-
@collect_timer.pause
|
161
183
|
@announce_timer.resume
|
162
|
-
|
184
|
+
@pending_timer.pause
|
185
|
+
@collect_timer.pause
|
186
|
+
elsif @state == :announced
|
187
|
+
@announce_timer.pause
|
188
|
+
@pending_timer.resume
|
189
|
+
@collect_timer.pause
|
190
|
+
elsif @state == :ready
|
163
191
|
@announce_timer.pause
|
192
|
+
@pending_timer.pause
|
164
193
|
@collect_timer.resume
|
165
194
|
end
|
166
195
|
@timers.wait
|
@@ -169,11 +198,12 @@ module Instana
|
|
169
198
|
::Instana.logger.warn { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
170
199
|
::Instana.logger.debug { e.backtrace.join("\r\n") }
|
171
200
|
ensure
|
172
|
-
if @state == :
|
201
|
+
if @state == :ready
|
173
202
|
# Pause the timers so they don't fire while we are
|
174
203
|
# reporting traces
|
175
|
-
@collect_timer.pause
|
176
204
|
@announce_timer.pause
|
205
|
+
@pending_timer.pause
|
206
|
+
@collect_timer.pause
|
177
207
|
|
178
208
|
::Instana.logger.debug { "#{Thread.current}: Agent exiting. Reporting final spans (if any)." }
|
179
209
|
::Instana.processor.send
|
@@ -198,7 +228,7 @@ module Instana
|
|
198
228
|
announce_payload[:name] = @process[:name]
|
199
229
|
announce_payload[:args] = @process[:arguments]
|
200
230
|
|
201
|
-
if @is_linux &&
|
231
|
+
if @is_linux && !@testmode
|
202
232
|
# We create an open socket to the host agent in case we are running in a container
|
203
233
|
# and the real pid needs to be detected.
|
204
234
|
socket = TCPSocket.new @discovered[:agent_host], @discovered[:agent_port]
|
@@ -241,12 +271,12 @@ module Instana
|
|
241
271
|
# @return [Boolean] true on success, false otherwise
|
242
272
|
#
|
243
273
|
def report_metrics(payload)
|
244
|
-
|
245
|
-
::Instana.logger.debug
|
274
|
+
if @state != :ready && !@testmode
|
275
|
+
::Instana.logger.debug "report_metrics called but agent not in ready state."
|
246
276
|
return false
|
247
277
|
end
|
248
278
|
|
249
|
-
path =
|
279
|
+
path = sprintf(METRICS_PATH, @process[:report_pid])
|
250
280
|
uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
|
251
281
|
req = Net::HTTP::Post.new(uri)
|
252
282
|
|
@@ -274,18 +304,16 @@ module Instana
|
|
274
304
|
|
275
305
|
# Accept and report spans to the host agent.
|
276
306
|
#
|
277
|
-
# @param
|
307
|
+
# @param spans [Array] An array of [Span]
|
278
308
|
# @return [Boolean]
|
279
309
|
#
|
280
310
|
def report_spans(spans)
|
281
|
-
|
282
|
-
|
283
|
-
unless @discovered
|
284
|
-
::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!")
|
311
|
+
if @state != :ready && !@testmode
|
312
|
+
::Instana.logger.debug "report_spans called but agent not in ready state."
|
285
313
|
return false
|
286
314
|
end
|
287
315
|
|
288
|
-
path =
|
316
|
+
path = sprintf(TRACES_PATH, @process[:report_pid])
|
289
317
|
uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
|
290
318
|
req = Net::HTTP::Post.new(uri)
|
291
319
|
|
@@ -315,20 +343,12 @@ module Instana
|
|
315
343
|
@discovered ||= run_discovery
|
316
344
|
|
317
345
|
if @discovered
|
318
|
-
|
319
|
-
uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/")
|
320
|
-
req = Net::HTTP::Get.new(uri)
|
321
|
-
|
322
|
-
response = make_host_agent_request(req)
|
323
|
-
|
324
|
-
if response && (response.code.to_i == 200)
|
325
|
-
return true
|
326
|
-
end
|
346
|
+
return true
|
327
347
|
end
|
328
348
|
false
|
329
349
|
rescue => e
|
330
350
|
Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
331
|
-
Instana.logger.debug { e.backtrace.join("\r\n") } unless
|
351
|
+
Instana.logger.debug { e.backtrace.join("\r\n") } unless @testmode
|
332
352
|
return false
|
333
353
|
end
|
334
354
|
|
@@ -390,22 +410,26 @@ module Instana
|
|
390
410
|
def transition_to(state)
|
391
411
|
::Instana.logger.debug("Transitioning to #{state}")
|
392
412
|
case state
|
413
|
+
when :ready
|
414
|
+
# announced
|
415
|
+
@state = :ready
|
416
|
+
|
417
|
+
# Reset the entity timer
|
418
|
+
@entity_last_seen = Time.now
|
393
419
|
when :announced
|
394
420
|
# announce successful; set state
|
395
421
|
@state = :announced
|
396
422
|
|
397
423
|
# Reset the entity timer
|
398
424
|
@entity_last_seen = Time.now
|
399
|
-
|
400
425
|
when :unannounced
|
401
426
|
@state = :unannounced
|
402
427
|
# Reset our HTTP client
|
403
428
|
@httpclient = nil
|
404
|
-
|
405
429
|
else
|
406
430
|
::Instana.logger.debug "Uknown agent state: #{state}"
|
407
431
|
end
|
408
|
-
::Instana.collector.
|
432
|
+
::Instana.collector.reset_snapshot_timer!
|
409
433
|
true
|
410
434
|
end
|
411
435
|
|
@@ -434,7 +458,7 @@ module Instana
|
|
434
458
|
return nil
|
435
459
|
rescue => e
|
436
460
|
Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
437
|
-
Instana.logger.debug { e.backtrace.join("\r\n") } unless
|
461
|
+
Instana.logger.debug { e.backtrace.join("\r\n") } unless @testmode
|
438
462
|
return nil
|
439
463
|
end
|
440
464
|
end
|
@@ -52,7 +52,7 @@ module AgentHelpers
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
@state == :
|
55
|
+
@state == :ready
|
56
56
|
rescue => e
|
57
57
|
Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
58
58
|
Instana.logger.debug { e.backtrace.join("\r\n") } unless ENV.key?('INSTANA_TEST')
|
data/lib/instana/collector.rb
CHANGED
@@ -21,7 +21,7 @@ module Instana
|
|
21
21
|
|
22
22
|
# Register an individual collector.
|
23
23
|
#
|
24
|
-
# @param [Object]
|
24
|
+
# @param [Object] klass of the collector to register
|
25
25
|
#
|
26
26
|
def register(klass)
|
27
27
|
::Instana.logger.debug "Adding #{klass} to collectors..."
|
@@ -30,9 +30,9 @@ module Instana
|
|
30
30
|
|
31
31
|
# Resets the timer on when to send process snapshot data.
|
32
32
|
#
|
33
|
-
def
|
33
|
+
def reset_snapshot_timer!
|
34
34
|
# Set last snapshot to 10 minutes ago
|
35
|
-
# so we send a snapshot on first report
|
35
|
+
# so that we send a snapshot on first report
|
36
36
|
@last_snapshot = Time.now - 601
|
37
37
|
end
|
38
38
|
|
data/lib/instana/config.rb
CHANGED
@@ -28,11 +28,8 @@ module Instana
|
|
28
28
|
# Enable/disable tracing (default: enabled)
|
29
29
|
@config[:tracing] = { :enabled => true }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
@config[:collector] = { :enabled => true, :interval => 1 }
|
35
|
-
end
|
31
|
+
# Collector interval
|
32
|
+
@config[:collector] = { :enabled => true, :interval => 1 }
|
36
33
|
|
37
34
|
# EUM Related
|
38
35
|
@config[:eum_api_key] = nil
|
@@ -163,7 +163,7 @@ module Instana
|
|
163
163
|
end
|
164
164
|
|
165
165
|
if defined?(::ActionController) && ::Instana.config[:action_controller][:enabled] && ::ActionPack::VERSION::MAJOR >= 2
|
166
|
-
::Instana.logger.
|
166
|
+
::Instana.logger.debug "Instrumenting ActionController"
|
167
167
|
if ActionPack::VERSION::MAJOR >= 5
|
168
168
|
::ActionController::Base.send(:prepend, ::Instana::Instrumentation::ActionController)
|
169
169
|
else
|
@@ -178,6 +178,6 @@ end
|
|
178
178
|
# We allow ActionController::API instrumentation in version of Ruby on Rails 3 and higher.
|
179
179
|
#
|
180
180
|
if defined?(::ActionController::API) && ::Instana.config[:action_controller][:enabled] && ::ActionPack::VERSION::MAJOR >= 3
|
181
|
-
::Instana.logger.
|
181
|
+
::Instana.logger.debug "Instrumenting ActionController API"
|
182
182
|
::ActionController::API.send(:prepend, ::Instana::Instrumentation::ActionController)
|
183
183
|
end
|
@@ -38,6 +38,6 @@ module Instana
|
|
38
38
|
end
|
39
39
|
|
40
40
|
if defined?(::ActionView) && ::Instana.config[:action_view][:enabled] && ::ActionPack::VERSION::STRING >= '3.1'
|
41
|
-
::Instana.logger.
|
41
|
+
::Instana.logger.debug "Instrumenting ActionView"
|
42
42
|
::ActionView::PartialRenderer.send(:include, ::Instana::Instrumentation::ActionViewRenderer)
|
43
43
|
end
|
@@ -8,20 +8,20 @@ if defined?(::ActiveRecord) && ::Instana.config[:active_record][:enabled]
|
|
8
8
|
|
9
9
|
# Mysql
|
10
10
|
if defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
|
11
|
-
::Instana.logger.
|
11
|
+
::Instana.logger.debug "Instrumenting ActiveRecord (mysql)"
|
12
12
|
ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:include, ::Instana::Instrumentation::MysqlAdapter)
|
13
13
|
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:include, ::Instana::Instrumentation::AbstractMysqlAdapter)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Mysql2
|
17
17
|
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
18
|
-
::Instana.logger.
|
18
|
+
::Instana.logger.debug "Instrumenting ActiveRecord (mysql2)"
|
19
19
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, ::Instana::Instrumentation::Mysql2Adapter)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Postgres
|
23
23
|
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
24
|
-
::Instana.logger.
|
24
|
+
::Instana.logger.debug "Instrumenting ActiveRecord (postgresql)"
|
25
25
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include, ::Instana::Instrumentation::PostgreSQLAdapter)
|
26
26
|
end
|
27
27
|
end
|
@@ -8,7 +8,7 @@ if defined?(::Rails)
|
|
8
8
|
::Instana.logger = ::Rails.logger if ::Rails.logger
|
9
9
|
|
10
10
|
if ::Instana.config[:tracing][:enabled]
|
11
|
-
::Instana.logger.
|
11
|
+
::Instana.logger.debug "Instrumenting Rack"
|
12
12
|
::Rails.configuration.middleware.insert 0, ::Instana::Rack
|
13
13
|
else
|
14
14
|
::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
|
@@ -22,7 +22,7 @@ if defined?(::Rails)
|
|
22
22
|
::Instana.logger = ::Rails.logger if ::Rails.logger
|
23
23
|
|
24
24
|
if ::Instana.config[:tracing][:enabled]
|
25
|
-
::Instana.logger.
|
25
|
+
::Instana.logger.debug "Instrumenting Rack"
|
26
26
|
app.config.middleware.insert 0, ::Instana::Rack
|
27
27
|
else
|
28
28
|
::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
|
@@ -72,7 +72,7 @@ module Instana
|
|
72
72
|
end
|
73
73
|
|
74
74
|
if defined?(::Dalli) && ::Instana.config[:dalli][:enabled]
|
75
|
-
::Instana.logger.
|
75
|
+
::Instana.logger.debug "Instrumenting Dalli"
|
76
76
|
::Dalli::Client.send(:include, ::Instana::Instrumentation::Dalli)
|
77
77
|
::Dalli::Server.send(:include, ::Instana::Instrumentation::DalliServer)
|
78
78
|
end
|
@@ -39,7 +39,7 @@ if defined?(GRPC::ActiveCall) && ::Instana.config[:grpc][:enabled]
|
|
39
39
|
alias #{call_type} #{call_type}_with_instana
|
40
40
|
RUBY
|
41
41
|
end
|
42
|
-
::Instana.logger.
|
42
|
+
::Instana.logger.debug 'Instrumenting GRPC client'
|
43
43
|
end
|
44
44
|
|
45
45
|
if defined?(GRPC::RpcDesc) && ::Instana.config[:grpc][:enabled]
|
@@ -80,5 +80,5 @@ if defined?(GRPC::RpcDesc) && ::Instana.config[:grpc][:enabled]
|
|
80
80
|
alias handle_#{call_type} handle_#{call_type}_with_instana
|
81
81
|
RUBY
|
82
82
|
end
|
83
|
-
::Instana.logger.
|
83
|
+
::Instana.logger.debug 'Instrumenting GRPC server'
|
84
84
|
end
|
@@ -58,7 +58,7 @@ if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
|
|
58
58
|
::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
|
59
59
|
end
|
60
60
|
|
61
|
-
Instana.logger.
|
61
|
+
::Instana.logger.debug "Instrumenting Net::HTTP"
|
62
62
|
|
63
63
|
alias request_without_instana request
|
64
64
|
alias request request_with_instana
|
@@ -44,7 +44,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
|
44
44
|
::Instana.tracer.log_exit(:redis, {})
|
45
45
|
end
|
46
46
|
|
47
|
-
::Instana.logger.
|
47
|
+
::Instana.logger.debug "Instrumenting Redis"
|
48
48
|
|
49
49
|
alias call_without_instana call
|
50
50
|
alias call call_with_instana
|
@@ -108,12 +108,12 @@ end
|
|
108
108
|
if defined?(::Resque) && RUBY_VERSION >= '1.9.3'
|
109
109
|
|
110
110
|
if ::Instana.config[:'resque-client'][:enabled]
|
111
|
-
::Instana.logger.
|
111
|
+
::Instana.logger.debug 'Instrumenting Resque Client'
|
112
112
|
::Instana::Util.send_include(::Resque, ::Instana::Instrumentation::ResqueClient)
|
113
113
|
end
|
114
114
|
|
115
115
|
if ::Instana.config[:'resque-worker'][:enabled]
|
116
|
-
::Instana.logger.
|
116
|
+
::Instana.logger.debug 'Instrumenting Resque Worker'
|
117
117
|
|
118
118
|
::Instana::Util.send_include(::Resque::Worker, ::Instana::Instrumentation::ResqueWorker)
|
119
119
|
::Instana::Util.send_include(::Resque::Job, ::Instana::Instrumentation::ResqueJob)
|
@@ -29,6 +29,6 @@ module Instana
|
|
29
29
|
end
|
30
30
|
|
31
31
|
if defined?(::RestClient::Request) && ::Instana.config[:'rest-client'][:enabled]
|
32
|
-
::Instana.logger.
|
32
|
+
::Instana.logger.debug "Instrumenting RestClient"
|
33
33
|
::RestClient::Request.send(:include, ::Instana::Instrumentation::RestClientRequest)
|
34
34
|
end
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
|
39
39
|
::Sidekiq.configure_client do |cfg|
|
40
40
|
cfg.client_middleware do |chain|
|
41
|
-
::Instana.logger.
|
41
|
+
::Instana.logger.debug "Instrumenting Sidekiq client"
|
42
42
|
chain.add ::Instana::Instrumentation::SidekiqClient
|
43
43
|
end
|
44
44
|
end
|
@@ -47,7 +47,7 @@ end
|
|
47
47
|
if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
|
48
48
|
::Sidekiq.configure_server do |cfg|
|
49
49
|
cfg.server_middleware do |chain|
|
50
|
-
::Instana.logger.
|
50
|
+
::Instana.logger.debug "Instrumenting Sidekiq worker"
|
51
51
|
chain.add ::Instana::Instrumentation::SidekiqWorker
|
52
52
|
end
|
53
53
|
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -22,7 +22,7 @@ module Instana
|
|
22
22
|
id = ::Instana::Util.generate_id
|
23
23
|
@data[:t] = id # Trace ID
|
24
24
|
@data[:s] = id # Span ID
|
25
|
-
is_root = true
|
25
|
+
@is_root = true
|
26
26
|
else
|
27
27
|
if parent_ctx.is_a?(::Instana::Span)
|
28
28
|
@parent = parent_ctx
|
@@ -41,7 +41,7 @@ module Instana
|
|
41
41
|
@baggage = nil
|
42
42
|
end
|
43
43
|
|
44
|
-
is_root = false
|
44
|
+
@is_root = false
|
45
45
|
end
|
46
46
|
|
47
47
|
@data[:data] = {}
|
@@ -143,9 +143,17 @@ module Instana
|
|
143
143
|
#
|
144
144
|
def configure_custom(name)
|
145
145
|
@data[:n] = :sdk
|
146
|
-
@data[:
|
147
|
-
@data[:data] = { :sdk => { :name => name.to_sym, :type => :intermediate } }
|
146
|
+
@data[:data] = { :sdk => { :name => name.to_sym } }
|
148
147
|
@data[:data][:sdk][:custom] = { :tags => {}, :logs => {} }
|
148
|
+
|
149
|
+
if @is_root
|
150
|
+
# For custom root spans (via SDK or opentracing), default to entry type
|
151
|
+
@data[:k] = 1
|
152
|
+
@data[:data][:sdk][:type] = :entry
|
153
|
+
else
|
154
|
+
@data[:k] = 3
|
155
|
+
@data[:data][:sdk][:type] = :intermediate
|
156
|
+
end
|
149
157
|
self
|
150
158
|
end
|
151
159
|
|
@@ -300,10 +308,10 @@ module Instana
|
|
300
308
|
|
301
309
|
if key.to_sym == :'span.kind'
|
302
310
|
case value.to_sym
|
303
|
-
when :server, :consumer
|
311
|
+
when :entry, :server, :consumer
|
304
312
|
@data[:data][:sdk][:type] = :entry
|
305
313
|
@data[:k] = 1
|
306
|
-
when :client, :producer
|
314
|
+
when :exit, :client, :producer
|
307
315
|
@data[:data][:sdk][:type] = :exit
|
308
316
|
@data[:k] = 2
|
309
317
|
else
|
data/lib/instana/version.rb
CHANGED
data/test/agent/agent_test.rb
CHANGED
@@ -5,6 +5,11 @@ class AgentTest < Minitest::Test
|
|
5
5
|
|
6
6
|
Oj = ::Instana::Oj unless defined?(Oj)
|
7
7
|
|
8
|
+
def teardown
|
9
|
+
WebMock.reset!
|
10
|
+
::Instana.agent.instance_variable_set(:@discovered, nil)
|
11
|
+
end
|
12
|
+
|
8
13
|
def test_agent_host_detection
|
9
14
|
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/"
|
10
15
|
stub_request(:get, url)
|
@@ -28,6 +33,7 @@ class AgentTest < Minitest::Test
|
|
28
33
|
docker_url = "http://#{::Instana.agent.instance_variable_get(:@default_gateway)}:#{::Instana.config[:agent_port]}/"
|
29
34
|
stub_request(:get, url).to_raise(Errno::ECONNREFUSED)
|
30
35
|
stub_request(:get, docker_url).to_raise(Errno::ECONNREFUSED)
|
36
|
+
|
31
37
|
discovered = ::Instana.agent.run_discovery
|
32
38
|
|
33
39
|
assert_equal nil, discovered
|
@@ -134,10 +140,9 @@ class AgentTest < Minitest::Test
|
|
134
140
|
discovery[:agent_port] = ::Instana.config[:agent_port]
|
135
141
|
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
136
142
|
|
137
|
-
localhost_url = "http://#{::Instana::Agent::LOCALHOST}:#{::Instana.config[:agent_port]}/"
|
138
|
-
stub_request(:
|
139
|
-
|
140
|
-
|
141
|
-
assert_equal false, ::Instana.agent.host_agent_available?
|
143
|
+
localhost_url = "http://#{::Instana::Agent::LOCALHOST}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
144
|
+
stub_request(:any, localhost_url).to_timeout
|
145
|
+
|
146
|
+
assert_equal false, ::Instana.agent.announce_sensor
|
142
147
|
end
|
143
148
|
end
|
@@ -30,7 +30,7 @@ class DalliTest < Minitest::Test
|
|
30
30
|
first_span = spans[1]
|
31
31
|
second_span = spans[0]
|
32
32
|
|
33
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
33
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
34
34
|
|
35
35
|
assert_equal :memcache, second_span[:n]
|
36
36
|
assert_equal false, second_span.key?(:error)
|
@@ -63,7 +63,7 @@ class DalliTest < Minitest::Test
|
|
63
63
|
first_span = spans[1]
|
64
64
|
second_span = spans[0]
|
65
65
|
|
66
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
66
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
67
67
|
|
68
68
|
assert_equal :memcache, second_span[:n]
|
69
69
|
assert_equal false, second_span.key?(:error)
|
@@ -97,7 +97,7 @@ class DalliTest < Minitest::Test
|
|
97
97
|
first_span = spans[1]
|
98
98
|
second_span = spans[0]
|
99
99
|
|
100
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
100
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
101
101
|
|
102
102
|
assert_equal :memcache, second_span[:n]
|
103
103
|
assert_equal false, second_span.key?(:error)
|
@@ -131,7 +131,7 @@ class DalliTest < Minitest::Test
|
|
131
131
|
first_span = spans[1]
|
132
132
|
second_span = spans[0]
|
133
133
|
|
134
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
134
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
135
135
|
|
136
136
|
assert_equal :memcache, second_span[:n]
|
137
137
|
assert_equal false, second_span.key?(:error)
|
@@ -165,7 +165,7 @@ class DalliTest < Minitest::Test
|
|
165
165
|
first_span = spans[1]
|
166
166
|
second_span = spans[0]
|
167
167
|
|
168
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
168
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
169
169
|
|
170
170
|
assert_equal :memcache, second_span[:n]
|
171
171
|
assert_equal false, second_span.key?(:error)
|
@@ -199,7 +199,7 @@ class DalliTest < Minitest::Test
|
|
199
199
|
first_span = spans[1]
|
200
200
|
second_span = spans[0]
|
201
201
|
|
202
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
202
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
203
203
|
|
204
204
|
assert_equal :memcache, second_span[:n]
|
205
205
|
assert_equal false, second_span.key?(:error)
|
@@ -232,7 +232,7 @@ class DalliTest < Minitest::Test
|
|
232
232
|
first_span = spans[1]
|
233
233
|
second_span = spans[0]
|
234
234
|
|
235
|
-
validate_sdk_span(first_span, {:name => :dalli_test, :type => :
|
235
|
+
validate_sdk_span(first_span, {:name => :dalli_test, :type => :entry})
|
236
236
|
|
237
237
|
assert_equal :memcache, second_span[:n]
|
238
238
|
assert_equal false, second_span.key?(:error)
|
@@ -29,7 +29,7 @@ class ExconTest < Minitest::Test
|
|
29
29
|
excon_span = find_first_span_by_name(spans, :excon)
|
30
30
|
rack_span = find_first_span_by_name(spans, :rack)
|
31
31
|
|
32
|
-
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :
|
32
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :entry})
|
33
33
|
|
34
34
|
# data keys/values
|
35
35
|
refute_nil excon_span.key?(:data)
|
@@ -72,7 +72,7 @@ class ExconTest < Minitest::Test
|
|
72
72
|
excon_span = find_first_span_by_name(spans, :excon)
|
73
73
|
sdk_span = find_first_span_by_name(spans, :'excon-test')
|
74
74
|
|
75
|
-
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :
|
75
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :entry})
|
76
76
|
|
77
77
|
assert_equal sdk_span[:s], excon_span[:p]
|
78
78
|
assert_equal excon_span[:s], rack_span[:p]
|
@@ -111,7 +111,7 @@ class ExconTest < Minitest::Test
|
|
111
111
|
excon_spans = find_spans_by_name(spans, :excon)
|
112
112
|
sdk_span = find_first_span_by_name(spans, :'excon-test')
|
113
113
|
|
114
|
-
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :
|
114
|
+
validate_sdk_span(sdk_span, {:name => :'excon-test', :type => :entry})
|
115
115
|
|
116
116
|
assert_equal 3, rack_spans.length
|
117
117
|
assert_equal 3, excon_spans.length
|
@@ -25,7 +25,7 @@ class RestClientTest < Minitest::Test
|
|
25
25
|
rest_span = find_first_span_by_name(spans, :'rest-client')
|
26
26
|
net_span = find_first_span_by_name(spans, :'net-http')
|
27
27
|
|
28
|
-
validate_sdk_span(sdk_span, {:name => :'restclient-test', :type => :
|
28
|
+
validate_sdk_span(sdk_span, {:name => :'restclient-test', :type => :entry})
|
29
29
|
validate_sdk_span(rest_span, {:name => :'rest-client', :type => :intermediate})
|
30
30
|
|
31
31
|
# Span name validation
|
@@ -72,7 +72,7 @@ class SidekiqClientTest < Minitest::Test
|
|
72
72
|
second_span = spans[0]
|
73
73
|
|
74
74
|
assert_equal first_span[:s], second_span[:p]
|
75
|
-
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :
|
75
|
+
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :entry})
|
76
76
|
|
77
77
|
assert_equal :'sidekiq-client', second_span[:n]
|
78
78
|
assert_equal 'some_random_queue', second_span[:data][:'sidekiq-client'][:queue]
|
@@ -89,7 +89,7 @@ class SidekiqClientTest < Minitest::Test
|
|
89
89
|
second_span = spans[0]
|
90
90
|
|
91
91
|
assert_equal first_span[:s], second_span[:p]
|
92
|
-
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :
|
92
|
+
validate_sdk_span(first_span, {:name => :sidekiqtests, :type => :entry})
|
93
93
|
|
94
94
|
assert_equal :'sidekiq-client', second_span[:n]
|
95
95
|
assert_equal true, second_span[:error]
|
data/test/tracing/custom_test.rb
CHANGED
@@ -31,6 +31,10 @@ class CustomTracingTest < Minitest::Test
|
|
31
31
|
assert_equal :custom_trace, first_span[:data][:sdk][:name]
|
32
32
|
assert_equal 1, first_span[:data][:sdk][:custom][:tags][:one]
|
33
33
|
|
34
|
+
# Custom tracing root spans should default to entry type
|
35
|
+
assert_equal 1, first_span[:k]
|
36
|
+
assert_equal :entry, first_span[:data][:sdk][:type]
|
37
|
+
|
34
38
|
assert first_span.key?(:f)
|
35
39
|
assert first_span[:f].key?(:e)
|
36
40
|
assert first_span[:f].key?(:h)
|
data/test/tracing/tracer_test.rb
CHANGED
@@ -105,6 +105,38 @@ class TracerTest < Minitest::Test
|
|
105
105
|
assert_equal sdk_span[:data][:sdk][:custom][:tags][:sub_two], 2
|
106
106
|
end
|
107
107
|
|
108
|
+
def test_custom_complex_trace_block
|
109
|
+
clear_all!
|
110
|
+
::Instana.tracer.start_or_continue_trace(:root_span, {:one => 1}) do
|
111
|
+
sleep 0.2
|
112
|
+
::Instana.tracer.trace(:sub_span, {:sub_two => 2}) do
|
113
|
+
sleep 0.2
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
spans = ::Instana.processor.queued_spans
|
118
|
+
assert_equal 2, spans.length
|
119
|
+
|
120
|
+
root_span = find_first_span_by_name(spans, :root_span)
|
121
|
+
sub_span = find_first_span_by_name(spans, :sub_span)
|
122
|
+
|
123
|
+
assert_equal root_span[:n], :sdk
|
124
|
+
assert_equal root_span[:data][:sdk][:name], :root_span
|
125
|
+
assert_equal root_span[:data][:sdk][:type], :entry
|
126
|
+
assert_equal root_span[:k], 1
|
127
|
+
assert_equal root_span[:p], nil
|
128
|
+
assert_equal root_span[:t], root_span[:s]
|
129
|
+
assert_equal root_span[:data][:sdk][:custom][:tags][:one], 1
|
130
|
+
|
131
|
+
assert_equal sub_span[:n], :sdk
|
132
|
+
assert_equal sub_span[:data][:sdk][:name], :sub_span
|
133
|
+
assert_equal sub_span[:data][:sdk][:type], :intermediate
|
134
|
+
assert_equal sub_span[:k], 3
|
135
|
+
assert_equal sub_span[:p], root_span[:s]
|
136
|
+
assert_equal sub_span[:t], root_span[:t]
|
137
|
+
assert_equal sub_span[:data][:sdk][:custom][:tags][:sub_two], 2
|
138
|
+
end
|
139
|
+
|
108
140
|
def test_basic_low_level_tracing
|
109
141
|
clear_all!
|
110
142
|
|
@@ -189,8 +221,8 @@ class TracerTest < Minitest::Test
|
|
189
221
|
|
190
222
|
assert_equal sdk_span[:n], :sdk
|
191
223
|
assert_equal sdk_span[:data][:sdk][:name], :test_trace
|
192
|
-
assert_equal sdk_span[:data][:sdk][:type], :
|
193
|
-
assert_equal sdk_span[:k],
|
224
|
+
assert_equal sdk_span[:data][:sdk][:type], :entry
|
225
|
+
assert_equal sdk_span[:k], 1
|
194
226
|
assert_equal sdk_span[:data][:sdk][:custom][:tags][:one], 1
|
195
227
|
assert_equal sdk_span[:error], true
|
196
228
|
assert_equal sdk_span[:ec], 1
|
@@ -211,8 +243,8 @@ class TracerTest < Minitest::Test
|
|
211
243
|
|
212
244
|
assert_equal sdk_span[:n], :sdk
|
213
245
|
assert_equal sdk_span[:data][:sdk][:name], :test_trace
|
214
|
-
assert_equal sdk_span[:data][:sdk][:type], :
|
215
|
-
assert_equal sdk_span[:k],
|
246
|
+
assert_equal sdk_span[:data][:sdk][:type], :entry
|
247
|
+
assert_equal sdk_span[:k], 1
|
216
248
|
assert_equal sdk_span[:data][:sdk][:custom][:tags][:one], 1
|
217
249
|
assert_equal sdk_span[:data][:sdk][:custom][:tags][:info_logged], 1
|
218
250
|
assert_equal sdk_span[:data][:sdk][:custom][:tags][:close_one], 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +131,7 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- ".codeclimate.yml"
|
134
|
+
- ".fasterer.yml"
|
134
135
|
- ".gitignore"
|
135
136
|
- ".rubocop.yml"
|
136
137
|
- ".travis.yml"
|
@@ -142,7 +143,9 @@ files:
|
|
142
143
|
- Rakefile
|
143
144
|
- Tracing.md
|
144
145
|
- Troubleshooting.md
|
146
|
+
- benchmarks/10k-rack-traces.rb
|
145
147
|
- benchmarks/Gemfile
|
148
|
+
- benchmarks/Gemfile.lock
|
146
149
|
- benchmarks/id_generation.rb
|
147
150
|
- benchmarks/opentracing.rb
|
148
151
|
- benchmarks/rack_vanilla_vs_traced.rb
|
@@ -156,6 +159,7 @@ files:
|
|
156
159
|
- gemfiles/rails32.gemfile
|
157
160
|
- gemfiles/rails42.gemfile
|
158
161
|
- gemfiles/rails50.gemfile
|
162
|
+
- gemfiles/rails52.gemfile
|
159
163
|
- instana.gemspec
|
160
164
|
- lib/instana.rb
|
161
165
|
- lib/instana/agent.rb
|