elastic-apm 1.1.0 → 2.0.0
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.
Potentially problematic release.
This version of elastic-apm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +45 -0
- data/Gemfile +17 -12
- data/bench/app.rb +1 -2
- data/bench/benchmark.rb +1 -1
- data/bench/stackprof.rb +1 -1
- data/docs/api.asciidoc +115 -76
- data/docs/configuration.asciidoc +232 -167
- data/docs/context.asciidoc +7 -3
- data/docs/custom-instrumentation.asciidoc +17 -28
- data/docs/index.asciidoc +13 -7
- data/docs/supported-technologies.asciidoc +65 -0
- data/elastic-apm.gemspec +3 -2
- data/lib/elastic_apm.rb +272 -121
- data/lib/elastic_apm/agent.rb +56 -107
- data/lib/elastic_apm/config.rb +130 -106
- data/lib/elastic_apm/config/duration.rb +25 -0
- data/lib/elastic_apm/config/size.rb +28 -0
- data/lib/elastic_apm/context_builder.rb +1 -0
- data/lib/elastic_apm/deprecations.rb +19 -0
- data/lib/elastic_apm/error.rb +5 -2
- data/lib/elastic_apm/error/exception.rb +1 -1
- data/lib/elastic_apm/error_builder.rb +5 -0
- data/lib/elastic_apm/instrumenter.rb +121 -53
- data/lib/elastic_apm/internal_error.rb +1 -0
- data/lib/elastic_apm/{log.rb → logging.rb} +16 -11
- data/lib/elastic_apm/metadata.rb +20 -0
- data/lib/elastic_apm/metadata/process_info.rb +26 -0
- data/lib/elastic_apm/metadata/service_info.rb +56 -0
- data/lib/elastic_apm/metadata/system_info.rb +30 -0
- data/lib/elastic_apm/middleware.rb +31 -15
- data/lib/elastic_apm/normalizers/action_controller.rb +1 -1
- data/lib/elastic_apm/normalizers/action_mailer.rb +1 -1
- data/lib/elastic_apm/normalizers/action_view.rb +3 -3
- data/lib/elastic_apm/normalizers/active_record.rb +2 -1
- data/lib/elastic_apm/railtie.rb +1 -1
- data/lib/elastic_apm/span.rb +59 -29
- data/lib/elastic_apm/span/context.rb +30 -4
- data/lib/elastic_apm/span_helpers.rb +1 -1
- data/lib/elastic_apm/spies/delayed_job.rb +7 -7
- data/lib/elastic_apm/spies/elasticsearch.rb +4 -4
- data/lib/elastic_apm/spies/http.rb +38 -0
- data/lib/elastic_apm/spies/mongo.rb +22 -11
- data/lib/elastic_apm/spies/net_http.rb +7 -4
- data/lib/elastic_apm/spies/rake.rb +5 -6
- data/lib/elastic_apm/spies/redis.rb +1 -1
- data/lib/elastic_apm/spies/sequel.rb +9 -7
- data/lib/elastic_apm/spies/sidekiq.rb +5 -5
- data/lib/elastic_apm/spies/tilt.rb +2 -2
- data/lib/elastic_apm/sql_summarizer.rb +3 -3
- data/lib/elastic_apm/stacktrace_builder.rb +6 -6
- data/lib/elastic_apm/subscriber.rb +3 -3
- data/lib/elastic_apm/traceparent.rb +62 -0
- data/lib/elastic_apm/transaction.rb +62 -93
- data/lib/elastic_apm/transport/base.rb +98 -0
- data/lib/elastic_apm/transport/connection.rb +175 -0
- data/lib/elastic_apm/transport/filters.rb +45 -0
- data/lib/elastic_apm/transport/filters/request_body_filter.rb +31 -0
- data/lib/elastic_apm/transport/filters/secrets_filter.rb +59 -0
- data/lib/elastic_apm/transport/serializers.rb +58 -0
- data/lib/elastic_apm/transport/serializers/error_serializer.rb +59 -0
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +30 -0
- data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +33 -0
- data/lib/elastic_apm/transport/worker.rb +73 -0
- data/lib/elastic_apm/util.rb +11 -8
- data/lib/elastic_apm/version.rb +1 -1
- metadata +40 -21
- data/.travis.yml +0 -5
- data/docs/troubleshooting.asciidoc +0 -28
- data/lib/elastic_apm/filters.rb +0 -46
- data/lib/elastic_apm/filters/request_body_filter.rb +0 -33
- data/lib/elastic_apm/filters/secrets_filter.rb +0 -59
- data/lib/elastic_apm/http.rb +0 -139
- data/lib/elastic_apm/process_info.rb +0 -24
- data/lib/elastic_apm/serializers.rb +0 -28
- data/lib/elastic_apm/serializers/errors.rb +0 -61
- data/lib/elastic_apm/serializers/transactions.rb +0 -51
- data/lib/elastic_apm/service_info.rb +0 -54
- data/lib/elastic_apm/system_info.rb +0 -28
- data/lib/elastic_apm/util/dig.rb +0 -31
- data/lib/elastic_apm/util/inspector.rb +0 -61
- data/lib/elastic_apm/worker.rb +0 -106
data/lib/elastic_apm/agent.rb
CHANGED
@@ -5,16 +5,14 @@ require 'elastic_apm/context_builder'
|
|
5
5
|
require 'elastic_apm/error_builder'
|
6
6
|
require 'elastic_apm/stacktrace_builder'
|
7
7
|
require 'elastic_apm/error'
|
8
|
-
require 'elastic_apm/
|
8
|
+
require 'elastic_apm/transport/base'
|
9
9
|
require 'elastic_apm/spies'
|
10
|
-
require 'elastic_apm/serializers'
|
11
|
-
require 'elastic_apm/worker'
|
12
10
|
|
13
11
|
module ElasticAPM
|
14
12
|
# rubocop:disable Metrics/ClassLength
|
15
13
|
# @api private
|
16
14
|
class Agent
|
17
|
-
include
|
15
|
+
include Logging
|
18
16
|
|
19
17
|
LOCK = Mutex.new
|
20
18
|
|
@@ -24,22 +22,11 @@ module ElasticAPM
|
|
24
22
|
@instance
|
25
23
|
end
|
26
24
|
|
27
|
-
def self.start(config)
|
25
|
+
def self.start(config)
|
28
26
|
return @instance if @instance
|
29
27
|
|
30
28
|
config = Config.new(config) unless config.is_a?(Config)
|
31
29
|
|
32
|
-
unless config.enabled_environments.include?(config.environment)
|
33
|
-
unless config.disable_environment_warning?
|
34
|
-
puts format(
|
35
|
-
'%sNot tracking anything in "%s" env',
|
36
|
-
Log::PREFIX, config.environment
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
return
|
41
|
-
end
|
42
|
-
|
43
30
|
LOCK.synchronize do
|
44
31
|
return @instance if @instance
|
45
32
|
|
@@ -62,25 +49,23 @@ module ElasticAPM
|
|
62
49
|
|
63
50
|
def initialize(config)
|
64
51
|
@config = config
|
65
|
-
@http = Http.new(config)
|
66
|
-
|
67
|
-
@messages = Queue.new
|
68
|
-
@pending_transactions = Queue.new
|
69
52
|
|
70
|
-
@
|
53
|
+
@transport = Transport::Base.new(config)
|
54
|
+
@instrumenter = Instrumenter.new(config) { |event| enqueue event }
|
71
55
|
|
56
|
+
@stacktrace_builder = StacktraceBuilder.new(config)
|
72
57
|
@context_builder = ContextBuilder.new(self)
|
73
58
|
@error_builder = ErrorBuilder.new(self)
|
74
|
-
@stacktrace_builder = StacktraceBuilder.new(self)
|
75
59
|
end
|
76
60
|
|
77
|
-
attr_reader :config, :
|
78
|
-
:
|
61
|
+
attr_reader :config, :transport, :instrumenter,
|
62
|
+
:stacktrace_builder, :context_builder, :error_builder
|
79
63
|
|
80
64
|
def start
|
81
|
-
|
65
|
+
info '[%s] Starting agent, reporting to %s', VERSION, config.server_url
|
82
66
|
|
83
|
-
|
67
|
+
transport.start
|
68
|
+
instrumenter.start
|
84
69
|
|
85
70
|
config.enabled_spies.each do |lib|
|
86
71
|
require "elastic_apm/spies/#{lib}"
|
@@ -90,9 +75,10 @@ module ElasticAPM
|
|
90
75
|
end
|
91
76
|
|
92
77
|
def stop
|
93
|
-
|
78
|
+
debug 'Stopping agent'
|
94
79
|
|
95
|
-
|
80
|
+
instrumenter.stop
|
81
|
+
transport.stop
|
96
82
|
|
97
83
|
self
|
98
84
|
end
|
@@ -101,29 +87,10 @@ module ElasticAPM
|
|
101
87
|
stop
|
102
88
|
end
|
103
89
|
|
104
|
-
#
|
90
|
+
# transport
|
105
91
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
pending_transactions.push(transaction)
|
110
|
-
|
111
|
-
return unless should_flush_transactions?
|
112
|
-
|
113
|
-
messages.push(Worker::FlushMsg.new)
|
114
|
-
end
|
115
|
-
|
116
|
-
def should_flush_transactions?
|
117
|
-
return true unless config.flush_interval
|
118
|
-
return true if pending_transactions.length >= config.max_queue_size
|
119
|
-
|
120
|
-
false
|
121
|
-
end
|
122
|
-
|
123
|
-
def enqueue_error(error)
|
124
|
-
boot_worker unless worker_running?
|
125
|
-
|
126
|
-
messages.push(Worker::ErrorMsg.new(error))
|
92
|
+
def enqueue(obj)
|
93
|
+
transport.submit obj
|
127
94
|
end
|
128
95
|
|
129
96
|
# instrumentation
|
@@ -132,26 +99,53 @@ module ElasticAPM
|
|
132
99
|
instrumenter.current_transaction
|
133
100
|
end
|
134
101
|
|
135
|
-
def
|
136
|
-
instrumenter.
|
102
|
+
def current_span
|
103
|
+
instrumenter.current_span
|
104
|
+
end
|
105
|
+
|
106
|
+
def start_transaction(
|
107
|
+
name = nil,
|
108
|
+
type = nil,
|
109
|
+
context: nil,
|
110
|
+
traceparent: nil
|
111
|
+
)
|
112
|
+
instrumenter.start_transaction(
|
137
113
|
name,
|
138
114
|
type,
|
139
115
|
context: context,
|
140
|
-
|
141
|
-
&block
|
116
|
+
traceparent: traceparent
|
142
117
|
)
|
143
118
|
end
|
144
119
|
|
145
|
-
def
|
146
|
-
instrumenter.
|
120
|
+
def end_transaction(result = nil)
|
121
|
+
instrumenter.end_transaction(result)
|
122
|
+
end
|
123
|
+
|
124
|
+
def start_span(name = nil, type = nil, backtrace: nil, context: nil)
|
125
|
+
instrumenter.start_span(
|
147
126
|
name,
|
148
127
|
type,
|
149
128
|
backtrace: backtrace,
|
150
|
-
context: context
|
151
|
-
&block
|
129
|
+
context: context
|
152
130
|
)
|
153
131
|
end
|
154
132
|
|
133
|
+
def end_span
|
134
|
+
instrumenter.end_span
|
135
|
+
end
|
136
|
+
|
137
|
+
def set_tag(key, value)
|
138
|
+
instrumenter.set_tag(key, value)
|
139
|
+
end
|
140
|
+
|
141
|
+
def set_custom_context(context)
|
142
|
+
instrumenter.set_custom_context(context)
|
143
|
+
end
|
144
|
+
|
145
|
+
def set_user(user)
|
146
|
+
instrumenter.set_user(user)
|
147
|
+
end
|
148
|
+
|
155
149
|
def build_context(rack_env)
|
156
150
|
@context_builder.build(rack_env)
|
157
151
|
end
|
@@ -165,7 +159,7 @@ module ElasticAPM
|
|
165
159
|
exception,
|
166
160
|
handled: handled
|
167
161
|
)
|
168
|
-
|
162
|
+
enqueue error
|
169
163
|
end
|
170
164
|
|
171
165
|
def report_message(message, backtrace: nil, **attrs)
|
@@ -174,58 +168,13 @@ module ElasticAPM
|
|
174
168
|
backtrace: backtrace,
|
175
169
|
**attrs
|
176
170
|
)
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
# context
|
181
|
-
|
182
|
-
def set_tag(key, value)
|
183
|
-
instrumenter.set_tag(key, value)
|
171
|
+
enqueue error
|
184
172
|
end
|
185
173
|
|
186
|
-
|
187
|
-
instrumenter.set_custom_context(context)
|
188
|
-
end
|
189
|
-
|
190
|
-
def set_user(user)
|
191
|
-
instrumenter.set_user(user)
|
192
|
-
end
|
174
|
+
# filters
|
193
175
|
|
194
176
|
def add_filter(key, callback)
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
def inspect
|
199
|
-
'<ElasticAPM::Agent>'
|
200
|
-
end
|
201
|
-
|
202
|
-
private
|
203
|
-
|
204
|
-
def boot_worker
|
205
|
-
debug 'Booting worker'
|
206
|
-
|
207
|
-
@worker_thread = Thread.new do
|
208
|
-
Worker.new(
|
209
|
-
config,
|
210
|
-
messages,
|
211
|
-
pending_transactions,
|
212
|
-
http
|
213
|
-
).run_forever
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def kill_worker
|
218
|
-
messages << Worker::StopMsg.new
|
219
|
-
|
220
|
-
if @worker_thread && !@worker_thread.join(5) # 5 secs
|
221
|
-
raise 'Failed to wait for worker, not all messages sent'
|
222
|
-
end
|
223
|
-
|
224
|
-
@worker_thread = nil
|
225
|
-
end
|
226
|
-
|
227
|
-
def worker_running?
|
228
|
-
@worker_thread && @worker_thread.alive?
|
177
|
+
transport.add_filter(key, callback)
|
229
178
|
end
|
230
179
|
end
|
231
180
|
# rubocop:enable Metrics/ClassLength
|
data/lib/elastic_apm/config.rb
CHANGED
@@ -3,55 +3,45 @@
|
|
3
3
|
require 'logger'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
+
require 'elastic_apm/config/duration'
|
7
|
+
require 'elastic_apm/config/size'
|
8
|
+
|
6
9
|
module ElasticAPM
|
7
10
|
# rubocop:disable Metrics/ClassLength
|
8
11
|
# @api private
|
9
12
|
class Config
|
10
13
|
DEFAULTS = {
|
11
14
|
config_file: 'config/elastic_apm.yml',
|
15
|
+
|
12
16
|
server_url: 'http://localhost:8200',
|
13
17
|
|
18
|
+
api_buffer_size: 256,
|
19
|
+
api_request_size: '750kb',
|
20
|
+
api_request_time: '10s',
|
21
|
+
current_user_email_method: :email,
|
22
|
+
current_user_id_method: :id,
|
23
|
+
current_user_username_method: :username,
|
24
|
+
custom_key_filters: [],
|
25
|
+
default_tags: {},
|
26
|
+
disable_send: false,
|
27
|
+
disabled_spies: %w[json],
|
14
28
|
environment: ENV['RAILS_ENV'] || ENV['RACK_ENV'],
|
15
|
-
enabled_environments: %w[production],
|
16
|
-
disable_environment_warning: false,
|
17
|
-
instrument: true,
|
18
|
-
|
19
|
-
log_path: nil,
|
20
|
-
log_level: Logger::DEBUG,
|
21
|
-
|
22
|
-
max_queue_size: 500,
|
23
|
-
flush_interval: 10,
|
24
|
-
transaction_sample_rate: 1.0,
|
25
|
-
transaction_max_spans: 500,
|
26
29
|
filter_exception_types: [],
|
27
|
-
|
28
|
-
disable_send: false,
|
29
|
-
http_read_timeout: 120,
|
30
|
-
http_open_timeout: 60,
|
31
|
-
debug_transactions: false,
|
32
|
-
debug_http: false,
|
33
|
-
verify_server_cert: true,
|
34
30
|
http_compression: true,
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
ignore_url_patterns: [],
|
32
|
+
instrument: true,
|
33
|
+
instrumented_rake_tasks: [],
|
34
|
+
log_level: Logger::INFO,
|
35
|
+
log_path: nil,
|
36
|
+
pool_size: 1,
|
38
37
|
source_lines_error_app_frames: 5,
|
39
|
-
source_lines_span_app_frames: 5,
|
40
38
|
source_lines_error_library_frames: 0,
|
39
|
+
source_lines_span_app_frames: 5,
|
41
40
|
source_lines_span_library_frames: 0,
|
42
|
-
span_frames_min_duration:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
default_tags: {},
|
48
|
-
|
49
|
-
current_user_id_method: :id,
|
50
|
-
current_user_email_method: :email,
|
51
|
-
current_user_username_method: :username,
|
52
|
-
|
53
|
-
custom_key_filters: [],
|
54
|
-
ignore_url_patterns: [],
|
41
|
+
span_frames_min_duration: '5ms',
|
42
|
+
transaction_max_spans: 500,
|
43
|
+
transaction_sample_rate: 1.0,
|
44
|
+
verify_server_cert: true,
|
55
45
|
|
56
46
|
view_paths: [],
|
57
47
|
root_path: Dir.pwd
|
@@ -61,49 +51,46 @@ module ElasticAPM
|
|
61
51
|
'ELASTIC_APM_SERVER_URL' => 'server_url',
|
62
52
|
'ELASTIC_APM_SECRET_TOKEN' => 'secret_token',
|
63
53
|
|
54
|
+
'ELASTIC_APM_API_BUFFER_SIZE' => [:int, 'api_buffer_size'],
|
55
|
+
'ELASTIC_APM_API_REQUEST_SIZE' => [:int, 'api_request_size'],
|
56
|
+
'ELASTIC_APM_API_REQUEST_TIME' => 'api_request_time',
|
57
|
+
'ELASTIC_APM_CUSTOM_KEY_FILTERS' => [:list, 'custom_key_filters'],
|
58
|
+
'ELASTIC_APM_DEFAULT_TAGS' => [:dict, 'default_tags'],
|
59
|
+
'ELASTIC_APM_DISABLED_SPIES' => [:list, 'disabled_spies'],
|
60
|
+
'ELASTIC_APM_DISABLE_SEND' => [:bool, 'disable_send'],
|
64
61
|
'ELASTIC_APM_ENVIRONMENT' => 'environment',
|
65
|
-
'
|
66
|
-
'
|
67
|
-
|
62
|
+
'ELASTIC_APM_FRAMEWORK_NAME' => 'framework_name',
|
63
|
+
'ELASTIC_APM_FRAMEWORK_VERSION' => 'framework_version',
|
64
|
+
'ELASTIC_APM_HOSTNAME' => 'hostname',
|
65
|
+
'ELASTIC_APM_IGNORE_URL_PATTERNS' => [:list, 'ignore_url_patterns'],
|
68
66
|
'ELASTIC_APM_INSTRUMENT' => [:bool, 'instrument'],
|
69
|
-
|
70
|
-
|
67
|
+
'ELASTIC_APM_INSTRUMENTED_RAKE_TASKS' =>
|
68
|
+
[:list, 'instrumented_rake_tasks'],
|
71
69
|
'ELASTIC_APM_LOG_LEVEL' => [:int, 'log_level'],
|
72
|
-
|
70
|
+
'ELASTIC_APM_LOG_PATH' => 'log_path',
|
71
|
+
'ELASTIC_APM_POOL_SIZE' => [:int, 'pool_size'],
|
73
72
|
'ELASTIC_APM_SERVICE_NAME' => 'service_name',
|
74
73
|
'ELASTIC_APM_SERVICE_VERSION' => 'service_version',
|
75
|
-
'ELASTIC_APM_FRAMEWORK_NAME' => 'framework_name',
|
76
|
-
'ELASTIC_APM_FRAMEWORK_VERSION' => 'framework_version',
|
77
|
-
'ELASTIC_APM_HOSTNAME' => 'hostname',
|
78
|
-
|
79
74
|
'ELASTIC_APM_SOURCE_LINES_ERROR_APP_FRAMES' =>
|
80
75
|
[:int, 'source_lines_error_app_frames'],
|
81
|
-
'ELASTIC_APM_SOURCE_LINES_SPAN_APP_FRAMES' =>
|
82
|
-
[:int, 'source_lines_span_app_frames'],
|
83
76
|
'ELASTIC_APM_SOURCE_LINES_ERROR_LIBRARY_FRAMES' =>
|
84
77
|
[:int, 'source_lines_error_library_frames'],
|
78
|
+
'ELASTIC_APM_SOURCE_LINES_SPAN_APP_FRAMES' =>
|
79
|
+
[:int, 'source_lines_span_app_frames'],
|
85
80
|
'ELASTIC_APM_SOURCE_LINES_SPAN_LIBRARY_FRAMES' =>
|
86
81
|
[:int, 'source_lines_span_library_frames'],
|
87
|
-
'ELASTIC_APM_SPAN_FRAMES_MIN_DURATION' =>
|
88
|
-
|
89
|
-
|
90
|
-
'ELASTIC_APM_CUSTOM_KEY_FILTERS' => [:list, 'custom_key_filters'],
|
91
|
-
'ELASTIC_APM_IGNORE_URL_PATTERNS' => [:list, 'ignore_url_patterns'],
|
92
|
-
|
93
|
-
'ELASTIC_APM_MAX_QUEUE_SIZE' => [:int, 'max_queue_size'],
|
94
|
-
'ELASTIC_APM_FLUSH_INTERVAL' => 'flush_interval',
|
82
|
+
'ELASTIC_APM_SPAN_FRAMES_MIN_DURATION' => 'span_frames_min_duration',
|
83
|
+
'ELASTIC_APM_TRANSACTION_MAX_SPANS' => [:int, 'transaction_max_spans'],
|
95
84
|
'ELASTIC_APM_TRANSACTION_SAMPLE_RATE' =>
|
96
85
|
[:float, 'transaction_sample_rate'],
|
97
|
-
'ELASTIC_APM_VERIFY_SERVER_CERT' => [:bool, 'verify_server_cert']
|
98
|
-
|
86
|
+
'ELASTIC_APM_VERIFY_SERVER_CERT' => [:bool, 'verify_server_cert']
|
87
|
+
}.freeze
|
99
88
|
|
100
|
-
|
101
|
-
|
102
|
-
'ELASTIC_APM_INSTRUMENTED_RAKE_TASKS' =>
|
103
|
-
[:list, 'instrumented_rake_tasks'],
|
89
|
+
DURATION_KEYS = %i[api_request_time span_frames_min_duration].freeze
|
90
|
+
DURATION_DEFAULT_UNITS = { span_frames_min_duration: 'ms' }.freeze
|
104
91
|
|
105
|
-
|
106
|
-
}.freeze
|
92
|
+
SIZE_KEYS = %i[api_request_size].freeze
|
93
|
+
SIZE_DEFAULT_UNITS = { api_request_size: 'kb' }.freeze
|
107
94
|
|
108
95
|
def initialize(options = {})
|
109
96
|
set_defaults
|
@@ -112,9 +99,12 @@ module ElasticAPM
|
|
112
99
|
set_from_config_file
|
113
100
|
set_from_env
|
114
101
|
|
102
|
+
normalize_durations
|
103
|
+
normalize_sizes
|
104
|
+
|
115
105
|
yield self if block_given?
|
116
106
|
|
117
|
-
build_logger if logger.nil?
|
107
|
+
build_logger if logger.nil?
|
118
108
|
end
|
119
109
|
|
120
110
|
attr_accessor :config_file
|
@@ -122,61 +112,49 @@ module ElasticAPM
|
|
122
112
|
attr_accessor :server_url
|
123
113
|
attr_accessor :secret_token
|
124
114
|
|
115
|
+
attr_accessor :api_buffer_size
|
116
|
+
attr_accessor :api_request_size
|
117
|
+
attr_accessor :api_request_time
|
118
|
+
attr_accessor :current_user_email_method
|
119
|
+
attr_accessor :current_user_id_method
|
120
|
+
attr_accessor :current_user_method
|
121
|
+
attr_accessor :current_user_username_method
|
122
|
+
attr_accessor :default_tags
|
123
|
+
attr_accessor :disable_send
|
124
|
+
attr_accessor :disabled_spies
|
125
125
|
attr_accessor :environment
|
126
|
-
attr_accessor :
|
127
|
-
attr_accessor :disable_environment_warning
|
128
|
-
attr_accessor :instrument
|
129
|
-
|
130
|
-
attr_accessor :service_name
|
131
|
-
attr_accessor :service_version
|
126
|
+
attr_accessor :filter_exception_types
|
132
127
|
attr_accessor :framework_name
|
133
128
|
attr_accessor :framework_version
|
134
129
|
attr_accessor :hostname
|
135
|
-
|
136
|
-
attr_accessor :
|
130
|
+
attr_accessor :http_compression
|
131
|
+
attr_accessor :instrument
|
132
|
+
attr_accessor :instrumented_rake_tasks
|
137
133
|
attr_accessor :log_level
|
134
|
+
attr_accessor :log_path
|
138
135
|
attr_accessor :logger
|
139
|
-
|
140
|
-
attr_accessor :
|
141
|
-
attr_accessor :
|
142
|
-
attr_accessor :transaction_sample_rate
|
143
|
-
attr_accessor :transaction_max_spans
|
144
|
-
attr_accessor :verify_server_cert
|
145
|
-
attr_accessor :filter_exception_types
|
146
|
-
|
147
|
-
attr_accessor :disable_send
|
148
|
-
attr_accessor :http_read_timeout
|
149
|
-
attr_accessor :http_open_timeout
|
150
|
-
attr_accessor :debug_transactions
|
151
|
-
attr_accessor :debug_http
|
152
|
-
attr_accessor :http_compression
|
153
|
-
attr_accessor :compression_minimum_size
|
154
|
-
attr_accessor :compression_level
|
155
|
-
|
136
|
+
attr_accessor :pool_size
|
137
|
+
attr_accessor :service_name
|
138
|
+
attr_accessor :service_version
|
156
139
|
attr_accessor :source_lines_error_app_frames
|
157
|
-
attr_accessor :source_lines_span_app_frames
|
158
140
|
attr_accessor :source_lines_error_library_frames
|
141
|
+
attr_accessor :source_lines_span_app_frames
|
159
142
|
attr_accessor :source_lines_span_library_frames
|
160
|
-
attr_accessor :
|
143
|
+
attr_accessor :transaction_max_spans
|
144
|
+
attr_accessor :transaction_sample_rate
|
145
|
+
attr_accessor :verify_server_cert
|
161
146
|
|
162
|
-
|
163
|
-
|
147
|
+
attr_reader :custom_key_filters
|
148
|
+
attr_reader :ignore_url_patterns
|
149
|
+
attr_reader :span_frames_min_duration
|
150
|
+
attr_reader :span_frames_min_duration_us
|
164
151
|
|
165
152
|
attr_accessor :view_paths
|
166
153
|
attr_accessor :root_path
|
167
154
|
|
168
|
-
attr_accessor :current_user_method
|
169
|
-
attr_accessor :current_user_id_method
|
170
|
-
attr_accessor :current_user_email_method
|
171
|
-
attr_accessor :current_user_username_method
|
172
|
-
|
173
|
-
attr_accessor :default_tags
|
174
|
-
|
175
|
-
attr_reader :custom_key_filters
|
176
|
-
attr_reader :ignore_url_patterns
|
177
|
-
|
178
|
-
alias :disable_environment_warning? :disable_environment_warning
|
179
155
|
alias :disable_send? :disable_send
|
156
|
+
alias :http_compression? :http_compression
|
157
|
+
alias :instrument? :instrument
|
180
158
|
alias :verify_server_cert? :verify_server_cert
|
181
159
|
|
182
160
|
def app=(app)
|
@@ -186,7 +164,6 @@ module ElasticAPM
|
|
186
164
|
when :rails
|
187
165
|
set_rails(app)
|
188
166
|
else
|
189
|
-
# TODO: define custom?
|
190
167
|
self.service_name = 'ruby'
|
191
168
|
end
|
192
169
|
end
|
@@ -221,6 +198,7 @@ module ElasticAPM
|
|
221
198
|
action_dispatch
|
222
199
|
delayed_job
|
223
200
|
elasticsearch
|
201
|
+
http
|
224
202
|
json
|
225
203
|
mongo
|
226
204
|
net_http
|
@@ -238,6 +216,32 @@ module ElasticAPM
|
|
238
216
|
available_spies - disabled_spies
|
239
217
|
end
|
240
218
|
|
219
|
+
def span_frames_min_duration=(duration)
|
220
|
+
@span_frames_min_duration = duration
|
221
|
+
@span_frames_min_duration_us = duration * 1_000_000
|
222
|
+
end
|
223
|
+
|
224
|
+
DEPRECATED_OPTIONS = %i[
|
225
|
+
compression_level=
|
226
|
+
compression_minimum_size=
|
227
|
+
debug_http=
|
228
|
+
debug_transactions=
|
229
|
+
flush_interval=
|
230
|
+
http_open_timeout=
|
231
|
+
http_read_timeout=
|
232
|
+
enabled_environments=
|
233
|
+
disable_environment_warning=
|
234
|
+
].freeze
|
235
|
+
|
236
|
+
def respond_to_missing?(name)
|
237
|
+
DEPRECATED_OPTIONS.include? name
|
238
|
+
end
|
239
|
+
|
240
|
+
def method_missing(name, *args)
|
241
|
+
return super unless DEPRECATED_OPTIONS.include?(name)
|
242
|
+
warn "The option `#{name}' has been removed."
|
243
|
+
end
|
244
|
+
|
241
245
|
private
|
242
246
|
|
243
247
|
def assign(options)
|
@@ -251,6 +255,7 @@ module ElasticAPM
|
|
251
255
|
end
|
252
256
|
|
253
257
|
# rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
258
|
+
# rubocop:disable Metrics/AbcSize
|
254
259
|
def set_from_env
|
255
260
|
ENV_TO_KEY.each do |env_key, key|
|
256
261
|
next unless (value = ENV[env_key])
|
@@ -270,6 +275,7 @@ module ElasticAPM
|
|
270
275
|
send("#{key}=", value)
|
271
276
|
end
|
272
277
|
end
|
278
|
+
# rubocop:enable Metrics/AbcSize
|
273
279
|
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
274
280
|
|
275
281
|
def set_from_args(options)
|
@@ -299,7 +305,7 @@ module ElasticAPM
|
|
299
305
|
end
|
300
306
|
|
301
307
|
def build_logger
|
302
|
-
logger = Logger.new(log_path == '-' ?
|
308
|
+
logger = Logger.new(log_path == '-' ? STDOUT : log_path)
|
303
309
|
logger.level = log_level
|
304
310
|
|
305
311
|
self.logger = logger
|
@@ -308,6 +314,24 @@ module ElasticAPM
|
|
308
314
|
def format_name(str)
|
309
315
|
str.gsub('::', '_')
|
310
316
|
end
|
317
|
+
|
318
|
+
def normalize_durations
|
319
|
+
DURATION_KEYS.each do |key|
|
320
|
+
value = send(key).to_s
|
321
|
+
default_unit = DURATION_DEFAULT_UNITS.fetch(key, 's')
|
322
|
+
duration = Duration.parse(value, default_unit: default_unit)
|
323
|
+
send("#{key}=", duration.seconds)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
def normalize_sizes
|
328
|
+
SIZE_KEYS.each do |key|
|
329
|
+
value = send(key).to_s
|
330
|
+
default_unit = SIZE_DEFAULT_UNITS.fetch(key, 'b')
|
331
|
+
size = Size.parse(value, default_unit: default_unit)
|
332
|
+
send("#{key}=", size.bytes)
|
333
|
+
end
|
334
|
+
end
|
311
335
|
end
|
312
336
|
# rubocop:enable Metrics/ClassLength
|
313
337
|
end
|