instana 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/instana/agent.rb +17 -8
- data/lib/instana/config.rb +1 -0
- data/lib/instana/frameworks/instrumentation/action_controller.rb +14 -0
- data/lib/instana/frameworks/instrumentation/action_view.rb +43 -0
- data/lib/instana/frameworks/rails.rb +1 -0
- data/lib/instana/tracing/span.rb +1 -1
- data/lib/instana/version.rb +1 -1
- data/test/frameworks/rails/actioncontroller_test.rb +5 -1
- data/test/frameworks/rails/actionview_test.rb +81 -0
- data/test/frameworks/rails/activerecord3_test.rb +3 -3
- data/test/frameworks/rails/activerecord4_test.rb +3 -3
- data/test/servers/rails_3205.rb +25 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b29ece207c8410bea84eb595c1f70e0f019502f
|
4
|
+
data.tar.gz: 527d974dadaa17372a87f7fafabd28de2a4601c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6a8d6780ac0d0ac0cea4d56e1e794e99a1a740475bd7dd6f1537c3595409a0fea824663b693a71f3192885693a05dec5d1ac507c63c6c54841ed8f40e4e541
|
7
|
+
data.tar.gz: 6df29e6b77dc0dfd303965acf1d6eec9282f3fef83c91360acfa78a68247609b00b3a34b9b788b238a8c5fee965e34f01f56dafce1a2c37b40ec56382a756d42
|
data/lib/instana/agent.rb
CHANGED
@@ -23,6 +23,9 @@ module Instana
|
|
23
23
|
# entity data reporting.
|
24
24
|
@entity_last_seen = Time.now
|
25
25
|
|
26
|
+
# Used to track the last time the collect timer was run.
|
27
|
+
@last_collect_run = Time.now
|
28
|
+
|
26
29
|
# Two timers, one for each state (unannounced & announced)
|
27
30
|
@timers = ::Timers::Group.new
|
28
31
|
@announce_timer = nil
|
@@ -109,16 +112,22 @@ module Instana
|
|
109
112
|
# If we are in announced state, send metric data (only delta reporting)
|
110
113
|
# every ::Instana.config[:collector][:interval] seconds.
|
111
114
|
@collect_timer = @timers.every(::Instana.config[:collector][:interval]) do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
# Make sure that this block doesn't get called more often than the interval. This can
|
116
|
+
# happen on high CPU load and a back up of timer runs. If we are called before `interval`
|
117
|
+
# then we just skip.
|
118
|
+
unless (Time.now - @last_collect_run) < ::Instana.config[:collector][:interval]
|
119
|
+
@last_collect_run = Time.now
|
120
|
+
if @state == :announced
|
121
|
+
if !::Instana.collector.collect_and_report
|
122
|
+
# If report has been failing for more than 1 minute,
|
123
|
+
# fall back to unannounced state
|
124
|
+
if (Time.now - @entity_last_seen) > 60
|
125
|
+
::Instana.logger.warn "Host agent offline for >1 min. Going to sit in a corner..."
|
126
|
+
transition_to(:unannounced)
|
127
|
+
end
|
119
128
|
end
|
129
|
+
::Instana.processor.send
|
120
130
|
end
|
121
|
-
::Instana.processor.send
|
122
131
|
end
|
123
132
|
end
|
124
133
|
end
|
data/lib/instana/config.rb
CHANGED
@@ -22,6 +22,7 @@ module Instana
|
|
22
22
|
|
23
23
|
# Instrumentation
|
24
24
|
@config[:action_controller] = { :enabled => true }
|
25
|
+
@config[:action_view] = { :enabled => true }
|
25
26
|
@config[:active_record] = { :enabled => true }
|
26
27
|
@config[:dalli] = { :enabled => true }
|
27
28
|
@config[:excon] = { :enabled => true }
|
@@ -60,6 +60,7 @@ module Instana
|
|
60
60
|
def self.included(klass)
|
61
61
|
klass.class_eval do
|
62
62
|
alias_method_chain :process_action, :instana
|
63
|
+
alias_method_chain :render, :instana
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
@@ -80,6 +81,19 @@ module Instana
|
|
80
81
|
ensure
|
81
82
|
::Instana.tracer.log_exit(:actioncontroller)
|
82
83
|
end
|
84
|
+
|
85
|
+
# The Instana wrapper method for ActionController::Base.render
|
86
|
+
# for versions 3 and 4.
|
87
|
+
#
|
88
|
+
def render_with_instana(*args, &blk)
|
89
|
+
::Instana.tracer.log_entry(:actionview)
|
90
|
+
render_without_instana(*args, &blk)
|
91
|
+
rescue Exception => e
|
92
|
+
::Instana.tracer.log_error(e) unless has_rails_handler?
|
93
|
+
raise
|
94
|
+
ensure
|
95
|
+
::Instana.tracer.log_exit(:actionview)
|
96
|
+
end
|
83
97
|
end
|
84
98
|
end
|
85
99
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Instana
|
2
|
+
module Instrumentation
|
3
|
+
module ActionViewRenderer
|
4
|
+
def self.included(klass)
|
5
|
+
::Instana::Util.method_alias(klass, :render_partial)
|
6
|
+
::Instana::Util.method_alias(klass, :render_collection)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_partial_with_instana
|
10
|
+
kv_payload = { :render => {} }
|
11
|
+
kv_payload[:render][:type] = :partial
|
12
|
+
kv_payload[:render][:name] = @options[:partial].to_s if @options.is_a?(Hash)
|
13
|
+
|
14
|
+
::Instana.tracer.log_entry(:render, kv_payload)
|
15
|
+
render_partial_without_instana
|
16
|
+
rescue Exception => e
|
17
|
+
::Instana.tracer.log_error(e) unless has_rails_handler?
|
18
|
+
raise
|
19
|
+
ensure
|
20
|
+
::Instana.tracer.log_exit(:render)
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_collection_with_instana
|
24
|
+
kv_payload = { :render => {} }
|
25
|
+
kv_payload[:render][:type] = :collection
|
26
|
+
kv_payload[:render][:name] = @path.to_s
|
27
|
+
|
28
|
+
::Instana.tracer.log_entry(:render, kv_payload)
|
29
|
+
render_collection_without_instana
|
30
|
+
rescue Exception => e
|
31
|
+
::Instana.tracer.log_error(e) unless has_rails_handler?
|
32
|
+
raise
|
33
|
+
ensure
|
34
|
+
::Instana.tracer.log_exit(:render)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if defined?(::ActionView) && ::Instana.config[:action_view][:enabled] && ::ActionPack::VERSION::STRING >= '3.1'
|
41
|
+
::Instana.logger.warn "Instrumenting ActionView"
|
42
|
+
::ActionView::PartialRenderer.send(:include, ::Instana::Instrumentation::ActionViewRenderer)
|
43
|
+
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Instana
|
2
2
|
class Span
|
3
|
-
REGISTERED_SPANS = [ :actioncontroller, :activerecord, :excon, :memcache, :'net-http', :rack ].freeze
|
3
|
+
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon, :memcache, :'net-http', :rack, :render ].freeze
|
4
4
|
ENTRY_SPANS = [ :rack ].freeze
|
5
5
|
EXIT_SPANS = [ :'net-http', :excon, :activerecord ].freeze
|
6
6
|
HTTP_SPANS = ENTRY_SPANS + EXIT_SPANS
|
data/lib/instana/version.rb
CHANGED
@@ -16,7 +16,11 @@ class ActionControllerTest < Minitest::Test
|
|
16
16
|
assert_equal 1, traces.count
|
17
17
|
trace = traces.first
|
18
18
|
|
19
|
-
|
19
|
+
if ::Rails::VERSION::MAJOR > 4
|
20
|
+
assert_equal 2, trace.spans.count
|
21
|
+
else
|
22
|
+
assert_equal 3, trace.spans.count
|
23
|
+
end
|
20
24
|
spans = trace.spans.to_a
|
21
25
|
first_span = spans[0]
|
22
26
|
second_span = spans[1]
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActionViewTest < Minitest::Test
|
4
|
+
def test_config_defaults
|
5
|
+
assert ::Instana.config[:action_view].is_a?(Hash)
|
6
|
+
assert ::Instana.config[:action_view].key?(:enabled)
|
7
|
+
assert_equal true, ::Instana.config[:action_view][:enabled]
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_render_view
|
11
|
+
clear_all!
|
12
|
+
|
13
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_view'))
|
14
|
+
|
15
|
+
traces = Instana.processor.queued_traces
|
16
|
+
assert_equal 1, traces.count
|
17
|
+
trace = traces.first
|
18
|
+
|
19
|
+
assert_equal 3, trace.spans.count
|
20
|
+
spans = trace.spans.to_a
|
21
|
+
first_span = spans[0]
|
22
|
+
second_span = spans[1]
|
23
|
+
third_span = spans[2]
|
24
|
+
|
25
|
+
assert_equal :rack, first_span.name
|
26
|
+
assert_equal :actioncontroller, second_span.name
|
27
|
+
assert_equal :actionview, third_span.name
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_render_partial
|
31
|
+
clear_all!
|
32
|
+
|
33
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial'))
|
34
|
+
|
35
|
+
traces = Instana.processor.queued_traces
|
36
|
+
assert_equal 1, traces.count
|
37
|
+
trace = traces.first
|
38
|
+
|
39
|
+
assert_equal 4, trace.spans.count
|
40
|
+
spans = trace.spans.to_a
|
41
|
+
first_span = spans[0]
|
42
|
+
second_span = spans[1]
|
43
|
+
third_span = spans[2]
|
44
|
+
fourth_span = spans[3]
|
45
|
+
|
46
|
+
assert_equal :rack, first_span.name
|
47
|
+
assert_equal :actioncontroller, second_span.name
|
48
|
+
assert_equal :actionview, third_span.name
|
49
|
+
assert_equal :render, fourth_span.name
|
50
|
+
assert_equal :partial, fourth_span[:data][:render][:type]
|
51
|
+
assert_equal 'message', fourth_span[:data][:render][:name]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_render_collection
|
55
|
+
clear_all!
|
56
|
+
|
57
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_collection'))
|
58
|
+
|
59
|
+
traces = Instana.processor.queued_traces
|
60
|
+
assert_equal 1, traces.count
|
61
|
+
trace = traces.first
|
62
|
+
|
63
|
+
assert_equal 5, trace.spans.count
|
64
|
+
spans = trace.spans.to_a
|
65
|
+
first_span = spans[0]
|
66
|
+
second_span = spans[1]
|
67
|
+
third_span = spans[2]
|
68
|
+
fourth_span = spans[3]
|
69
|
+
fifth_span = spans[4]
|
70
|
+
|
71
|
+
assert_equal :rack, first_span.name
|
72
|
+
assert_equal :actioncontroller, second_span.name
|
73
|
+
assert_equal :activerecord, third_span.name
|
74
|
+
assert_equal :actionview, fourth_span.name
|
75
|
+
|
76
|
+
assert_equal :render, fifth_span.name
|
77
|
+
assert_equal :collection, fifth_span[:data][:render][:type]
|
78
|
+
assert_equal 'blocks/block', fifth_span[:data][:render][:name]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -23,7 +23,7 @@ class ActiveRecordTest < Minitest::Test
|
|
23
23
|
assert_equal 1, traces.count
|
24
24
|
trace = traces.first
|
25
25
|
|
26
|
-
assert_equal
|
26
|
+
assert_equal 6, trace.spans.count
|
27
27
|
spans = trace.spans.to_a
|
28
28
|
first_span = spans[0]
|
29
29
|
second_span = spans[2]
|
@@ -63,7 +63,7 @@ class ActiveRecordTest < Minitest::Test
|
|
63
63
|
assert_equal 1, traces.count
|
64
64
|
trace = traces.first
|
65
65
|
|
66
|
-
assert_equal
|
66
|
+
assert_equal 6, trace.spans.count
|
67
67
|
spans = trace.spans.to_a
|
68
68
|
first_span = spans[0]
|
69
69
|
second_span = spans[2]
|
@@ -103,7 +103,7 @@ class ActiveRecordTest < Minitest::Test
|
|
103
103
|
assert_equal 1, traces.count
|
104
104
|
trace = traces.first
|
105
105
|
|
106
|
-
assert_equal
|
106
|
+
assert_equal 6, trace.spans.count
|
107
107
|
spans = trace.spans.to_a
|
108
108
|
first_span = spans[0]
|
109
109
|
second_span = spans[2]
|
@@ -23,7 +23,7 @@ class ActiveRecordPgTest < Minitest::Test
|
|
23
23
|
assert_equal 1, traces.count
|
24
24
|
trace = traces.first
|
25
25
|
|
26
|
-
assert_equal
|
26
|
+
assert_equal 6, trace.spans.count
|
27
27
|
spans = trace.spans.to_a
|
28
28
|
first_span = spans[0]
|
29
29
|
second_span = spans[2]
|
@@ -63,7 +63,7 @@ class ActiveRecordPgTest < Minitest::Test
|
|
63
63
|
assert_equal 1, traces.count
|
64
64
|
trace = traces.first
|
65
65
|
|
66
|
-
assert_equal
|
66
|
+
assert_equal 6, trace.spans.count
|
67
67
|
spans = trace.spans.to_a
|
68
68
|
first_span = spans[0]
|
69
69
|
second_span = spans[2]
|
@@ -103,7 +103,7 @@ class ActiveRecordPgTest < Minitest::Test
|
|
103
103
|
assert_equal 1, traces.count
|
104
104
|
trace = traces.first
|
105
105
|
|
106
|
-
assert_equal
|
106
|
+
assert_equal 6, trace.spans.count
|
107
107
|
spans = trace.spans.to_a
|
108
108
|
first_span = spans[0]
|
109
109
|
second_span = spans[2]
|
data/test/servers/rails_3205.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
|
-
::Instana.logger.warn "Starting background Ruby on Rails application on port 3205"
|
2
|
+
::Instana.logger.warn "Starting background Ruby on Rails #{Rails::VERSION::STRING} application on port 3205"
|
3
|
+
|
4
|
+
if Rails::VERSION::STRING >= '5.0' && ::Instana::Test.mysql?
|
5
|
+
::Instana.logger.fatal "Rails 5.x doesn't support the mysql adapter (discontinued). Set DB_FLAVOR=msyql2 instead. This will fail as is."
|
6
|
+
end
|
3
7
|
|
4
8
|
require "rails/all"
|
5
9
|
require "action_controller/railtie" # require more if needed
|
@@ -18,9 +22,12 @@ end
|
|
18
22
|
|
19
23
|
class RailsTestApp < Rails::Application
|
20
24
|
routes.append do
|
21
|
-
get "/test/world"
|
22
|
-
get "/test/db"
|
23
|
-
get "/test/error"
|
25
|
+
get "/test/world" => "test#world"
|
26
|
+
get "/test/db" => "test#db"
|
27
|
+
get "/test/error" => "test#error"
|
28
|
+
get "/test/render_view" => "test#render_view"
|
29
|
+
get "/test/render_partial" => "test#render_partial"
|
30
|
+
get "/test/render_collection" => "test#render_collection"
|
24
31
|
|
25
32
|
get "/api/world" => "socket#world"
|
26
33
|
get "/api/error" => "socket#error"
|
@@ -33,6 +40,8 @@ class RailsTestApp < Rails::Application
|
|
33
40
|
# uncomment below to display errors
|
34
41
|
# config.consider_all_requests_local = true
|
35
42
|
|
43
|
+
config.paths['app/views'].unshift(File.expand_path(File.dirname(__FILE__) + '/../views'))
|
44
|
+
|
36
45
|
config.active_support.deprecation = :stderr
|
37
46
|
|
38
47
|
config.middleware.delete Rack::Lock
|
@@ -65,6 +74,18 @@ class TestController < ActionController::Base
|
|
65
74
|
end
|
66
75
|
end
|
67
76
|
|
77
|
+
def render_view
|
78
|
+
@message = "Hello Instana!"
|
79
|
+
end
|
80
|
+
|
81
|
+
def render_partial
|
82
|
+
@message = "Hello Instana!"
|
83
|
+
end
|
84
|
+
|
85
|
+
def render_collection
|
86
|
+
@blocks = Block.all
|
87
|
+
end
|
88
|
+
|
68
89
|
def error
|
69
90
|
raise Exception.new("Warning: This is a simulated Error")
|
70
91
|
end
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/instana/frameworks/cuba.rb
|
189
189
|
- lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb
|
190
190
|
- lib/instana/frameworks/instrumentation/action_controller.rb
|
191
|
+
- lib/instana/frameworks/instrumentation/action_view.rb
|
191
192
|
- lib/instana/frameworks/instrumentation/active_record.rb
|
192
193
|
- lib/instana/frameworks/instrumentation/mysql2_adapter.rb
|
193
194
|
- lib/instana/frameworks/instrumentation/mysql_adapter.rb
|
@@ -226,6 +227,7 @@ files:
|
|
226
227
|
- test/frameworks/cuba_test.rb
|
227
228
|
- test/frameworks/rack_test.rb
|
228
229
|
- test/frameworks/rails/actioncontroller_test.rb
|
230
|
+
- test/frameworks/rails/actionview_test.rb
|
229
231
|
- test/frameworks/rails/activerecord3_test.rb
|
230
232
|
- test/frameworks/rails/activerecord4_test.rb
|
231
233
|
- test/frameworks/rails/activerecord5_test.rb
|
@@ -278,6 +280,7 @@ test_files:
|
|
278
280
|
- test/frameworks/cuba_test.rb
|
279
281
|
- test/frameworks/rack_test.rb
|
280
282
|
- test/frameworks/rails/actioncontroller_test.rb
|
283
|
+
- test/frameworks/rails/actionview_test.rb
|
281
284
|
- test/frameworks/rails/activerecord3_test.rb
|
282
285
|
- test/frameworks/rails/activerecord4_test.rb
|
283
286
|
- test/frameworks/rails/activerecord5_test.rb
|