instana 1.10.1-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 +7 -0
- data/.codeclimate.yml +23 -0
- data/.gitignore +16 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +43 -0
- data/Configuration.md +149 -0
- data/Dockerfile +13 -0
- data/Gemfile +41 -0
- data/LICENSE +21 -0
- data/README.md +102 -0
- data/Rakefile +56 -0
- data/Tracing.md +145 -0
- data/Troubleshooting.md +32 -0
- data/benchmarks/Gemfile +7 -0
- data/benchmarks/id_generation.rb +12 -0
- data/benchmarks/opentracing.rb +26 -0
- data/benchmarks/rack_vanilla_vs_traced.rb +80 -0
- data/benchmarks/stackprof_rack_tracing.rb +77 -0
- data/benchmarks/time_processing.rb +12 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/examples/opentracing.rb +31 -0
- data/examples/tracing.rb +80 -0
- data/gemfiles/libraries.gemfile +71 -0
- data/gemfiles/rails32.gemfile +51 -0
- data/gemfiles/rails42.gemfile +50 -0
- data/gemfiles/rails50.gemfile +52 -0
- data/instana.gemspec +46 -0
- data/lib/instana.rb +12 -0
- data/lib/instana/agent.rb +441 -0
- data/lib/instana/agent/helpers.rb +61 -0
- data/lib/instana/agent/hooks.rb +37 -0
- data/lib/instana/agent/tasks.rb +48 -0
- data/lib/instana/base.rb +54 -0
- data/lib/instana/collector.rb +116 -0
- data/lib/instana/collectors/gc.rb +57 -0
- data/lib/instana/collectors/memory.rb +34 -0
- data/lib/instana/collectors/thread.rb +30 -0
- data/lib/instana/config.rb +79 -0
- data/lib/instana/eum/eum-test.js.erb +16 -0
- data/lib/instana/eum/eum.js.erb +14 -0
- data/lib/instana/frameworks/cuba.rb +6 -0
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +58 -0
- data/lib/instana/frameworks/instrumentation/action_controller.rb +183 -0
- data/lib/instana/frameworks/instrumentation/action_view.rb +43 -0
- data/lib/instana/frameworks/instrumentation/active_record.rb +27 -0
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +81 -0
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +56 -0
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +71 -0
- data/lib/instana/frameworks/rails.rb +42 -0
- data/lib/instana/frameworks/roda.rb +6 -0
- data/lib/instana/frameworks/sinatra.rb +9 -0
- data/lib/instana/helpers.rb +40 -0
- data/lib/instana/instrumentation.rb +21 -0
- data/lib/instana/instrumentation/dalli.rb +78 -0
- data/lib/instana/instrumentation/excon.rb +74 -0
- data/lib/instana/instrumentation/grpc.rb +84 -0
- data/lib/instana/instrumentation/net-http.rb +66 -0
- data/lib/instana/instrumentation/rack.rb +77 -0
- data/lib/instana/instrumentation/redis.rb +82 -0
- data/lib/instana/instrumentation/resque.rb +131 -0
- data/lib/instana/instrumentation/rest-client.rb +34 -0
- data/lib/instana/instrumentation/sidekiq-client.rb +45 -0
- data/lib/instana/instrumentation/sidekiq-worker.rb +54 -0
- data/lib/instana/opentracing/carrier.rb +4 -0
- data/lib/instana/opentracing/tracer.rb +18 -0
- data/lib/instana/rack.rb +10 -0
- data/lib/instana/setup.rb +36 -0
- data/lib/instana/test.rb +40 -0
- data/lib/instana/thread_local.rb +15 -0
- data/lib/instana/tracer.rb +392 -0
- data/lib/instana/tracing/processor.rb +92 -0
- data/lib/instana/tracing/span.rb +401 -0
- data/lib/instana/tracing/span_context.rb +33 -0
- data/lib/instana/util.rb +261 -0
- data/lib/instana/version.rb +4 -0
- data/lib/oj_check.rb +16 -0
- data/lib/opentracing.rb +6 -0
- data/test/agent/agent_test.rb +143 -0
- data/test/apps/cuba.rb +15 -0
- data/test/apps/grpc_server.rb +81 -0
- data/test/apps/roda.rb +10 -0
- data/test/apps/sinatra.rb +5 -0
- data/test/benchmarks/bench_id_generation.rb +12 -0
- data/test/benchmarks/bench_opentracing.rb +13 -0
- data/test/config_test.rb +37 -0
- data/test/frameworks/cuba_test.rb +44 -0
- data/test/frameworks/rack_test.rb +167 -0
- data/test/frameworks/rails/actioncontroller_test.rb +93 -0
- data/test/frameworks/rails/actionview3_test.rb +255 -0
- data/test/frameworks/rails/actionview4_test.rb +254 -0
- data/test/frameworks/rails/actionview5_test.rb +221 -0
- data/test/frameworks/rails/activerecord3_test.rb +134 -0
- data/test/frameworks/rails/activerecord4_test.rb +134 -0
- data/test/frameworks/rails/activerecord5_test.rb +87 -0
- data/test/frameworks/roda_test.rb +44 -0
- data/test/frameworks/sinatra_test.rb +44 -0
- data/test/instana_test.rb +27 -0
- data/test/instrumentation/dalli_test.rb +253 -0
- data/test/instrumentation/excon_test.rb +147 -0
- data/test/instrumentation/grpc_test.rb +377 -0
- data/test/instrumentation/net-http_test.rb +160 -0
- data/test/instrumentation/redis_test.rb +119 -0
- data/test/instrumentation/resque_test.rb +128 -0
- data/test/instrumentation/rest-client_test.rb +55 -0
- data/test/instrumentation/sidekiq-client_test.rb +125 -0
- data/test/instrumentation/sidekiq-worker_test.rb +173 -0
- data/test/jobs/resque_error_job.rb +22 -0
- data/test/jobs/resque_fast_job.rb +20 -0
- data/test/jobs/sidekiq_job_1.rb +6 -0
- data/test/jobs/sidekiq_job_2.rb +7 -0
- data/test/models/block.rb +18 -0
- data/test/servers/grpc_50051.rb +20 -0
- data/test/servers/helpers/sidekiq_worker_initializer.rb +27 -0
- data/test/servers/rackapp_6511.rb +25 -0
- data/test/servers/rails_3205.rb +167 -0
- data/test/servers/sidekiq/worker.rb +27 -0
- data/test/test_helper.rb +145 -0
- data/test/tracing/custom_test.rb +158 -0
- data/test/tracing/id_management_test.rb +130 -0
- data/test/tracing/opentracing_test.rb +335 -0
- data/test/tracing/trace_test.rb +67 -0
- data/test/tracing/tracer_async_test.rb +198 -0
- data/test/tracing/tracer_test.rb +223 -0
- metadata +327 -0
|
@@ -0,0 +1,221 @@
|
|
|
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
|
+
spans = ::Instana.processor.queued_spans
|
|
16
|
+
assert_equal 3, spans.length
|
|
17
|
+
|
|
18
|
+
first_span = spans[2]
|
|
19
|
+
second_span = spans[1]
|
|
20
|
+
third_span = spans[0]
|
|
21
|
+
|
|
22
|
+
assert_equal :rack, first_span[:n]
|
|
23
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
24
|
+
assert_equal :actionview, third_span[:n]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_render_nothing
|
|
28
|
+
clear_all!
|
|
29
|
+
|
|
30
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_nothing'))
|
|
31
|
+
|
|
32
|
+
spans = ::Instana.processor.queued_spans
|
|
33
|
+
assert_equal 3, spans.length
|
|
34
|
+
|
|
35
|
+
first_span = spans[2]
|
|
36
|
+
second_span = spans[1]
|
|
37
|
+
third_span = spans[0]
|
|
38
|
+
|
|
39
|
+
assert_equal :rack, first_span[:n]
|
|
40
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
41
|
+
assert_equal "Nothing", third_span[:data][:actionview][:name]
|
|
42
|
+
assert_equal :actionview, third_span[:n]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_render_file
|
|
46
|
+
clear_all!
|
|
47
|
+
|
|
48
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_file'))
|
|
49
|
+
|
|
50
|
+
spans = ::Instana.processor.queued_spans
|
|
51
|
+
assert_equal 3, spans.length
|
|
52
|
+
|
|
53
|
+
first_span = spans[2]
|
|
54
|
+
second_span = spans[1]
|
|
55
|
+
third_span = spans[0]
|
|
56
|
+
|
|
57
|
+
assert_equal :rack, first_span[:n]
|
|
58
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
59
|
+
assert_equal "/etc/issue", third_span[:data][:actionview][:name]
|
|
60
|
+
assert_equal :actionview, third_span[:n]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_render_json
|
|
64
|
+
clear_all!
|
|
65
|
+
|
|
66
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_json'))
|
|
67
|
+
|
|
68
|
+
spans = ::Instana.processor.queued_spans
|
|
69
|
+
assert_equal 3, spans.length
|
|
70
|
+
|
|
71
|
+
first_span = spans[2]
|
|
72
|
+
second_span = spans[1]
|
|
73
|
+
third_span = spans[0]
|
|
74
|
+
|
|
75
|
+
assert_equal :rack, first_span[:n]
|
|
76
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
77
|
+
assert_equal "JSON", third_span[:data][:actionview][:name]
|
|
78
|
+
assert_equal :actionview, third_span[:n]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_render_xml
|
|
82
|
+
clear_all!
|
|
83
|
+
|
|
84
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_xml'))
|
|
85
|
+
|
|
86
|
+
spans = ::Instana.processor.queued_spans
|
|
87
|
+
assert_equal 3, spans.length
|
|
88
|
+
|
|
89
|
+
first_span = spans[2]
|
|
90
|
+
second_span = spans[1]
|
|
91
|
+
third_span = spans[0]
|
|
92
|
+
|
|
93
|
+
assert_equal :rack, first_span[:n]
|
|
94
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
95
|
+
assert_equal "XML", third_span[:data][:actionview][:name]
|
|
96
|
+
assert_equal :actionview, third_span[:n]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_render_body
|
|
100
|
+
clear_all!
|
|
101
|
+
|
|
102
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_rawbody'))
|
|
103
|
+
|
|
104
|
+
spans = ::Instana.processor.queued_spans
|
|
105
|
+
assert_equal 3, spans.length
|
|
106
|
+
|
|
107
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
|
108
|
+
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
|
109
|
+
av_span = find_first_span_by_name(spans, :actionview)
|
|
110
|
+
|
|
111
|
+
assert_equal :actioncontroller, ac_span[:n]
|
|
112
|
+
assert_equal "Raw", av_span[:data][:actionview][:name]
|
|
113
|
+
assert_equal :actionview, av_span[:n]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_render_js
|
|
117
|
+
clear_all!
|
|
118
|
+
|
|
119
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_js'))
|
|
120
|
+
|
|
121
|
+
spans = ::Instana.processor.queued_spans
|
|
122
|
+
assert_equal 3, spans.length
|
|
123
|
+
|
|
124
|
+
first_span = spans[2]
|
|
125
|
+
second_span = spans[1]
|
|
126
|
+
third_span = spans[0]
|
|
127
|
+
|
|
128
|
+
assert_equal :rack, first_span[:n]
|
|
129
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
130
|
+
assert_equal "Javascript", third_span[:data][:actionview][:name]
|
|
131
|
+
assert_equal :actionview, third_span[:n]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_render_alternate_layout
|
|
135
|
+
clear_all!
|
|
136
|
+
|
|
137
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_alternate_layout'))
|
|
138
|
+
|
|
139
|
+
spans = ::Instana.processor.queued_spans
|
|
140
|
+
assert_equal 3, spans.length
|
|
141
|
+
|
|
142
|
+
first_span = spans[2]
|
|
143
|
+
second_span = spans[1]
|
|
144
|
+
third_span = spans[0]
|
|
145
|
+
|
|
146
|
+
assert_equal :rack, first_span[:n]
|
|
147
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
148
|
+
assert_equal "layouts/mobile", third_span[:data][:actionview][:name]
|
|
149
|
+
assert_equal :actionview, third_span[:n]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_render_partial
|
|
153
|
+
clear_all!
|
|
154
|
+
|
|
155
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial'))
|
|
156
|
+
|
|
157
|
+
spans = ::Instana.processor.queued_spans
|
|
158
|
+
assert_equal 4, spans.length
|
|
159
|
+
|
|
160
|
+
first_span = spans[3]
|
|
161
|
+
second_span = spans[2]
|
|
162
|
+
third_span = spans[1]
|
|
163
|
+
fourth_span = spans[0]
|
|
164
|
+
|
|
165
|
+
assert_equal :rack, first_span[:n]
|
|
166
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
167
|
+
assert_equal :actionview, third_span[:n]
|
|
168
|
+
assert_equal :render, fourth_span[:n]
|
|
169
|
+
assert_equal :partial, fourth_span[:data][:render][:type]
|
|
170
|
+
assert_equal 'message', fourth_span[:data][:render][:name]
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_render_partial_that_errors
|
|
174
|
+
clear_all!
|
|
175
|
+
|
|
176
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial_that_errors'))
|
|
177
|
+
|
|
178
|
+
spans = ::Instana.processor.queued_spans
|
|
179
|
+
assert_equal 4, spans.length
|
|
180
|
+
|
|
181
|
+
first_span = spans[3]
|
|
182
|
+
second_span = spans[2]
|
|
183
|
+
third_span = spans[1]
|
|
184
|
+
fourth_span = spans[0]
|
|
185
|
+
|
|
186
|
+
assert_equal :rack, first_span[:n]
|
|
187
|
+
assert_equal :actioncontroller, second_span[:n]
|
|
188
|
+
assert_equal :actionview, third_span[:n]
|
|
189
|
+
assert_equal :render, fourth_span[:n]
|
|
190
|
+
assert_equal :partial, fourth_span[:data][:render][:type]
|
|
191
|
+
assert_equal 'syntax_error', fourth_span[:data][:render][:name]
|
|
192
|
+
assert fourth_span[:data][:log].key?(:message)
|
|
193
|
+
assert_equal "SyntaxError", fourth_span[:data][:log][:parameters]
|
|
194
|
+
assert fourth_span[:error]
|
|
195
|
+
assert fourth_span[:stack]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def test_render_collection
|
|
199
|
+
clear_all!
|
|
200
|
+
|
|
201
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_collection'))
|
|
202
|
+
|
|
203
|
+
spans = ::Instana.processor.queued_spans
|
|
204
|
+
assert_equal 5, spans.length
|
|
205
|
+
|
|
206
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
|
207
|
+
ac_span = find_first_span_by_name(spans, :actioncontroller)
|
|
208
|
+
ar_span = find_first_span_by_name(spans, :activerecord)
|
|
209
|
+
av_span = find_first_span_by_name(spans, :actionview)
|
|
210
|
+
render_span = find_first_span_by_name(spans, :render)
|
|
211
|
+
|
|
212
|
+
assert_equal render_span[:p], av_span[:s]
|
|
213
|
+
assert_equal av_span[:p], ac_span[:s]
|
|
214
|
+
assert_equal ar_span[:p], av_span[:s]
|
|
215
|
+
assert_equal ac_span[:p], rack_span[:s]
|
|
216
|
+
|
|
217
|
+
assert_equal :render, render_span[:n]
|
|
218
|
+
assert_equal :collection, render_span[:data][:render][:type]
|
|
219
|
+
assert_equal 'blocks/block', render_span[:data][:render][:name]
|
|
220
|
+
end
|
|
221
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'active_record'
|
|
3
|
+
|
|
4
|
+
class ActiveRecordTest < Minitest::Test
|
|
5
|
+
def test_config_defaults
|
|
6
|
+
assert ::Instana.config[:active_record].is_a?(Hash)
|
|
7
|
+
assert ::Instana.config[:active_record].key?(:enabled)
|
|
8
|
+
assert_equal true, ::Instana.config[:active_record][:enabled]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_postgresql
|
|
12
|
+
# Make one call to warm up the Rails stack and allow it to load
|
|
13
|
+
# relations
|
|
14
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
15
|
+
|
|
16
|
+
skip unless ::Instana::Test.postgresql?
|
|
17
|
+
|
|
18
|
+
clear_all!
|
|
19
|
+
|
|
20
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
21
|
+
|
|
22
|
+
traces = Instana.processor.queued_traces
|
|
23
|
+
assert_equal 1, traces.length
|
|
24
|
+
trace = traces.first
|
|
25
|
+
|
|
26
|
+
assert_equal 6, trace.spans.length
|
|
27
|
+
spans = trace.spans.to_a
|
|
28
|
+
first_span = spans[0]
|
|
29
|
+
second_span = spans[2]
|
|
30
|
+
third_span = spans[3]
|
|
31
|
+
fourth_span = spans[4]
|
|
32
|
+
|
|
33
|
+
assert_equal :rack, first_span.name
|
|
34
|
+
assert_equal :activerecord, second_span.name
|
|
35
|
+
assert_equal :activerecord, third_span.name
|
|
36
|
+
assert_equal :activerecord, fourth_span.name
|
|
37
|
+
|
|
38
|
+
assert_equal "INSERT INTO \"blocks\" (\"color\", \"created_at\", \"name\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\"", second_span[:data][:activerecord][:sql]
|
|
39
|
+
assert_equal "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = ? LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
40
|
+
assert_equal "DELETE FROM \"blocks\" WHERE \"blocks\".\"id\" = ?", fourth_span[:data][:activerecord][:sql]
|
|
41
|
+
|
|
42
|
+
assert_equal "postgresql", second_span[:data][:activerecord][:adapter]
|
|
43
|
+
assert_equal "postgresql", third_span[:data][:activerecord][:adapter]
|
|
44
|
+
assert_equal "postgresql", fourth_span[:data][:activerecord][:adapter]
|
|
45
|
+
|
|
46
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
47
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
48
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
49
|
+
|
|
50
|
+
assert_equal "postgres", second_span[:data][:activerecord][:username]
|
|
51
|
+
assert_equal "postgres", third_span[:data][:activerecord][:username]
|
|
52
|
+
assert_equal "postgres", fourth_span[:data][:activerecord][:username]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_mysql2
|
|
56
|
+
skip unless ::Instana::Test.mysql2?
|
|
57
|
+
|
|
58
|
+
clear_all!
|
|
59
|
+
|
|
60
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
61
|
+
|
|
62
|
+
traces = Instana.processor.queued_traces
|
|
63
|
+
assert_equal 1, traces.length
|
|
64
|
+
trace = traces.first
|
|
65
|
+
|
|
66
|
+
assert_equal 6, trace.spans.length
|
|
67
|
+
spans = trace.spans.to_a
|
|
68
|
+
first_span = spans[0]
|
|
69
|
+
second_span = spans[2]
|
|
70
|
+
third_span = spans[3]
|
|
71
|
+
fourth_span = spans[4]
|
|
72
|
+
|
|
73
|
+
assert_equal :rack, first_span.name
|
|
74
|
+
assert_equal :activerecord, second_span.name
|
|
75
|
+
assert_equal :activerecord, third_span.name
|
|
76
|
+
assert_equal :activerecord, fourth_span.name
|
|
77
|
+
|
|
78
|
+
assert_equal "INSERT INTO `blocks` (`color`, `created_at`, `name`, `updated_at`) VALUES (?, ?, ?, ?)", second_span[:data][:activerecord][:sql]
|
|
79
|
+
assert_equal "SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`name` = ? LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
80
|
+
assert_equal "DELETE FROM `blocks` WHERE `blocks`.`id` = ?", fourth_span[:data][:activerecord][:sql]
|
|
81
|
+
|
|
82
|
+
assert_equal "mysql2", second_span[:data][:activerecord][:adapter]
|
|
83
|
+
assert_equal "mysql2", third_span[:data][:activerecord][:adapter]
|
|
84
|
+
assert_equal "mysql2", fourth_span[:data][:activerecord][:adapter]
|
|
85
|
+
|
|
86
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
87
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
88
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
89
|
+
|
|
90
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], second_span[:data][:activerecord][:username]
|
|
91
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], third_span[:data][:activerecord][:username]
|
|
92
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], fourth_span[:data][:activerecord][:username]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_mysql
|
|
96
|
+
skip unless ::Instana::Test.mysql?
|
|
97
|
+
|
|
98
|
+
clear_all!
|
|
99
|
+
|
|
100
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
101
|
+
|
|
102
|
+
traces = Instana.processor.queued_traces
|
|
103
|
+
assert_equal 1, traces.length
|
|
104
|
+
trace = traces.first
|
|
105
|
+
|
|
106
|
+
assert_equal 6, trace.spans.length
|
|
107
|
+
spans = trace.spans.to_a
|
|
108
|
+
first_span = spans[0]
|
|
109
|
+
second_span = spans[2]
|
|
110
|
+
third_span = spans[3]
|
|
111
|
+
fourth_span = spans[4]
|
|
112
|
+
|
|
113
|
+
assert_equal :rack, first_span.name
|
|
114
|
+
assert_equal :activerecord, second_span.name
|
|
115
|
+
assert_equal :activerecord, third_span.name
|
|
116
|
+
assert_equal :activerecord, fourth_span.name
|
|
117
|
+
|
|
118
|
+
assert_equal "INSERT INTO `blocks` (`color`, `created_at`, `name`, `updated_at`) VALUES (?, ?, ?, ?)", second_span[:data][:activerecord][:sql]
|
|
119
|
+
assert_equal "SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`name` = ? LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
120
|
+
assert_equal "DELETE FROM `blocks` WHERE `blocks`.`id` = ?", fourth_span[:data][:activerecord][:sql]
|
|
121
|
+
|
|
122
|
+
assert_equal "mysql", second_span[:data][:activerecord][:adapter]
|
|
123
|
+
assert_equal "mysql", third_span[:data][:activerecord][:adapter]
|
|
124
|
+
assert_equal "mysql", fourth_span[:data][:activerecord][:adapter]
|
|
125
|
+
|
|
126
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
127
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
128
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
129
|
+
|
|
130
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], second_span[:data][:activerecord][:username]
|
|
131
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], third_span[:data][:activerecord][:username]
|
|
132
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], fourth_span[:data][:activerecord][:username]
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'active_record'
|
|
3
|
+
|
|
4
|
+
class ActiveRecordPgTest < Minitest::Test
|
|
5
|
+
def test_config_defaults
|
|
6
|
+
assert ::Instana.config[:active_record].is_a?(Hash)
|
|
7
|
+
assert ::Instana.config[:active_record].key?(:enabled)
|
|
8
|
+
assert_equal true, ::Instana.config[:active_record][:enabled]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_postgresql
|
|
12
|
+
# Make one call to warm up the Rails stack and allow it to load
|
|
13
|
+
# relations
|
|
14
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
15
|
+
|
|
16
|
+
skip unless ::Instana::Test.postgresql?
|
|
17
|
+
|
|
18
|
+
clear_all!
|
|
19
|
+
|
|
20
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
21
|
+
|
|
22
|
+
traces = Instana.processor.queued_traces
|
|
23
|
+
assert_equal 1, traces.length
|
|
24
|
+
trace = traces.first
|
|
25
|
+
|
|
26
|
+
assert_equal 6, trace.spans.length
|
|
27
|
+
spans = trace.spans.to_a
|
|
28
|
+
first_span = spans[0]
|
|
29
|
+
second_span = spans[2]
|
|
30
|
+
third_span = spans[3]
|
|
31
|
+
fourth_span = spans[4]
|
|
32
|
+
|
|
33
|
+
assert_equal :rack, first_span.name
|
|
34
|
+
assert_equal :activerecord, second_span.name
|
|
35
|
+
assert_equal :activerecord, third_span.name
|
|
36
|
+
assert_equal :activerecord, fourth_span.name
|
|
37
|
+
|
|
38
|
+
assert_equal "INSERT INTO \"blocks\" (\"name\", \"color\", \"created_at\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\"", second_span[:data][:activerecord][:sql]
|
|
39
|
+
assert_equal "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = $? ORDER BY \"blocks\".\"id\" ASC LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
40
|
+
assert_equal "DELETE FROM \"blocks\" WHERE \"blocks\".\"id\" = $?", fourth_span[:data][:activerecord][:sql]
|
|
41
|
+
|
|
42
|
+
assert_equal "postgresql", second_span[:data][:activerecord][:adapter]
|
|
43
|
+
assert_equal "postgresql", third_span[:data][:activerecord][:adapter]
|
|
44
|
+
assert_equal "postgresql", fourth_span[:data][:activerecord][:adapter]
|
|
45
|
+
|
|
46
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
47
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
48
|
+
assert_equal ENV['TRAVIS_PSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
49
|
+
|
|
50
|
+
assert_equal "postgres", second_span[:data][:activerecord][:username]
|
|
51
|
+
assert_equal "postgres", third_span[:data][:activerecord][:username]
|
|
52
|
+
assert_equal "postgres", fourth_span[:data][:activerecord][:username]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_mysql2
|
|
56
|
+
skip unless ::Instana::Test.mysql2?
|
|
57
|
+
|
|
58
|
+
clear_all!
|
|
59
|
+
|
|
60
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
61
|
+
|
|
62
|
+
traces = Instana.processor.queued_traces
|
|
63
|
+
assert_equal 1, traces.length
|
|
64
|
+
trace = traces.first
|
|
65
|
+
|
|
66
|
+
assert_equal 6, trace.spans.length
|
|
67
|
+
spans = trace.spans.to_a
|
|
68
|
+
first_span = spans[0]
|
|
69
|
+
second_span = spans[2]
|
|
70
|
+
third_span = spans[3]
|
|
71
|
+
fourth_span = spans[4]
|
|
72
|
+
|
|
73
|
+
assert_equal :rack, first_span.name
|
|
74
|
+
assert_equal :activerecord, second_span.name
|
|
75
|
+
assert_equal :activerecord, third_span.name
|
|
76
|
+
assert_equal :activerecord, fourth_span.name
|
|
77
|
+
|
|
78
|
+
assert_equal "INSERT INTO `blocks` (`name`, `color`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)", second_span[:data][:activerecord][:sql]
|
|
79
|
+
assert_equal "SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`name` = ? ORDER BY `blocks`.`id` ASC LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
80
|
+
assert_equal "DELETE FROM `blocks` WHERE `blocks`.`id` = ?", fourth_span[:data][:activerecord][:sql]
|
|
81
|
+
|
|
82
|
+
assert_equal "mysql2", second_span[:data][:activerecord][:adapter]
|
|
83
|
+
assert_equal "mysql2", third_span[:data][:activerecord][:adapter]
|
|
84
|
+
assert_equal "mysql2", fourth_span[:data][:activerecord][:adapter]
|
|
85
|
+
|
|
86
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
87
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
88
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
89
|
+
|
|
90
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], second_span[:data][:activerecord][:username]
|
|
91
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], third_span[:data][:activerecord][:username]
|
|
92
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], fourth_span[:data][:activerecord][:username]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_mysql
|
|
96
|
+
skip unless ::Instana::Test.mysql?
|
|
97
|
+
|
|
98
|
+
clear_all!
|
|
99
|
+
|
|
100
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
|
101
|
+
|
|
102
|
+
traces = Instana.processor.queued_traces
|
|
103
|
+
assert_equal 1, traces.length
|
|
104
|
+
trace = traces.first
|
|
105
|
+
|
|
106
|
+
assert_equal 6, trace.spans.length
|
|
107
|
+
spans = trace.spans.to_a
|
|
108
|
+
first_span = spans[0]
|
|
109
|
+
second_span = spans[2]
|
|
110
|
+
third_span = spans[3]
|
|
111
|
+
fourth_span = spans[4]
|
|
112
|
+
|
|
113
|
+
assert_equal :rack, first_span.name
|
|
114
|
+
assert_equal :activerecord, second_span.name
|
|
115
|
+
assert_equal :activerecord, third_span.name
|
|
116
|
+
assert_equal :activerecord, fourth_span.name
|
|
117
|
+
|
|
118
|
+
assert_equal "INSERT INTO `blocks` (`name`, `color`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)", second_span[:data][:activerecord][:sql]
|
|
119
|
+
assert_equal "SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`name` = ? ORDER BY `blocks`.`id` ASC LIMIT ?", third_span[:data][:activerecord][:sql]
|
|
120
|
+
assert_equal "DELETE FROM `blocks` WHERE `blocks`.`id` = ?", fourth_span[:data][:activerecord][:sql]
|
|
121
|
+
|
|
122
|
+
assert_equal "mysql", second_span[:data][:activerecord][:adapter]
|
|
123
|
+
assert_equal "mysql", third_span[:data][:activerecord][:adapter]
|
|
124
|
+
assert_equal "mysql", fourth_span[:data][:activerecord][:adapter]
|
|
125
|
+
|
|
126
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], second_span[:data][:activerecord][:host]
|
|
127
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], third_span[:data][:activerecord][:host]
|
|
128
|
+
assert_equal ENV['TRAVIS_MYSQL_HOST'], fourth_span[:data][:activerecord][:host]
|
|
129
|
+
|
|
130
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], second_span[:data][:activerecord][:username]
|
|
131
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], third_span[:data][:activerecord][:username]
|
|
132
|
+
assert_equal ENV['TRAVIS_MYSQL_USER'], fourth_span[:data][:activerecord][:username]
|
|
133
|
+
end
|
|
134
|
+
end
|