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
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
require "instana/frameworks/instrumentation/mysql_adapter"
|
3
|
-
require "instana/frameworks/instrumentation/abstract_mysql_adapter"
|
4
|
-
require "instana/frameworks/instrumentation/mysql2_adapter"
|
5
|
-
require "instana/frameworks/instrumentation/postgresql_adapter"
|
6
|
-
|
7
|
-
if defined?(::ActiveRecord) && ::Instana.config[:active_record][:enabled]
|
8
|
-
|
9
|
-
# Mysql
|
10
|
-
if defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
|
11
|
-
::Instana.logger.debug "Instrumenting ActiveRecord (mysql)"
|
12
|
-
ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:include, ::Instana::Instrumentation::MysqlAdapter)
|
13
|
-
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:include, ::Instana::Instrumentation::AbstractMysqlAdapter)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Mysql2
|
17
|
-
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
18
|
-
::Instana.logger.debug "Instrumenting ActiveRecord (mysql2)"
|
19
|
-
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, ::Instana::Instrumentation::Mysql2Adapter)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Postgres
|
23
|
-
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
24
|
-
::Instana.logger.debug "Instrumenting ActiveRecord (postgresql)"
|
25
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include, ::Instana::Instrumentation::PostgreSQLAdapter)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
module Instrumentation
|
3
|
-
module Mysql2Adapter
|
4
|
-
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE).freeze
|
5
|
-
EXPLAINED_SQLS = /\A\s*(with|select|update|delete|insert)\b/i
|
6
|
-
|
7
|
-
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
|
-
#
|
9
|
-
def self.included(klass)
|
10
|
-
# ActiveRecord 3.1 and up only (for now possibly)
|
11
|
-
if ActiveRecord::VERSION::STRING > '3.0'
|
12
|
-
Instana::Util.method_alias(klass, :exec_delete)
|
13
|
-
Instana::Util.method_alias(klass, :exec_insert)
|
14
|
-
Instana::Util.method_alias(klass, :exec_query)
|
15
|
-
|
16
|
-
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Collect up this DB connection info for reporting.
|
21
|
-
#
|
22
|
-
# @param sql [String]
|
23
|
-
# @return [Hash] Hash of collected KVs
|
24
|
-
#
|
25
|
-
def collect(sql)
|
26
|
-
payload = { :activerecord => {} }
|
27
|
-
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
28
|
-
payload[:activerecord][:adapter] = @config[:adapter]
|
29
|
-
payload[:activerecord][:host] = @config[:host]
|
30
|
-
payload[:activerecord][:db] = @config[:database]
|
31
|
-
payload[:activerecord][:username] = @config[:username]
|
32
|
-
payload
|
33
|
-
end
|
34
|
-
|
35
|
-
# In the spirit of ::ActiveRecord::ExplainSubscriber.ignore_payload? There are
|
36
|
-
# only certain calls that we're interested in tracing. e.g. No use to instrument
|
37
|
-
# framework caches.
|
38
|
-
#
|
39
|
-
# @param payload [String]
|
40
|
-
# @return [Boolean]
|
41
|
-
#
|
42
|
-
def ignore_payload?(name, sql)
|
43
|
-
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
44
|
-
end
|
45
|
-
|
46
|
-
def exec_delete_with_instana(sql, name = nil, binds = [])
|
47
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
48
|
-
return exec_delete_without_instana(sql, name, binds)
|
49
|
-
end
|
50
|
-
|
51
|
-
kv_payload = collect(sql)
|
52
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
53
|
-
exec_delete_without_instana(sql, name, binds)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def exec_insert_with_instana(sql, name = 'SQL', binds = [], *args)
|
58
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
59
|
-
return exec_insert_without_instana(sql, name, binds, *args)
|
60
|
-
end
|
61
|
-
|
62
|
-
kv_payload = collect(sql)
|
63
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
64
|
-
exec_insert_without_instana(sql, name, binds, *args)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def exec_query_with_instana(sql, name = 'SQL', binds = [], *args)
|
69
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
|
70
|
-
::Instana.tracer.current_span[:n] == :activerecord
|
71
|
-
return exec_query_without_instana(sql, name, binds, *args)
|
72
|
-
end
|
73
|
-
|
74
|
-
kv_payload = collect(sql)
|
75
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
76
|
-
exec_query_without_instana(sql, name, binds, *args)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
module Instrumentation
|
3
|
-
module MysqlAdapter
|
4
|
-
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE).freeze
|
5
|
-
EXPLAINED_SQLS = /\A\s*(with|select|update|delete|insert)\b/i
|
6
|
-
|
7
|
-
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
|
-
#
|
9
|
-
def self.included(klass)
|
10
|
-
if ActiveRecord::VERSION::STRING >= '3.2'
|
11
|
-
Instana::Util.method_alias(klass, :exec_query)
|
12
|
-
|
13
|
-
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Collect up this DB connection info for reporting.
|
18
|
-
#
|
19
|
-
# @param sql [String]
|
20
|
-
# @return [Hash] Hash of collected KVs
|
21
|
-
#
|
22
|
-
def collect(sql)
|
23
|
-
payload = { :activerecord => {} }
|
24
|
-
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
25
|
-
payload[:activerecord][:adapter] = @config[:adapter]
|
26
|
-
payload[:activerecord][:host] = @config[:host]
|
27
|
-
payload[:activerecord][:db] = @config[:database]
|
28
|
-
payload[:activerecord][:username] = @config[:username]
|
29
|
-
payload
|
30
|
-
end
|
31
|
-
|
32
|
-
# In the spirit of ::ActiveRecord::ExplainSubscriber.ignore_payload? There are
|
33
|
-
# only certain calls that we're interested in tracing. e.g. No use to instrument
|
34
|
-
# framework caches.
|
35
|
-
#
|
36
|
-
# @param payload [String]
|
37
|
-
# @return [Boolean]
|
38
|
-
#
|
39
|
-
def ignore_payload?(name, sql)
|
40
|
-
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
41
|
-
end
|
42
|
-
|
43
|
-
def exec_query_with_instana(sql, name = 'SQL', binds = [], *args)
|
44
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
|
45
|
-
::Instana.tracer.current_span[:n] == :activerecord
|
46
|
-
return exec_query_without_instana(sql, name, binds, *args)
|
47
|
-
end
|
48
|
-
|
49
|
-
kv_payload = collect(sql)
|
50
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
51
|
-
exec_query_without_instana(sql, name, binds, *args)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
module Instrumentation
|
3
|
-
module PostgreSQLAdapter
|
4
|
-
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE).freeze
|
5
|
-
IGNORED_SQL = %w(BEGIN COMMIT)
|
6
|
-
EXPLAINED_SQLS = /\A\s*(with|select|update|delete|insert)\b/i
|
7
|
-
|
8
|
-
# This module supports instrumenting ActiveRecord with the postgresql adapter. Only
|
9
|
-
# versions >= 3.1 are supported.
|
10
|
-
#
|
11
|
-
def self.included(klass)
|
12
|
-
if (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR > 0) ||
|
13
|
-
::ActiveRecord::VERSION::MAJOR >= 4
|
14
|
-
|
15
|
-
# ActiveRecord 3.1 and up
|
16
|
-
Instana::Util.method_alias(klass, :exec_query)
|
17
|
-
Instana::Util.method_alias(klass, :exec_delete)
|
18
|
-
Instana::Util.method_alias(klass, :execute)
|
19
|
-
|
20
|
-
|
21
|
-
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Collect up this DB connection info for reporting.
|
26
|
-
#
|
27
|
-
# @param sql [String]
|
28
|
-
# @return [Hash] Hash of collected KVs
|
29
|
-
#
|
30
|
-
def collect(sql)
|
31
|
-
payload = { :activerecord => {} }
|
32
|
-
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
33
|
-
payload[:activerecord][:adapter] = @config[:adapter]
|
34
|
-
payload[:activerecord][:host] = @config[:host]
|
35
|
-
payload[:activerecord][:db] = @config[:database]
|
36
|
-
payload[:activerecord][:username] = @config[:username]
|
37
|
-
payload
|
38
|
-
end
|
39
|
-
|
40
|
-
# In the spirit of ::ActiveRecord::ExplainSubscriber.ignore_payload? There are
|
41
|
-
# only certain calls that we're interested in tracing. e.g. No use to instrument
|
42
|
-
# framework caches.
|
43
|
-
#
|
44
|
-
# @param payload [String]
|
45
|
-
# @return [Boolean]
|
46
|
-
#
|
47
|
-
def ignore_payload?(name, sql)
|
48
|
-
IGNORED_PAYLOADS.include?(name) || IGNORED_SQL.include?(sql)
|
49
|
-
end
|
50
|
-
|
51
|
-
def exec_query_with_instana(sql, name = 'SQL', binds = [], *args)
|
52
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
53
|
-
return exec_query_without_instana(sql, name, binds, *args)
|
54
|
-
end
|
55
|
-
|
56
|
-
kv_payload = collect(sql)
|
57
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
58
|
-
exec_query_without_instana(sql, name, binds, *args)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def exec_delete_with_instana(sql, name = nil, binds = [])
|
63
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
64
|
-
return exec_delete_without_instana(sql, name, binds)
|
65
|
-
end
|
66
|
-
|
67
|
-
kv_payload = collect(sql)
|
68
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
69
|
-
exec_delete_without_instana(sql, name, binds)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def execute_with_instana(sql, name = nil)
|
74
|
-
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
75
|
-
return execute_without_instana(sql, name)
|
76
|
-
end
|
77
|
-
|
78
|
-
kv_payload = collect(sql)
|
79
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
80
|
-
execute_without_instana(sql, name)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
AUTOLOAD_DIRECTORIES = [:instrumentation, :frameworks].freeze
|
3
|
-
end
|
4
|
-
|
5
|
-
# Environment variables:
|
6
|
-
#
|
7
|
-
# INSTANA_DISABLE_AUTO_INSTR, unless set to false, will disable loading of automatic instrumentation
|
8
|
-
# INSTANA_DISABLE disables the gem entirely and therefore doesn't load automatic instrumentation
|
9
|
-
#
|
10
|
-
if (!ENV.key?('INSTANA_DISABLE_AUTO_INSTR') || ENV['INSTANA_DISABLE_AUTO_INSTR'] === 'false') && !ENV.key?('INSTANA_DISABLE')
|
11
|
-
#
|
12
|
-
# Load all of the files in the specified subdirectories
|
13
|
-
#
|
14
|
-
::Instana::AUTOLOAD_DIRECTORIES.each do |d|
|
15
|
-
pattern = File.join(File.dirname(__FILE__), d.to_s, '*.rb')
|
16
|
-
Dir.glob(pattern) do |f|
|
17
|
-
begin
|
18
|
-
require f
|
19
|
-
rescue => e
|
20
|
-
Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
21
|
-
Instana.logger.debug { e.backtrace.join("\r\n") }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/instana/test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
class Test
|
3
|
-
class << self
|
4
|
-
# Used at the start of the test suite to configure required environment
|
5
|
-
# variables (if missing)
|
6
|
-
#
|
7
|
-
def setup_environment
|
8
|
-
# Set defaults if not set
|
9
|
-
ENV['MEMCACHED_HOST'] ||= '127.0.0.1:11211'
|
10
|
-
ENV['POSTGRES_HOST'] ||= "127.0.0.1"
|
11
|
-
ENV['POSTGRES_USER'] ||= "stan"
|
12
|
-
ENV['POSTGRES_PASSWORD'] ||= "stanlikesdata"
|
13
|
-
ENV['TRAVIS_MYSQL_HOST'] ||= "127.0.0.1"
|
14
|
-
ENV['TRAVIS_MYSQL_USER'] ||= "root"
|
15
|
-
|
16
|
-
if !ENV.key?('DATABASE_URL')
|
17
|
-
if ENV['DB_FLAVOR'] == 'postgresql'
|
18
|
-
ENV['DATABASE_URL'] = "postgresql://#{ENV['POSTGRES_USER']}:#{ENV['POSTGRES_PASSWORD']}@#{ENV['POSTGRES_HOST']}:5432/#{ENV['POSTGRES_USER']}"
|
19
|
-
elsif ENV['DB_FLAVOR'] == 'mysql'
|
20
|
-
ENV['DATABASE_URL'] = "mysql://#{ENV['TRAVIS_MYSQL_USER']}:#{ENV['TRAVIS_MYSQL_PASS']}@#{ENV['TRAVIS_MYSQL_HOST']}:3306/travis_ci_test"
|
21
|
-
else
|
22
|
-
ENV['DB_FLAVOR'] ||= 'mysql2'
|
23
|
-
ENV['DATABASE_URL'] = "mysql2://#{ENV['TRAVIS_MYSQL_USER']}:#{ENV['TRAVIS_MYSQL_PASS']}@#{ENV['TRAVIS_MYSQL_HOST']}:3306/travis_ci_test"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
Instana.logger.warn "Database connect string configured to: #{ENV['DATABASE_URL']}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def postgresql?
|
31
|
-
ENV['DB_FLAVOR'] == 'postgresql'
|
32
|
-
end
|
33
|
-
|
34
|
-
def mysql2?
|
35
|
-
ENV['DB_FLAVOR'] == 'mysql2'
|
36
|
-
end
|
37
|
-
|
38
|
-
def mysql?
|
39
|
-
ENV['DB_FLAVOR'] == 'mysql'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/test/apps/cuba.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "cuba/safe"
|
2
|
-
|
3
|
-
Cuba.plugin ::Cuba::Safe
|
4
|
-
|
5
|
-
Cuba.define do
|
6
|
-
on get do
|
7
|
-
on "hello" do
|
8
|
-
res.write "Hello Instana!"
|
9
|
-
end
|
10
|
-
|
11
|
-
on "greet/:name" do |name|
|
12
|
-
res.write "Hello, #{name}"
|
13
|
-
end
|
14
|
-
|
15
|
-
on root do
|
16
|
-
res.redirect '/hello'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/apps/roda.rb
DELETED
data/test/apps/sinatra.rb
DELETED
@@ -1,210 +0,0 @@
|
|
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
|
-
first_span = spans[0]
|
18
|
-
second_span = spans[1]
|
19
|
-
third_span = spans[2]
|
20
|
-
|
21
|
-
assert_equal :rack, first_span.name
|
22
|
-
assert_equal :actioncontroller, second_span.name
|
23
|
-
assert_equal :actionview, third_span.name
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_render_nothing
|
27
|
-
clear_all!
|
28
|
-
|
29
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_nothing'))
|
30
|
-
|
31
|
-
spans = Instana.processor.queued_spans
|
32
|
-
assert_equal 3, spans.length
|
33
|
-
first_span = spans[0]
|
34
|
-
second_span = spans[1]
|
35
|
-
third_span = spans[2]
|
36
|
-
|
37
|
-
assert_equal :rack, first_span.name
|
38
|
-
assert_equal :actioncontroller, second_span.name
|
39
|
-
assert_equal "Nothing", third_span[:data][:actionview][:name]
|
40
|
-
assert_equal :actionview, third_span.name
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_render_file
|
44
|
-
clear_all!
|
45
|
-
|
46
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_file'))
|
47
|
-
|
48
|
-
spans = Instana.processor.queued_spans
|
49
|
-
assert_equal 3, spans.length
|
50
|
-
first_span = spans[0]
|
51
|
-
second_span = spans[1]
|
52
|
-
third_span = spans[2]
|
53
|
-
|
54
|
-
assert_equal :rack, first_span.name
|
55
|
-
assert_equal :actioncontroller, second_span.name
|
56
|
-
assert_equal "/etc/issue", third_span[:data][:actionview][:name]
|
57
|
-
assert_equal :actionview, third_span.name
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_render_json
|
61
|
-
clear_all!
|
62
|
-
|
63
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_json'))
|
64
|
-
|
65
|
-
spans = Instana.processor.queued_spans
|
66
|
-
assert_equal 3, spans.length
|
67
|
-
first_span = spans[0]
|
68
|
-
second_span = spans[1]
|
69
|
-
third_span = spans[2]
|
70
|
-
|
71
|
-
assert_equal :rack, first_span.name
|
72
|
-
assert_equal :actioncontroller, second_span.name
|
73
|
-
assert_equal "JSON", third_span[:data][:actionview][:name]
|
74
|
-
assert_equal :actionview, third_span.name
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_render_xml
|
78
|
-
clear_all!
|
79
|
-
|
80
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_xml'))
|
81
|
-
|
82
|
-
assert_equal 3, spans.length
|
83
|
-
first_span = spans[0]
|
84
|
-
second_span = spans[1]
|
85
|
-
third_span = spans[2]
|
86
|
-
|
87
|
-
assert_equal :rack, first_span.name
|
88
|
-
assert_equal :actioncontroller, second_span.name
|
89
|
-
assert_equal "XML", third_span[:data][:actionview][:name]
|
90
|
-
assert_equal :actionview, third_span.name
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_render_body
|
94
|
-
clear_all!
|
95
|
-
|
96
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_rawbody'))
|
97
|
-
|
98
|
-
spans = Instana.processor.queued_spans
|
99
|
-
assert_equal 3, spans.length
|
100
|
-
first_span = spans[0]
|
101
|
-
second_span = spans[1]
|
102
|
-
third_span = spans[2]
|
103
|
-
|
104
|
-
assert_equal :rack, first_span.name
|
105
|
-
assert_equal :actioncontroller, second_span.name
|
106
|
-
assert_equal "Raw", third_span[:data][:actionview][:name]
|
107
|
-
assert_equal :actionview, third_span.name
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_render_js
|
111
|
-
clear_all!
|
112
|
-
|
113
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_js'))
|
114
|
-
|
115
|
-
spans = Instana.processor.queued_spans
|
116
|
-
assert_equal 3, spans.length
|
117
|
-
first_span = spans[0]
|
118
|
-
second_span = spans[1]
|
119
|
-
third_span = spans[2]
|
120
|
-
|
121
|
-
assert_equal :rack, first_span.name
|
122
|
-
assert_equal :actioncontroller, second_span.name
|
123
|
-
assert_equal "Javascript", third_span[:data][:actionview][:name]
|
124
|
-
assert_equal :actionview, third_span.name
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_render_alternate_layout
|
128
|
-
clear_all!
|
129
|
-
|
130
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_alternate_layout'))
|
131
|
-
|
132
|
-
spans = Instana.processor.queued_spans
|
133
|
-
assert_equal 3, spans.length
|
134
|
-
first_span = spans[0]
|
135
|
-
second_span = spans[1]
|
136
|
-
third_span = spans[2]
|
137
|
-
|
138
|
-
assert_equal :rack, first_span.name
|
139
|
-
assert_equal :actioncontroller, second_span.name
|
140
|
-
assert_equal "layouts/mobile", third_span[:data][:actionview][:name]
|
141
|
-
assert_equal :actionview, third_span.name
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_render_partial
|
145
|
-
clear_all!
|
146
|
-
|
147
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial'))
|
148
|
-
|
149
|
-
spans = Instana.processor.queued_spans
|
150
|
-
assert_equal 4, spans.length
|
151
|
-
first_span = spans[0]
|
152
|
-
second_span = spans[1]
|
153
|
-
third_span = spans[2]
|
154
|
-
fourth_span = spans[3]
|
155
|
-
|
156
|
-
assert_equal :rack, first_span.name
|
157
|
-
assert_equal :actioncontroller, second_span.name
|
158
|
-
assert_equal :actionview, third_span.name
|
159
|
-
assert_equal :render, fourth_span.name
|
160
|
-
assert_equal :partial, fourth_span[:data][:render][:type]
|
161
|
-
assert_equal 'message', fourth_span[:data][:render][:name]
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_render_partial_that_errors
|
165
|
-
clear_all!
|
166
|
-
|
167
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_partial_that_errors'))
|
168
|
-
|
169
|
-
spans = Instana.processor.queued_spans
|
170
|
-
assert_equal 4, spans.length
|
171
|
-
first_span = spans[0]
|
172
|
-
second_span = spans[1]
|
173
|
-
third_span = spans[2]
|
174
|
-
fourth_span = spans[3]
|
175
|
-
|
176
|
-
assert_equal :rack, first_span.name
|
177
|
-
assert_equal :actioncontroller, second_span.name
|
178
|
-
assert_equal :actionview, third_span.name
|
179
|
-
assert_equal :render, fourth_span.name
|
180
|
-
assert_equal :partial, fourth_span[:data][:render][:type]
|
181
|
-
assert_equal 'syntax_error', fourth_span[:data][:render][:name]
|
182
|
-
assert fourth_span[:data][:log].key?(:message)
|
183
|
-
assert_equal "ActionView::Template::Error", fourth_span[:data][:log][:parameters]
|
184
|
-
assert fourth_span[:error]
|
185
|
-
assert fourth_span[:stack]
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_render_collection
|
189
|
-
clear_all!
|
190
|
-
|
191
|
-
Net::HTTP.get(URI.parse('http://localhost:3205/test/render_collection'))
|
192
|
-
|
193
|
-
spans = Instana.processor.queued_spans
|
194
|
-
assert_equal 5, spans.length
|
195
|
-
first_span = spans[0]
|
196
|
-
second_span = spans[1]
|
197
|
-
third_span = spans[2]
|
198
|
-
fourth_span = spans[3]
|
199
|
-
fifth_span = spans[4]
|
200
|
-
|
201
|
-
assert_equal :rack, first_span.name
|
202
|
-
assert_equal :actioncontroller, second_span.name
|
203
|
-
assert_equal :activerecord, third_span.name
|
204
|
-
assert_equal :actionview, fourth_span.name
|
205
|
-
|
206
|
-
assert_equal :render, fifth_span.name
|
207
|
-
assert_equal :collection, fifth_span[:data][:render][:type]
|
208
|
-
assert_equal 'blocks/block', fifth_span[:data][:render][:name]
|
209
|
-
end
|
210
|
-
end
|