solarwinds_apm 5.1.9 → 6.0.0.preV2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +28 -55
- data/ext/oboe_metal/extconf.rb +37 -41
- data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/init_solarwinds_apm.cc +0 -6
- data/ext/oboe_metal/src/oboe_debug.h +1 -0
- data/lib/oboe_metal.rb +116 -80
- data/lib/rails/generators/solarwinds_apm/install_generator.rb +1 -5
- data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +42 -267
- data/lib/solarwinds_apm/api/current_trace_info.rb +148 -0
- data/lib/solarwinds_apm/api/tracing.rb +30 -0
- data/lib/solarwinds_apm/api/transaction_name.rb +58 -0
- data/lib/solarwinds_apm/api.rb +8 -15
- data/lib/solarwinds_apm/base.rb +4 -131
- data/lib/solarwinds_apm/config.rb +101 -174
- data/lib/solarwinds_apm/constants.rb +32 -0
- data/lib/solarwinds_apm/logger.rb +1 -1
- data/lib/solarwinds_apm/noop/context.rb +2 -5
- data/lib/solarwinds_apm/noop/metadata.rb +1 -2
- data/lib/solarwinds_apm/oboe_init_options.rb +74 -38
- data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +204 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +166 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +92 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +72 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +335 -0
- data/lib/solarwinds_apm/opentelemetry.rb +8 -0
- data/lib/solarwinds_apm/otel_config.rb +161 -0
- data/lib/solarwinds_apm/{inst → support}/logger_formatter.rb +5 -6
- data/lib/solarwinds_apm/{inst → support}/logging_log_event.rb +3 -6
- data/lib/solarwinds_apm/{inst → support}/lumberjack_formatter.rb +1 -4
- data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +27 -0
- data/lib/solarwinds_apm/support/swomarginalia/LICENSE +20 -0
- data/lib/solarwinds_apm/support/swomarginalia/README.md +41 -0
- data/lib/solarwinds_apm/support/swomarginalia/comment.rb +205 -0
- data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +48 -0
- data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +22 -0
- data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +86 -0
- data/lib/solarwinds_apm/support/transaction_cache.rb +24 -0
- data/lib/solarwinds_apm/support/transaction_settings.rb +26 -209
- data/lib/solarwinds_apm/support/transformer.rb +56 -0
- data/lib/solarwinds_apm/support/txn_name_manager.rb +25 -0
- data/lib/solarwinds_apm/support/x_trace_options.rb +42 -26
- data/lib/solarwinds_apm/support.rb +37 -10
- data/lib/solarwinds_apm/support_report.rb +10 -32
- data/lib/solarwinds_apm/thread_local.rb +1 -1
- data/lib/solarwinds_apm/version.rb +4 -4
- data/lib/solarwinds_apm.rb +29 -25
- metadata +63 -123
- data/.dockerignore +0 -5
- data/.gitignore +0 -58
- data/.rubocop.yml +0 -29
- data/.whitesource +0 -22
- data/.yardopts +0 -7
- data/CHANGELOG-appoptics.md +0 -766
- data/CHANGELOG.md +0 -82
- data/CONFIG.md +0 -31
- data/Gemfile +0 -15
- data/README.md +0 -385
- data/bin/solarwinds_apm_config +0 -15
- data/examples/prepend.rb +0 -13
- data/examples/sdk_examples.rb +0 -158
- data/ext/oboe_metal/README.md +0 -69
- data/ext/oboe_metal/extconf_local.rb +0 -75
- data/ext/oboe_metal/lib/.keep +0 -0
- data/ext/oboe_metal/noop/noop.c +0 -8
- data/ext/oboe_metal/src/README.md +0 -6
- data/ext/oboe_metal/src/frames.cc +0 -247
- data/ext/oboe_metal/src/frames.h +0 -40
- data/ext/oboe_metal/src/logging.cc +0 -97
- data/ext/oboe_metal/src/logging.h +0 -34
- data/ext/oboe_metal/src/profiling.cc +0 -435
- data/ext/oboe_metal/src/profiling.h +0 -78
- data/ext/oboe_metal/test/CMakeLists.txt +0 -53
- data/ext/oboe_metal/test/FindGMock.cmake +0 -43
- data/ext/oboe_metal/test/README.md +0 -56
- data/ext/oboe_metal/test/frames_test.cc +0 -164
- data/ext/oboe_metal/test/profiling_test.cc +0 -93
- data/ext/oboe_metal/test/ruby_inc_dir.rb +0 -8
- data/ext/oboe_metal/test/ruby_prefix.rb +0 -8
- data/ext/oboe_metal/test/ruby_test_helper.rb +0 -67
- data/ext/oboe_metal/test/test.h +0 -11
- data/ext/oboe_metal/test/test_main.cc +0 -32
- data/init.rb +0 -4
- data/lib/solarwinds_apm/api/layerinit.rb +0 -41
- data/lib/solarwinds_apm/api/logging.rb +0 -356
- data/lib/solarwinds_apm/api/memcache.rb +0 -37
- data/lib/solarwinds_apm/api/metrics.rb +0 -63
- data/lib/solarwinds_apm/api/util.rb +0 -98
- data/lib/solarwinds_apm/frameworks/grape.rb +0 -96
- data/lib/solarwinds_apm/frameworks/padrino.rb +0 -78
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +0 -100
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +0 -50
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +0 -50
- data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +0 -88
- data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +0 -26
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +0 -29
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +0 -22
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +0 -103
- data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +0 -14
- data/lib/solarwinds_apm/frameworks/rails.rb +0 -100
- data/lib/solarwinds_apm/frameworks/sinatra.rb +0 -96
- data/lib/solarwinds_apm/inst/bunny-client.rb +0 -157
- data/lib/solarwinds_apm/inst/bunny-consumer.rb +0 -102
- data/lib/solarwinds_apm/inst/curb.rb +0 -289
- data/lib/solarwinds_apm/inst/dalli.rb +0 -89
- data/lib/solarwinds_apm/inst/delayed_job.rb +0 -100
- data/lib/solarwinds_apm/inst/excon.rb +0 -113
- data/lib/solarwinds_apm/inst/faraday.rb +0 -96
- data/lib/solarwinds_apm/inst/graphql.rb +0 -206
- data/lib/solarwinds_apm/inst/grpc_client.rb +0 -147
- data/lib/solarwinds_apm/inst/grpc_server.rb +0 -119
- data/lib/solarwinds_apm/inst/httpclient.rb +0 -182
- data/lib/solarwinds_apm/inst/memcached.rb +0 -86
- data/lib/solarwinds_apm/inst/mongo.rb +0 -246
- data/lib/solarwinds_apm/inst/mongo2.rb +0 -225
- data/lib/solarwinds_apm/inst/moped.rb +0 -466
- data/lib/solarwinds_apm/inst/net_http.rb +0 -60
- data/lib/solarwinds_apm/inst/rack.rb +0 -223
- data/lib/solarwinds_apm/inst/rack_cache.rb +0 -35
- data/lib/solarwinds_apm/inst/redis.rb +0 -280
- data/lib/solarwinds_apm/inst/redis_v4.rb +0 -273
- data/lib/solarwinds_apm/inst/resque.rb +0 -129
- data/lib/solarwinds_apm/inst/rest-client.rb +0 -43
- data/lib/solarwinds_apm/inst/sequel.rb +0 -241
- data/lib/solarwinds_apm/inst/sidekiq-client.rb +0 -63
- data/lib/solarwinds_apm/inst/sidekiq-worker.rb +0 -64
- data/lib/solarwinds_apm/inst/typhoeus.rb +0 -90
- data/lib/solarwinds_apm/instrumentation.rb +0 -22
- data/lib/solarwinds_apm/loading.rb +0 -65
- data/lib/solarwinds_apm/noop/profiling.rb +0 -21
- data/lib/solarwinds_apm/ruby.rb +0 -35
- data/lib/solarwinds_apm/sdk/current_trace_info.rb +0 -123
- data/lib/solarwinds_apm/sdk/custom_metrics.rb +0 -94
- data/lib/solarwinds_apm/sdk/logging.rb +0 -37
- data/lib/solarwinds_apm/sdk/trace_context_headers.rb +0 -69
- data/lib/solarwinds_apm/sdk/tracing.rb +0 -432
- data/lib/solarwinds_apm/support/profiling.rb +0 -25
- data/lib/solarwinds_apm/support/trace_context.rb +0 -53
- data/lib/solarwinds_apm/support/trace_state.rb +0 -69
- data/lib/solarwinds_apm/support/trace_string.rb +0 -89
- data/lib/solarwinds_apm/support/transaction_metrics.rb +0 -67
- data/lib/solarwinds_apm/test.rb +0 -165
- data/lib/solarwinds_apm/util.rb +0 -426
- data/log/.keep +0 -0
- data/log/postgresql/.keep +0 -0
- data/solarwinds_apm.gemspec +0 -55
- data/yardoc_frontpage.md +0 -24
@@ -1,67 +0,0 @@
|
|
1
|
-
# Copyright (c) 2018 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
module SolarWindsAPM
|
5
|
-
##
|
6
|
-
# This module sends the duration of the call and
|
7
|
-
# sets the transaction_name
|
8
|
-
#
|
9
|
-
class TransactionMetrics
|
10
|
-
class << self
|
11
|
-
|
12
|
-
##
|
13
|
-
# sends the duration of the call and
|
14
|
-
# sets the transaction_name
|
15
|
-
def metrics(env, settings)
|
16
|
-
if settings.do_metrics
|
17
|
-
req = ::Rack::Request.new(env)
|
18
|
-
# TODO rails 3x is not supported anymore ...
|
19
|
-
url = req.url # saving it here because rails3.2 overrides it when there is a 500 error
|
20
|
-
start = Time.now
|
21
|
-
|
22
|
-
begin
|
23
|
-
status, headers, response = yield
|
24
|
-
|
25
|
-
SolarWindsAPM.transaction_name = send_metrics(env, req, url, start, status)
|
26
|
-
rescue
|
27
|
-
SolarWindsAPM.transaction_name = send_metrics(env, req, url, start, status || '500')
|
28
|
-
raise
|
29
|
-
end
|
30
|
-
else
|
31
|
-
status, headers, response = yield
|
32
|
-
SolarWindsAPM.transaction_name = "#{domain(req)}#{transaction_name(env)}" if settings.do_sample
|
33
|
-
end
|
34
|
-
|
35
|
-
[status, headers, response]
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def send_metrics(env, req, url, start, status)
|
41
|
-
name = transaction_name(env)
|
42
|
-
|
43
|
-
status = status.to_i
|
44
|
-
error = status.between?(500,599) ? 1 : 0
|
45
|
-
duration =(1000 * 1000 * (Time.now - start)).round(0)
|
46
|
-
method = req.request_method
|
47
|
-
# SolarWindsAPM.logger.warn "%%% Sending metrics: #{name}, #{url}, #{status} %%%"
|
48
|
-
SolarWindsAPM::Span.createHttpSpan(name, url, domain(req), duration, status, method, error) || ''
|
49
|
-
end
|
50
|
-
|
51
|
-
def domain(req)
|
52
|
-
if SolarWindsAPM::Config['transaction_name']['prepend_domain']
|
53
|
-
[80, 443].include?(req.port) ? req.host : "#{req.host}:#{req.port}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def transaction_name(env)
|
58
|
-
return SolarWindsAPM.transaction_name if SolarWindsAPM.transaction_name
|
59
|
-
|
60
|
-
if env['solarwinds_apm.controller'] && env['solarwinds_apm.action']
|
61
|
-
[env['solarwinds_apm.controller'], env['solarwinds_apm.action']].join('.')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/lib/solarwinds_apm/test.rb
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
module SolarWindsAPM
|
5
|
-
module Test
|
6
|
-
class << self
|
7
|
-
##
|
8
|
-
# load_extras
|
9
|
-
#
|
10
|
-
# This method simply loads all the extras needed to run
|
11
|
-
# tests such as models, jobs etc...
|
12
|
-
#
|
13
|
-
def load_extras
|
14
|
-
# If we're using the libraries gemfile (with sidekiq and resque)
|
15
|
-
if SolarWindsAPM::Test.gemfile?(:libraries)
|
16
|
-
# Load all of the test workers
|
17
|
-
pattern = File.join(File.dirname(__FILE__), '../../test/jobs/**/', '*.rb')
|
18
|
-
Dir.glob(pattern) do |f|
|
19
|
-
SolarWindsAPM.logger.debug "[solarwinds_apm/test] Loading test job file: #{File.basename(f)}"
|
20
|
-
require f
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# gemfile?
|
27
|
-
#
|
28
|
-
# Method used to determine under which gemfile we're running.
|
29
|
-
# Pass <tt>name</tt> as the gemfile name only (without the
|
30
|
-
# .gemfile extension)
|
31
|
-
#
|
32
|
-
# returns true or fase depending on result
|
33
|
-
#
|
34
|
-
def gemfile?(name)
|
35
|
-
File.basename(ENV['BUNDLE_GEMFILE']) == (name.to_s + '.gemfile')
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# gemfile
|
40
|
-
#
|
41
|
-
# Used to determine under which gemfile we are running. This
|
42
|
-
# method will return the name of the active gemfile
|
43
|
-
#
|
44
|
-
def gemfile
|
45
|
-
File.basename(ENV['BUNDLE_GEMFILE']).split('.').first
|
46
|
-
end
|
47
|
-
|
48
|
-
##
|
49
|
-
# set_postgresql_env
|
50
|
-
#
|
51
|
-
# Used to set the postgresql specific DATABASE_URL env based
|
52
|
-
# on various conditions
|
53
|
-
def set_postgresql_env
|
54
|
-
if ENV.key?('TRAVIS_PSQL_PASS')
|
55
|
-
ENV['DATABASE_URL'] = "postgresql://postgres:#{ENV['TRAVIS_PSQL_PASS']}@127.0.0.1:5432/test_db"
|
56
|
-
elsif ENV.key?('POSTGRES_USER')
|
57
|
-
port = ENV.key?('POSTGRES_PORT') ? ENV['POSTGRES_PORT'] : 5432
|
58
|
-
ENV['DATABASE_URL'] = "postgresql://#{ENV['POSTGRES_PASSWORD']}:#{ENV['POSTGRES_USER']}@#{ENV['POSTGRES_HOST']}:#{port}/test_db"
|
59
|
-
else
|
60
|
-
ENV['DATABASE_URL'] = 'postgresql://postgres@127.0.0.1:5432/test_db'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
##
|
65
|
-
# To configure Rails to enable or disable prepared statements
|
66
|
-
# we need to do it using the database.yml file
|
67
|
-
# there is no method exposed (afaik) to set prepared_statements
|
68
|
-
# interactively
|
69
|
-
def set_postgresql_rails_config
|
70
|
-
# need to use string keys otherwise the output is not readable by Rails 5
|
71
|
-
config = {
|
72
|
-
'adapter' => "postgresql",
|
73
|
-
'username' => ENV.key?('POSTGRES_USER') ? ENV['POSTGRES_USER'] : "postgres",
|
74
|
-
'password' => ENV.key?('POSTGRES_PASSWORD') ? ENV['POSTGRES_PASSWORD'] : "postgres",
|
75
|
-
'database' => "test_db",
|
76
|
-
'host' => ENV.key?('POSTGRES_HOST') ? ENV['POSTGRES_HOST'] : '127.0.0.1',
|
77
|
-
'port' => ENV.key?('POSTGRES_PORT') ? ENV['POSTGRES_PORT'] : 5432,
|
78
|
-
'statement_limit' => 5
|
79
|
-
}
|
80
|
-
|
81
|
-
if ENV.key?('TEST_PREPARED_STATEMENT')
|
82
|
-
config['prepared_statements'] = ENV['TEST_PREPARED_STATEMENT'] == 'true' ? true : false
|
83
|
-
else
|
84
|
-
config['prepared_statements'] = false
|
85
|
-
end
|
86
|
-
|
87
|
-
env_config = {
|
88
|
-
'default' => config,
|
89
|
-
'development' => config,
|
90
|
-
'test' => config
|
91
|
-
}
|
92
|
-
|
93
|
-
FileUtils.mkdir_p('config')
|
94
|
-
File.open("config/database.yml","w") do |file|
|
95
|
-
file.write env_config.to_yaml
|
96
|
-
end
|
97
|
-
config
|
98
|
-
end
|
99
|
-
##
|
100
|
-
# set_mysql_env
|
101
|
-
#
|
102
|
-
# Used to set the mysql specific DATABASE_URL env based
|
103
|
-
# on various conditions
|
104
|
-
def set_mysql_env
|
105
|
-
if ENV.key?('TRAVIS_MYSQL_PASS')
|
106
|
-
ENV['DATABASE_URL'] = "mysql://root:#{ENV['TRAVIS_MYSQL_PASS']}@127.0.0.1:3306/test_db"
|
107
|
-
elsif ENV.key?('DOCKER_MYSQL_PASS')
|
108
|
-
port = ENV.key?('MYSQL_PORT') ? ENV['MYSQL_PORT'] : 3306
|
109
|
-
ENV['DATABASE_URL'] = "mysql://root:#{ENV['DOCKER_MYSQL_PASS']}@#{ENV['MYSQL_HOST']}:#{port}/test_db"
|
110
|
-
else
|
111
|
-
ENV['DATABASE_URL'] = 'mysql://root@127.0.0.1:3306/test_db'
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
##
|
116
|
-
# set_mysql2_env
|
117
|
-
#
|
118
|
-
# Used to set the mysql specific DATABASE_URL env based
|
119
|
-
# on various conditions
|
120
|
-
def set_mysql2_env
|
121
|
-
if ENV.key?('TRAVIS_MYSQL_PASS')
|
122
|
-
ENV['DATABASE_URL'] = "mysql2://root:#{ENV['TRAVIS_MYSQL_PASS']}@127.0.0.1:3306/test_db"
|
123
|
-
elsif ENV.key?('DOCKER_MYSQL_PASS')
|
124
|
-
ENV['DATABASE_URL'] = "mysql2://root:#{ENV['DOCKER_MYSQL_PASS']}@#{ENV['MYSQL_HOST']}:3306/test_db"
|
125
|
-
else
|
126
|
-
ENV['DATABASE_URL'] = 'mysql2://root@127.0.0.1:3306/test_db'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
##
|
131
|
-
# To configure Rails to enable or disable prepared statements
|
132
|
-
# we need to do it using the database.yml file
|
133
|
-
# there is no method exposed (afaik) to set prepared_statements
|
134
|
-
# interactively
|
135
|
-
def set_mysql2_rails_config
|
136
|
-
config = {
|
137
|
-
'adapter' => "mysql2",
|
138
|
-
'username' => "root",
|
139
|
-
'database' => "test_db",
|
140
|
-
'port' => 3306
|
141
|
-
}
|
142
|
-
|
143
|
-
config[:password] = ENV['DOCKER_MYSQL_PASS'] if ENV.key?('DOCKER_MYSQL_PASS')
|
144
|
-
config[:host] = ENV.key?('MYSQL_HOST') ? ENV['MYSQL_HOST'] : '127.0.0.1'
|
145
|
-
|
146
|
-
if ENV.key?('TEST_PREPARED_STATEMENT')
|
147
|
-
config['prepared_statements'] = ENV['TEST_PREPARED_STATEMENT'] == 'true' ? true : false
|
148
|
-
else
|
149
|
-
config['prepared_statements'] = false
|
150
|
-
end
|
151
|
-
|
152
|
-
env_config = {
|
153
|
-
'default' => config,
|
154
|
-
'test' => config
|
155
|
-
}
|
156
|
-
|
157
|
-
FileUtils.mkdir_p('config')
|
158
|
-
File.open("config/database.yml","w") do |file|
|
159
|
-
file.write env_config.to_yaml
|
160
|
-
end
|
161
|
-
config
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
data/lib/solarwinds_apm/util.rb
DELETED
@@ -1,426 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
module SolarWindsAPM
|
5
|
-
##
|
6
|
-
# Provides utility methods for use while in the business
|
7
|
-
# of instrumenting code
|
8
|
-
module Util
|
9
|
-
class << self
|
10
|
-
def contextual_name(cls)
|
11
|
-
# Attempt to infer a contextual name if not indicated
|
12
|
-
#
|
13
|
-
# For example:
|
14
|
-
# ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.to_s.split(/::/).last
|
15
|
-
# => "AbstractMysqlAdapter"
|
16
|
-
#
|
17
|
-
cls.to_s.split(/::/).last
|
18
|
-
rescue
|
19
|
-
cls
|
20
|
-
end
|
21
|
-
|
22
|
-
##
|
23
|
-
# method_alias
|
24
|
-
#
|
25
|
-
# Centralized utility method to alias a method on an arbitrary
|
26
|
-
# class or module.
|
27
|
-
#
|
28
|
-
def method_alias(cls, method, name = nil)
|
29
|
-
name ||= contextual_name(cls)
|
30
|
-
|
31
|
-
if cls.method_defined?(method.to_sym) || cls.private_method_defined?(method.to_sym)
|
32
|
-
|
33
|
-
# Strip '!' or '?' from method if present
|
34
|
-
safe_method_name = method.to_s.chop if method.to_s =~ /\?$|\!$/
|
35
|
-
safe_method_name ||= method
|
36
|
-
|
37
|
-
without_sw_apm = "#{safe_method_name}_without_sw_apm"
|
38
|
-
with_sw_apm = "#{safe_method_name}_with_sw_apm"
|
39
|
-
|
40
|
-
# Only alias if we haven't done so already
|
41
|
-
unless cls.method_defined?(without_sw_apm.to_sym) ||
|
42
|
-
cls.private_method_defined?(without_sw_apm.to_sym)
|
43
|
-
|
44
|
-
cls.class_eval do
|
45
|
-
alias_method without_sw_apm, method.to_s
|
46
|
-
alias_method method.to_s, with_sw_apm
|
47
|
-
end
|
48
|
-
end
|
49
|
-
else
|
50
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/loading] Couldn't properly instrument #{name}.#{method}. Partial traces may occur."
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
##
|
55
|
-
# class_method_alias
|
56
|
-
#
|
57
|
-
# Centralized utility method to alias a class method on an arbitrary
|
58
|
-
# class or module
|
59
|
-
#
|
60
|
-
def class_method_alias(cls, method, name = nil)
|
61
|
-
name ||= contextual_name(cls)
|
62
|
-
|
63
|
-
if cls.singleton_methods.include? method.to_sym
|
64
|
-
|
65
|
-
# Strip '!' or '?' from method if present
|
66
|
-
safe_method_name = method.to_s.chop if method.to_s =~ /\?$|\!$/
|
67
|
-
safe_method_name ||= method
|
68
|
-
|
69
|
-
without_sw_apm = "#{safe_method_name}_without_sw_apm"
|
70
|
-
with_sw_apm = "#{safe_method_name}_with_sw_apm"
|
71
|
-
|
72
|
-
# Only alias if we haven't done so already
|
73
|
-
unless cls.singleton_methods.include? without_sw_apm.to_sym
|
74
|
-
cls.singleton_class.send(:alias_method, without_sw_apm, method.to_s)
|
75
|
-
cls.singleton_class.send(:alias_method, method.to_s, with_sw_apm)
|
76
|
-
end
|
77
|
-
else
|
78
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/loading] Couldn't properly instrument #{name}. Partial traces may occur."
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
##
|
83
|
-
# send_extend
|
84
|
-
#
|
85
|
-
# Centralized utility method to send an extend call for an
|
86
|
-
# arbitrary class
|
87
|
-
def send_extend(target_cls, cls)
|
88
|
-
target_cls.send(:extend, cls) if defined?(target_cls)
|
89
|
-
end
|
90
|
-
|
91
|
-
##
|
92
|
-
# send_include
|
93
|
-
#
|
94
|
-
# Centralized utility method to send a include call for an
|
95
|
-
# arbitrary class
|
96
|
-
def send_include(target_cls, cls)
|
97
|
-
target_cls.send(:include, cls) if defined?(target_cls)
|
98
|
-
end
|
99
|
-
|
100
|
-
##
|
101
|
-
# prettify
|
102
|
-
#
|
103
|
-
# Even to my surprise, 'prettify' is a real word:
|
104
|
-
# transitive v. To make pretty or prettier, especially in a superficial or insubstantial way.
|
105
|
-
# from The American Heritage Dictionary of the English Language, 4th Edition
|
106
|
-
#
|
107
|
-
# This method makes things 'purty' for reporting.
|
108
|
-
def prettify(x)
|
109
|
-
if (x.to_s =~ /^#</) == 0
|
110
|
-
x.class.to_s
|
111
|
-
else
|
112
|
-
x.to_s
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
##
|
117
|
-
# sanitize
|
118
|
-
#
|
119
|
-
# Remove the potential username and password from the uri user provided for reporting
|
120
|
-
def sanitize_uri(uri)
|
121
|
-
return uri if uri.nil?
|
122
|
-
begin
|
123
|
-
parsed_uri = URI.parse(uri)
|
124
|
-
parsed_uri.user = nil
|
125
|
-
sanitized_uri = parsed_uri.to_s
|
126
|
-
rescue StandardError => e
|
127
|
-
sanitized_uri = uri
|
128
|
-
SolarWindsAPM.logger.debug "[solarwinds_apm/debug] SolarWindsAPM::Util.sanitize_uri: could not sanitize #{uri}; caused by #{e.message}."
|
129
|
-
end
|
130
|
-
sanitized_uri
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
##
|
135
|
-
# upcase
|
136
|
-
#
|
137
|
-
# Occasionally, we want to send some values in all caps. This is true
|
138
|
-
# for things like HTTP scheme or method. This takes anything and does
|
139
|
-
# it's best to safely convert it to a string (if needed) and convert it
|
140
|
-
# to all uppercase.
|
141
|
-
def upcase(o)
|
142
|
-
if o.is_a?(String) || o.respond_to?(:to_s)
|
143
|
-
o.to_s.upcase
|
144
|
-
else
|
145
|
-
SolarWindsAPM.logger.debug "[solarwinds_apm/debug] SolarWindsAPM::Util.upcase: could not convert #{o.class}"
|
146
|
-
'UNKNOWN'
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
##
|
151
|
-
# to_query
|
152
|
-
#
|
153
|
-
# Used to convert a hash into a URL # query.
|
154
|
-
#
|
155
|
-
def to_query(h)
|
156
|
-
return '' unless h.is_a?(Hash)
|
157
|
-
|
158
|
-
result = []
|
159
|
-
|
160
|
-
h.each { |k, v| result.push(k.to_s + '=' + v.to_s) }
|
161
|
-
result.sort.join('&')
|
162
|
-
end
|
163
|
-
|
164
|
-
##
|
165
|
-
# sanitize_sql
|
166
|
-
#
|
167
|
-
# Remove query literals from SQL. Used by all
|
168
|
-
# DB adapter instrumentation.
|
169
|
-
#
|
170
|
-
# The regular expression passed to String.gsub is configurable
|
171
|
-
# via SolarWindsAPM::Config[:sanitize_sql_regexp] and
|
172
|
-
# SolarWindsAPM::Config[:sanitize_sql_opts].
|
173
|
-
#
|
174
|
-
def sanitize_sql(sql)
|
175
|
-
return sql unless SolarWindsAPM::Config[:sanitize_sql]
|
176
|
-
|
177
|
-
@@regexp ||= Regexp.new(SolarWindsAPM::Config[:sanitize_sql_regexp], SolarWindsAPM::Config[:sanitize_sql_opts]).freeze
|
178
|
-
sql.gsub(/\\\'/,'').gsub(@@regexp, '?')
|
179
|
-
end
|
180
|
-
|
181
|
-
##
|
182
|
-
# remove_traceparent
|
183
|
-
#
|
184
|
-
# Remove trace context injection
|
185
|
-
#
|
186
|
-
def remove_traceparent(sql)
|
187
|
-
sql.gsub(SolarWindsAPM::SDK::CurrentTraceInfo::TraceInfo::SQL_REGEX, '')
|
188
|
-
end
|
189
|
-
|
190
|
-
##
|
191
|
-
# deep_dup
|
192
|
-
#
|
193
|
-
# deep duplicate of array or hash
|
194
|
-
#
|
195
|
-
def deep_dup(obj)
|
196
|
-
if obj.is_a? Array
|
197
|
-
new_obj = []
|
198
|
-
obj.each do |v|
|
199
|
-
new_obj << deep_dup(v)
|
200
|
-
end
|
201
|
-
elsif obj.is_a? Hash
|
202
|
-
new_obj = {}
|
203
|
-
obj.each_pair do |key, value|
|
204
|
-
new_obj[key] = deep_dup(value)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
##
|
210
|
-
# legacy_build_init_report
|
211
|
-
#
|
212
|
-
# Internal: Build a hash of KVs that reports on the status of the
|
213
|
-
# running environment. This is used on stack boot in __Init reporting
|
214
|
-
# and for SolarWindsAPM.support_report.
|
215
|
-
#
|
216
|
-
# This legacy version of build_init_report is used for apps without Bundler.
|
217
|
-
#
|
218
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
219
|
-
#
|
220
|
-
# @deprecated Please use {#build_init_report} instead
|
221
|
-
def legacy_build_init_report
|
222
|
-
SolarWindsAPM.logger.warn '[solarwinds_apm/deprecated] Oboe::API will be deprecated in a future version.'
|
223
|
-
platform_info = {}
|
224
|
-
|
225
|
-
begin
|
226
|
-
# Report the framework in use
|
227
|
-
if defined?(::RailsLts::VERSION)
|
228
|
-
platform_info['Ruby.RailsLts.Version'] = "RailsLts-#{::RailsLts::VERSION}"
|
229
|
-
elsif defined?(::Rails.version)
|
230
|
-
platform_info['Ruby.Rails.Version'] = "Rails-#{::Rails.version}"
|
231
|
-
end
|
232
|
-
platform_info['Ruby.Grape.Version'] = "Grape-#{::Grape::VERSION}" if defined?(::Grape::VERSION)
|
233
|
-
platform_info['Ruby.Cramp.Version'] = "Cramp-#{::Cramp::VERSION}" if defined?(::Cramp::VERSION)
|
234
|
-
|
235
|
-
if defined?(::Padrino::VERSION)
|
236
|
-
platform_info['Ruby.Padrino.Version'] = "Padrino-#{::Padrino::VERSION}"
|
237
|
-
elsif defined?(::Sinatra::VERSION)
|
238
|
-
platform_info['Ruby.Sinatra.Version'] = "Sinatra-#{::Sinatra::VERSION}"
|
239
|
-
end
|
240
|
-
|
241
|
-
# Report the instrumented libraries
|
242
|
-
platform_info['Ruby.Curb.Version'] = "Curb-#{::Curl::VERSION}" if defined?(::Curl::VERSION)
|
243
|
-
platform_info['Ruby.Dalli.Version'] = "Dalli-#{::Dalli::VERSION}" if defined?(::Dalli::VERSION)
|
244
|
-
platform_info['Ruby.Excon.Version'] = "Excon-#{::Excon::VERSION}" if defined?(::Excon::VERSION)
|
245
|
-
platform_info['Ruby.Faraday.Version'] = "Faraday-#{::Faraday::VERSION}" if defined?(::Faraday::VERSION)
|
246
|
-
platform_info['Ruby.HTTPClient.Version'] = "HTTPClient-#{::HTTPClient::VERSION}" if defined?(::HTTPClient::VERSION)
|
247
|
-
platform_info['Ruby.Memcached.Version'] = "Memcached-#{::Memcached::VERSION}" if defined?(::Memcached::VERSION)
|
248
|
-
platform_info['Ruby.Moped.Version'] = "Moped-#{::Moped::VERSION}" if defined?(::Moped::VERSION)
|
249
|
-
platform_info['Ruby.Redis.Version'] = "Redis-#{::Redis::VERSION}" if defined?(::Redis::VERSION)
|
250
|
-
platform_info['Ruby.Resque.Version'] = "Resque-#{::Resque::VERSION}" if defined?(::Resque::VERSION)
|
251
|
-
platform_info['Ruby.RestClient.Version'] = "RestClient-#{::RestClient::VERSION}" if defined?(::RestClient::VERSION)
|
252
|
-
platform_info['Ruby.Sidekiq.Version'] = "Sidekiq-#{::Sidekiq::VERSION}" if defined?(::Sidekiq::VERSION)
|
253
|
-
platform_info['Ruby.Typhoeus.Version'] = "Typhoeus-#{::Typhoeus::VERSION}" if defined?(::Typhoeus::VERSION)
|
254
|
-
|
255
|
-
if Gem.loaded_specs.key?('delayed_job')
|
256
|
-
# Oddly, DelayedJob doesn't have an embedded version number so we get it from the loaded
|
257
|
-
# gem specs.
|
258
|
-
version = Gem.loaded_specs['delayed_job'].version.to_s
|
259
|
-
platform_info['Ruby.DelayedJob.Version'] = "DelayedJob-#{version}"
|
260
|
-
end
|
261
|
-
|
262
|
-
# Special case since the Mongo 1.x driver doesn't embed the version number in the gem directly
|
263
|
-
if ::Gem.loaded_specs.key?('mongo')
|
264
|
-
platform_info['Ruby.Mongo.Version'] = "Mongo-#{::Gem.loaded_specs['mongo'].version}"
|
265
|
-
end
|
266
|
-
|
267
|
-
# Report the DB adapter in use
|
268
|
-
platform_info['Ruby.Mysql.Version'] = Mysql::GemVersion::VERSION if defined?(Mysql::GemVersion::VERSION)
|
269
|
-
platform_info['Ruby.PG.Version'] = PG::VERSION if defined?(PG::VERSION)
|
270
|
-
platform_info['Ruby.Mysql2.Version'] = Mysql2::VERSION if defined?(Mysql2::VERSION)
|
271
|
-
platform_info['Ruby.Sequel.Version'] = ::Sequel::VERSION if defined?(::Sequel::VERSION)
|
272
|
-
rescue StandardError, ScriptError => e
|
273
|
-
# Also rescue ScriptError (aka SyntaxError) in case one of the expected
|
274
|
-
# version defines don't exist
|
275
|
-
|
276
|
-
platform_info['Error'] = "Error in legacy_build_init_report: #{e.message}"
|
277
|
-
|
278
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/legacy] Error in legacy_build_init_report: #{e.message}"
|
279
|
-
SolarWindsAPM.logger.debug e.backtrace
|
280
|
-
end
|
281
|
-
platform_info
|
282
|
-
end
|
283
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
284
|
-
|
285
|
-
##
|
286
|
-
# build_legacy_ao_init_report
|
287
|
-
#
|
288
|
-
# Internal: Build a hash of KVs that reports on the status of the
|
289
|
-
# running environment. This is used on stack boot in __Init reporting
|
290
|
-
# and for SolarWindsAPM.support_report.
|
291
|
-
# On 2023-01-12, this is no longer used in new SWO endpoints
|
292
|
-
#
|
293
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
294
|
-
def build_legacy_ao_init_report
|
295
|
-
platform_info = { '__Init' => 1 }
|
296
|
-
begin
|
297
|
-
platform_info['Force'] = true
|
298
|
-
platform_info['Ruby.Platform.Version'] = RUBY_PLATFORM
|
299
|
-
platform_info['Ruby.Version'] = RUBY_VERSION
|
300
|
-
platform_info['Ruby.SolarWindsAPM.Version'] = SolarWindsAPM::Version::STRING
|
301
|
-
platform_info['Ruby.SolarWindsAPMExtension.Version'] = get_extension_lib_version
|
302
|
-
platform_info['RubyHeroku.SolarWindsAPM.Version'] = SolarWindsAPMHeroku::Version::STRING if defined?(SolarWindsAPMHeroku)
|
303
|
-
platform_info['Ruby.TraceMode.Version'] = SolarWindsAPM::Config[:tracing_mode]
|
304
|
-
platform_info.merge!(report_gem_in_use)
|
305
|
-
platform_info.merge!(report_server_in_use)
|
306
|
-
|
307
|
-
rescue StandardError, ScriptError => e
|
308
|
-
platform_info['Error'] = "Error in build_report: #{e.message}"
|
309
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/warn] Error in build_init_report: #{e.message}"
|
310
|
-
SolarWindsAPM.logger.debug e.backtrace
|
311
|
-
end
|
312
|
-
platform_info
|
313
|
-
end
|
314
|
-
|
315
|
-
##
|
316
|
-
# build_swo_init_report
|
317
|
-
#
|
318
|
-
# Internal: Build a hash of KVs that reports on the status of the
|
319
|
-
# running environment for swo only. This is used on stack boot in __Init reporting
|
320
|
-
# and for SolarWindsAPM.support_report.
|
321
|
-
#
|
322
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
323
|
-
def build_init_report
|
324
|
-
|
325
|
-
platform_info = { '__Init' => true }
|
326
|
-
|
327
|
-
begin
|
328
|
-
platform_info['APM.Version'] = SolarWindsAPM::Version::STRING
|
329
|
-
platform_info['APM.Extension.Version'] = get_extension_lib_version
|
330
|
-
|
331
|
-
platform_info['process.pid'] = Process.pid
|
332
|
-
platform_info['process.command'] = $PROGRAM_NAME
|
333
|
-
platform_info['process.runtime.name'] = RUBY_ENGINE
|
334
|
-
platform_info['process.runtime.version'] = RUBY_VERSION
|
335
|
-
platform_info['process.runtime.description'] = RUBY_DESCRIPTION
|
336
|
-
platform_info['telemetry.sdk.language'] = 'ruby'
|
337
|
-
|
338
|
-
# Resource Attributes (Optional)
|
339
|
-
platform_info['process.executable.path'] = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
|
340
|
-
platform_info['process.executable.name'] = RbConfig::CONFIG['ruby_install_name']
|
341
|
-
platform_info['process.command_line'] = $PROGRAM_NAME
|
342
|
-
platform_info['process.telemetry.path'] = Gem::Specification.find_by_name('solarwinds_apm')&.full_gem_path
|
343
|
-
platform_info['os.type'] = RUBY_PLATFORM
|
344
|
-
|
345
|
-
platform_info.merge!(report_gem_in_use)
|
346
|
-
|
347
|
-
rescue StandardError, ScriptError => e
|
348
|
-
# Also rescue ScriptError (aka SyntaxError) in case one of the expected
|
349
|
-
# version defines don't exist
|
350
|
-
|
351
|
-
platform_info['Error'] = "Error in build_report: #{e.message}"
|
352
|
-
|
353
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/warn] Error in build_init_report: #{e.message}"
|
354
|
-
SolarWindsAPM.logger.debug e.backtrace
|
355
|
-
end
|
356
|
-
platform_info
|
357
|
-
end
|
358
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
359
|
-
|
360
|
-
private
|
361
|
-
|
362
|
-
##
|
363
|
-
# Collect up the loaded gems
|
364
|
-
##
|
365
|
-
def report_gem_in_use
|
366
|
-
platform_info = {}
|
367
|
-
if defined?(Gem) && Gem.respond_to?(:loaded_specs)
|
368
|
-
Gem.loaded_specs.each_pair { |k, v|
|
369
|
-
platform_info["Ruby.#{k}.Version"] = v.version.to_s
|
370
|
-
}
|
371
|
-
else
|
372
|
-
platform_info.merge!(legacy_build_init_report)
|
373
|
-
end
|
374
|
-
platform_info
|
375
|
-
end
|
376
|
-
|
377
|
-
##
|
378
|
-
# get extension library version by looking at the VERSION file
|
379
|
-
# oboe not loaded yet, can't use oboe_api function to read oboe VERSION
|
380
|
-
##
|
381
|
-
def get_extension_lib_version
|
382
|
-
version = '0.0.0'
|
383
|
-
begin
|
384
|
-
gem_location = Gem::Specification.find_by_name('solarwinds_apm')
|
385
|
-
clib_version_file = File.join(gem_location&.gem_dir, 'ext', 'oboe_metal', 'src', 'VERSION')
|
386
|
-
version = File.read(clib_version_file).strip
|
387
|
-
rescue
|
388
|
-
SolarWindsAPM.logger.warn "[solarwinds_apm/warn] Error in build_init_report: couldn't find installed solarwinds_apm gem #{e.message}"
|
389
|
-
end
|
390
|
-
version
|
391
|
-
end
|
392
|
-
|
393
|
-
##
|
394
|
-
# build_init_report
|
395
|
-
#
|
396
|
-
# Internal: Build a hash of KVs that reports on the server in use
|
397
|
-
##
|
398
|
-
def report_server_in_use
|
399
|
-
platform_info = {}
|
400
|
-
# Report the server in use (if possible)
|
401
|
-
if defined?(::Unicorn::Const::UNICORN_VERSION)
|
402
|
-
platform_info['Ruby.AppContainer.Version'] = "Unicorn-#{::Unicorn::Const::UNICORN_VERSION}"
|
403
|
-
elsif defined?(::Puma::Const::PUMA_VERSION)
|
404
|
-
platform_info['Ruby.AppContainer.Version'] = "Puma-#{::Puma::Const::PUMA_VERSION} (#{::Puma::Const::CODE_NAME})"
|
405
|
-
elsif defined?(::PhusionPassenger::PACKAGE_NAME)
|
406
|
-
platform_info['Ruby.AppContainer.Version'] = "#{::PhusionPassenger::PACKAGE_NAME}-#{::PhusionPassenger::VERSION_STRING}"
|
407
|
-
elsif defined?(::Thin::VERSION::STRING)
|
408
|
-
platform_info['Ruby.AppContainer.Version'] = "Thin-#{::Thin::VERSION::STRING} (#{::Thin::VERSION::CODENAME})"
|
409
|
-
elsif defined?(::Mongrel::Const::MONGREL_VERSION)
|
410
|
-
platform_info['Ruby.AppContainer.Version'] = "Mongrel-#{::Mongrel::Const::MONGREL_VERSION}"
|
411
|
-
elsif defined?(::Mongrel2::VERSION)
|
412
|
-
platform_info['Ruby.AppContainer.Version'] = "Mongrel2-#{::Mongrel2::VERSION}"
|
413
|
-
elsif defined?(::Trinidad::VERSION)
|
414
|
-
platform_info['Ruby.AppContainer.Version'] = "Trinidad-#{::Trinidad::VERSION}"
|
415
|
-
elsif defined?(::WEBrick::VERSION)
|
416
|
-
platform_info['Ruby.AppContainer.Version'] = "WEBrick-#{::WEBrick::VERSION}"
|
417
|
-
else
|
418
|
-
platform_info['Ruby.AppContainer.Version'] = File.basename($PROGRAM_NAME)
|
419
|
-
end
|
420
|
-
platform_info
|
421
|
-
end
|
422
|
-
|
423
|
-
end
|
424
|
-
|
425
|
-
end
|
426
|
-
end
|
data/log/.keep
DELETED
File without changes
|
data/log/postgresql/.keep
DELETED
File without changes
|