elastic-apm 3.3.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +43 -24
  3. data/.ci/.jenkins_framework.yml +2 -2
  4. data/.ci/.jenkins_ruby.yml +1 -1
  5. data/.ci/Jenkinsfile +288 -170
  6. data/.ci/docker/jruby/11-jdk/Dockerfile +40 -0
  7. data/.ci/docker/jruby/12-jdk/Dockerfile +40 -0
  8. data/.ci/docker/jruby/13-jdk/Dockerfile +40 -0
  9. data/.ci/docker/jruby/7-jdk/Dockerfile +40 -0
  10. data/.ci/docker/jruby/8-jdk/Dockerfile +40 -0
  11. data/.ci/docker/jruby/README.md +31 -0
  12. data/.ci/docker/jruby/run.sh +73 -0
  13. data/.ci/docker/jruby/test.sh +13 -0
  14. data/.ci/jobs/apm-agent-ruby-downstream.yml +1 -0
  15. data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +1 -0
  16. data/.ci/jobs/apm-agent-ruby-mbp.yml +1 -0
  17. data/.ci/jobs/defaults.yml +1 -1
  18. data/.ci/packer_cache.sh +16 -0
  19. data/.github/ISSUE_TEMPLATE/Bug_report.md +40 -0
  20. data/.github/ISSUE_TEMPLATE/Feature_request.md +17 -0
  21. data/.github/PULL_REQUEST_TEMPLATE.md +60 -0
  22. data/.gitignore +8 -0
  23. data/.rspec +0 -1
  24. data/.rubocop.yml +18 -0
  25. data/CHANGELOG.asciidoc +104 -1
  26. data/CONTRIBUTING.md +6 -48
  27. data/Gemfile +38 -10
  28. data/README.md +62 -13
  29. data/Rakefile +37 -5
  30. data/bench/sql.rb +49 -0
  31. data/bin/build_docs +1 -1
  32. data/bin/run-tests +4 -1
  33. data/docker-compose.yml +7 -0
  34. data/docs/api.asciidoc +52 -3
  35. data/docs/configuration.asciidoc +171 -22
  36. data/docs/getting-started-rails.asciidoc +2 -0
  37. data/docs/graphql.asciidoc +23 -0
  38. data/docs/images/dynamic-config.svg +1 -0
  39. data/docs/index.asciidoc +6 -1
  40. data/docs/introduction.asciidoc +2 -1
  41. data/docs/performance-tuning.asciidoc +106 -0
  42. data/docs/set-up.asciidoc +5 -2
  43. data/docs/supported-technologies.asciidoc +86 -1
  44. data/docs/upgrading.asciidoc +45 -0
  45. data/elastic-apm.gemspec +17 -0
  46. data/lib/elastic-apm.rb +17 -0
  47. data/lib/elastic_apm.rb +58 -5
  48. data/lib/elastic_apm/agent.rb +55 -4
  49. data/lib/elastic_apm/central_config.rb +27 -8
  50. data/lib/elastic_apm/central_config/cache_control.rb +17 -0
  51. data/lib/elastic_apm/child_durations.rb +26 -4
  52. data/lib/elastic_apm/config.rb +86 -5
  53. data/lib/elastic_apm/config/bytes.rb +17 -0
  54. data/lib/elastic_apm/config/duration.rb +17 -0
  55. data/lib/elastic_apm/config/options.rb +21 -5
  56. data/lib/elastic_apm/config/regexp_list.rb +17 -0
  57. data/lib/elastic_apm/config/wildcard_pattern_list.rb +20 -1
  58. data/lib/elastic_apm/context.rb +17 -0
  59. data/lib/elastic_apm/context/request.rb +17 -0
  60. data/lib/elastic_apm/context/request/socket.rb +17 -0
  61. data/lib/elastic_apm/context/request/url.rb +17 -0
  62. data/lib/elastic_apm/context/response.rb +27 -2
  63. data/lib/elastic_apm/context/user.rb +17 -0
  64. data/lib/elastic_apm/context_builder.rb +17 -0
  65. data/lib/elastic_apm/deprecations.rb +17 -0
  66. data/lib/elastic_apm/error.rb +17 -0
  67. data/lib/elastic_apm/error/exception.rb +17 -0
  68. data/lib/elastic_apm/error/log.rb +17 -0
  69. data/lib/elastic_apm/error_builder.rb +17 -0
  70. data/lib/elastic_apm/grape.rb +17 -0
  71. data/lib/elastic_apm/graphql.rb +91 -0
  72. data/lib/elastic_apm/grpc.rb +99 -0
  73. data/lib/elastic_apm/instrumenter.rb +49 -15
  74. data/lib/elastic_apm/internal_error.rb +17 -0
  75. data/lib/elastic_apm/logging.rb +17 -0
  76. data/lib/elastic_apm/metadata.rb +17 -0
  77. data/lib/elastic_apm/metadata/process_info.rb +17 -0
  78. data/lib/elastic_apm/metadata/service_info.rb +22 -2
  79. data/lib/elastic_apm/metadata/system_info.rb +17 -0
  80. data/lib/elastic_apm/metadata/system_info/container_info.rb +17 -0
  81. data/lib/elastic_apm/metrics.rb +33 -1
  82. data/lib/elastic_apm/metrics/breakdown_set.rb +17 -0
  83. data/lib/elastic_apm/metrics/cpu_mem_set.rb +17 -0
  84. data/lib/elastic_apm/metrics/metric.rb +23 -4
  85. data/lib/elastic_apm/metrics/set.rb +17 -0
  86. data/lib/elastic_apm/metrics/span_scoped_set.rb +17 -0
  87. data/lib/elastic_apm/metrics/transaction_set.rb +17 -0
  88. data/lib/elastic_apm/metrics/vm_set.rb +17 -0
  89. data/lib/elastic_apm/metricset.rb +17 -0
  90. data/lib/elastic_apm/middleware.rb +20 -4
  91. data/lib/elastic_apm/naively_hashable.rb +17 -0
  92. data/lib/elastic_apm/normalizers.rb +17 -0
  93. data/lib/elastic_apm/normalizers/grape.rb +17 -0
  94. data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +18 -1
  95. data/lib/elastic_apm/normalizers/rails.rb +17 -0
  96. data/lib/elastic_apm/normalizers/rails/action_controller.rb +17 -0
  97. data/lib/elastic_apm/normalizers/rails/action_mailer.rb +17 -0
  98. data/lib/elastic_apm/normalizers/rails/action_view.rb +17 -0
  99. data/lib/elastic_apm/normalizers/rails/active_record.rb +29 -5
  100. data/lib/elastic_apm/opentracing.rb +66 -24
  101. data/lib/elastic_apm/rails.rb +18 -10
  102. data/lib/elastic_apm/railtie.rb +18 -1
  103. data/lib/elastic_apm/resque.rb +29 -0
  104. data/lib/elastic_apm/sinatra.rb +17 -0
  105. data/lib/elastic_apm/span.rb +20 -2
  106. data/lib/elastic_apm/span/context.rb +43 -44
  107. data/lib/elastic_apm/span/context/db.rb +43 -0
  108. data/lib/elastic_apm/span/context/destination.rb +77 -0
  109. data/lib/elastic_apm/span/context/http.rb +43 -0
  110. data/lib/elastic_apm/span_helpers.rb +17 -0
  111. data/lib/elastic_apm/spies.rb +33 -14
  112. data/lib/elastic_apm/spies/action_dispatch.rb +17 -0
  113. data/lib/elastic_apm/spies/delayed_job.rb +17 -0
  114. data/lib/elastic_apm/spies/elasticsearch.rb +49 -5
  115. data/lib/elastic_apm/spies/faraday.rb +53 -18
  116. data/lib/elastic_apm/spies/http.rb +35 -3
  117. data/lib/elastic_apm/spies/json.rb +17 -0
  118. data/lib/elastic_apm/spies/mongo.rb +23 -1
  119. data/lib/elastic_apm/spies/net_http.rb +50 -8
  120. data/lib/elastic_apm/spies/rake.rb +17 -0
  121. data/lib/elastic_apm/spies/redis.rb +17 -0
  122. data/lib/elastic_apm/spies/resque.rb +53 -0
  123. data/lib/elastic_apm/spies/sequel.rb +52 -15
  124. data/lib/elastic_apm/spies/shoryuken.rb +65 -0
  125. data/lib/elastic_apm/spies/sidekiq.rb +17 -0
  126. data/lib/elastic_apm/spies/sinatra.rb +17 -0
  127. data/lib/elastic_apm/spies/sneakers.rb +74 -0
  128. data/lib/elastic_apm/spies/sucker_punch.rb +54 -0
  129. data/lib/elastic_apm/spies/tilt.rb +17 -0
  130. data/lib/elastic_apm/sql.rb +36 -0
  131. data/lib/elastic_apm/sql/signature.rb +169 -0
  132. data/lib/elastic_apm/sql/tokenizer.rb +264 -0
  133. data/lib/elastic_apm/sql/tokens.rb +63 -0
  134. data/lib/elastic_apm/sql_summarizer.rb +18 -2
  135. data/lib/elastic_apm/stacktrace.rb +17 -0
  136. data/lib/elastic_apm/stacktrace/frame.rb +17 -0
  137. data/lib/elastic_apm/stacktrace_builder.rb +23 -1
  138. data/lib/elastic_apm/subscriber.rb +17 -0
  139. data/lib/elastic_apm/trace_context.rb +85 -49
  140. data/lib/elastic_apm/trace_context/traceparent.rb +113 -0
  141. data/lib/elastic_apm/trace_context/tracestate.rb +43 -0
  142. data/lib/elastic_apm/transaction.rb +43 -15
  143. data/lib/elastic_apm/transport/base.rb +39 -23
  144. data/lib/elastic_apm/transport/connection.rb +17 -0
  145. data/lib/elastic_apm/transport/connection/http.rb +17 -0
  146. data/lib/elastic_apm/transport/connection/proxy_pipe.rb +24 -2
  147. data/lib/elastic_apm/transport/filters.rb +17 -0
  148. data/lib/elastic_apm/transport/filters/hash_sanitizer.rb +77 -0
  149. data/lib/elastic_apm/transport/filters/secrets_filter.rb +29 -53
  150. data/lib/elastic_apm/transport/headers.rb +21 -0
  151. data/lib/elastic_apm/transport/serializers.rb +17 -0
  152. data/lib/elastic_apm/transport/serializers/context_serializer.rb +17 -0
  153. data/lib/elastic_apm/transport/serializers/error_serializer.rb +17 -0
  154. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +44 -20
  155. data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +17 -0
  156. data/lib/elastic_apm/transport/serializers/span_serializer.rb +45 -8
  157. data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +17 -0
  158. data/lib/elastic_apm/transport/user_agent.rb +17 -0
  159. data/lib/elastic_apm/transport/worker.rb +17 -0
  160. data/lib/elastic_apm/util.rb +17 -0
  161. data/lib/elastic_apm/util/inflector.rb +17 -0
  162. data/lib/elastic_apm/util/lru_cache.rb +17 -0
  163. data/lib/elastic_apm/util/throttle.rb +17 -0
  164. data/lib/elastic_apm/version.rb +18 -1
  165. metadata +36 -7
  166. data/.ci/downstreamTests.groovy +0 -185
  167. data/.ci/prepare-git-context.sh +0 -24
  168. data/.github/workflows/main.yml +0 -14
  169. data/CHANGELOG.md +0 -1
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  require 'elastic_apm/error'
@@ -34,9 +51,9 @@ module ElasticAPM
34
51
  LOCK.synchronize do
35
52
  return @instance if @instance
36
53
 
37
- unless config.active?
54
+ unless config.enabled?
38
55
  config.logger.debug format(
39
- "%sAgent disabled with `active: false'",
56
+ "%sAgent disabled with `enabled: false'",
40
57
  Logging::PREFIX
41
58
  )
42
59
  return
@@ -72,6 +89,7 @@ module ElasticAPM
72
89
  metrics: metrics,
73
90
  stacktrace_builder: stacktrace_builder
74
91
  ) { |event| enqueue event }
92
+ @pid = Process.pid
75
93
  end
76
94
 
77
95
  attr_reader(
@@ -86,6 +104,7 @@ module ElasticAPM
86
104
  )
87
105
 
88
106
  def_delegator :@central_config, :config
107
+
89
108
  def start
90
109
  unless config.disable_start_message?
91
110
  config.logger.info format(
@@ -144,6 +163,9 @@ module ElasticAPM
144
163
  context: nil,
145
164
  trace_context: nil
146
165
  )
166
+ return unless config.recording?
167
+ detect_forking!
168
+
147
169
  instrumenter.start_transaction(
148
170
  name,
149
171
  type,
@@ -165,8 +187,16 @@ module ElasticAPM
165
187
  action: nil,
166
188
  backtrace: nil,
167
189
  context: nil,
168
- trace_context: nil
190
+ trace_context: nil,
191
+ parent: nil,
192
+ sync: nil
169
193
  )
194
+ detect_forking!
195
+
196
+ # We don't check config.recording? because the span
197
+ # will not be created if there's no transaction.
198
+ # We want to use the recording value from the config
199
+ # that existed when start_transaction was called. ~estolfo
170
200
  instrumenter.start_span(
171
201
  name,
172
202
  type,
@@ -174,7 +204,9 @@ module ElasticAPM
174
204
  action: action,
175
205
  backtrace: backtrace,
176
206
  context: context,
177
- trace_context: trace_context
207
+ trace_context: trace_context,
208
+ parent: parent,
209
+ sync: sync
178
210
  )
179
211
  end
180
212
  # rubocop:enable Metrics/ParameterLists
@@ -202,6 +234,8 @@ module ElasticAPM
202
234
  # errors
203
235
 
204
236
  def report(exception, context: nil, handled: true)
237
+ return unless config.recording?
238
+ detect_forking!
205
239
  return if config.filter_exception_types.include?(exception.class.to_s)
206
240
 
207
241
  error = @error_builder.build_exception(
@@ -214,6 +248,9 @@ module ElasticAPM
214
248
  end
215
249
 
216
250
  def report_message(message, context: nil, backtrace: nil, **attrs)
251
+ return unless config.recording?
252
+ detect_forking!
253
+
217
254
  error = @error_builder.build_log(
218
255
  message,
219
256
  context: context,
@@ -235,5 +272,19 @@ module ElasticAPM
235
272
  def inspect
236
273
  super.split.first + '>'
237
274
  end
275
+
276
+ def detect_forking!
277
+ return if @pid == Process.pid
278
+
279
+ config.logger.debug "Detected forking,
280
+ restarting threads in process [PID:#{Process.pid}]"
281
+
282
+ central_config.handle_forking!
283
+ transport.handle_forking!
284
+ instrumenter.handle_forking!
285
+ metrics.handle_forking!
286
+
287
+ @pid = Process.pid
288
+ end
238
289
  end
239
290
  end
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  require 'elastic_apm/central_config/cache_control'
@@ -81,15 +98,16 @@ module ElasticAPM
81
98
  update[key] = @modified_options.delete(key)
82
99
  end
83
100
 
84
- update_config(update)
101
+ @config.replace_options(update)
85
102
  end
86
103
 
87
- private
88
-
89
- def update_config(new_options)
90
- @config = config.dup.tap { |new_config| new_config.assign(new_options) }
104
+ def handle_forking!
105
+ stop
106
+ start
91
107
  end
92
108
 
109
+ private
110
+
93
111
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
94
112
  def handle_success(resp)
95
113
  if (etag = resp.headers['Etag'])
@@ -104,9 +122,10 @@ module ElasticAPM
104
122
  assign(update)
105
123
  end
106
124
 
107
- if @modified_options.any?
125
+ if update && update.any?
108
126
  info 'Updated config from Kibana'
109
- debug 'Modified: %s', @modified_options.inspect
127
+ debug 'Modified: %s', update.inspect
128
+ debug 'Modified original options: %s', @modified_options.inspect
110
129
  end
111
130
  end
112
131
 
@@ -151,7 +170,7 @@ module ElasticAPM
151
170
  def schedule_next_fetch(resp = nil)
152
171
  headers = resp&.headers
153
172
  seconds =
154
- if headers['Cache-Control']
173
+ if headers && headers['Cache-Control']
155
174
  CacheControl.new(headers['Cache-Control']).max_age
156
175
  else
157
176
  DEFAULT_MAX_AGE
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module ElasticAPM
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module ElasticAPM
@@ -24,18 +41,23 @@ module ElasticAPM
24
41
  @nesting_level = 0
25
42
  @start = nil
26
43
  @duration = 0
44
+ @mutex = Mutex.new
27
45
  end
28
46
 
29
47
  attr_reader :duration
30
48
 
31
49
  def start
32
- @nesting_level += 1
33
- @start = Util.micros if @nesting_level == 1
50
+ @mutex.synchronize do
51
+ @nesting_level += 1
52
+ @start = Util.micros if @nesting_level == 1
53
+ end
34
54
  end
35
55
 
36
56
  def stop
37
- @nesting_level -= 1
38
- @duration = (Util.micros - @start) if @nesting_level == 0
57
+ @mutex.synchronize do
58
+ @nesting_level -= 1
59
+ @duration = (Util.micros - @start) if @nesting_level == 0
60
+ end
39
61
  end
40
62
  end
41
63
  end
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  require 'elastic_apm/config/options'
@@ -17,27 +34,28 @@ module ElasticAPM
17
34
  option :config_file, type: :string, default: 'config/elastic_apm.yml'
18
35
  option :server_url, type: :url, default: 'http://localhost:8200'
19
36
  option :secret_token, type: :string
37
+ option :api_key, type: :string
20
38
 
21
- option :active, type: :bool, default: true
22
39
  option :api_buffer_size, type: :int, default: 256
23
40
  option :api_request_size, type: :bytes, default: '750kb', converter: Bytes.new
24
41
  option :api_request_time, type: :float, default: '10s', converter: Duration.new
25
42
  option :breakdown_metrics, type: :bool, default: true
26
43
  option :capture_body, type: :string, default: 'off'
27
44
  option :capture_headers, type: :bool, default: true
45
+ option :capture_elasticsearch_queries, type: :bool, default: false
28
46
  option :capture_env, type: :bool, default: true
29
47
  option :central_config, type: :bool, default: true
30
48
  option :current_user_email_method, type: :string, default: 'email'
31
49
  option :current_user_id_method, type: :string, default: 'id'
32
50
  option :current_user_username_method, type: :string, default: 'username'
33
51
  option :custom_key_filters, type: :list, default: [], converter: RegexpList.new
34
- option :default_tags, type: :dict, default: {}
35
52
  option :default_labels, type: :dict, default: {}
36
53
  option :disable_metrics, type: :list, default: [], converter: WildcardPatternList.new
37
54
  option :disable_send, type: :bool, default: false
38
55
  option :disable_start_message, type: :bool, default: false
39
- option :disabled_instrumentations, type: :list, default: %w[json]
56
+ option :disable_instrumentations, type: :list, default: %w[json]
40
57
  option :disabled_spies, type: :list, default: []
58
+ option :enabled, type: :bool, default: true
41
59
  option :environment, type: :string, default: ENV['RAILS_ENV'] || ENV['RACK_ENV']
42
60
  option :framework_name, type: :string
43
61
  option :framework_version, type: :string
@@ -57,8 +75,11 @@ module ElasticAPM
57
75
  option :proxy_password, type: :string
58
76
  option :proxy_port, type: :int
59
77
  option :proxy_username, type: :string
78
+ option :recording, type: :bool, default: true
79
+ option :sanitize_field_names, type: :list, default: [], converter: WildcardPatternList.new
60
80
  option :server_ca_cert, type: :string
61
81
  option :service_name, type: :string
82
+ option :service_node_name, type: :string
62
83
  option :service_version, type: :string
63
84
  option :source_lines_error_app_frames, type: :int, default: 5
64
85
  option :source_lines_error_library_frames, type: :int, default: 0
@@ -68,7 +89,10 @@ module ElasticAPM
68
89
  option :stack_trace_limit, type: :int, default: 999_999
69
90
  option :transaction_max_spans, type: :int, default: 500
70
91
  option :transaction_sample_rate, type: :float, default: 1.0
92
+ option :use_elastic_traceparent_header, type: :bool, default: true
93
+ option :use_legacy_sql_parser, type: :bool, default: false
71
94
  option :verify_server_cert, type: :bool, default: true
95
+
72
96
  # rubocop:enable Metrics/LineLength, Layout/ExtraSpacing
73
97
  def initialize(options = {})
74
98
  @options = load_schema
@@ -105,6 +129,7 @@ module ElasticAPM
105
129
 
106
130
  def available_instrumentations
107
131
  %w[
132
+ action_dispatch
108
133
  delayed_job
109
134
  elasticsearch
110
135
  faraday
@@ -112,17 +137,21 @@ module ElasticAPM
112
137
  json
113
138
  mongo
114
139
  net_http
140
+ rake
115
141
  redis
142
+ resque
116
143
  sequel
144
+ shoryuken
117
145
  sidekiq
118
146
  sinatra
147
+ sneakers
148
+ sucker_punch
119
149
  tilt
120
- rake
121
150
  ]
122
151
  end
123
152
 
124
153
  def enabled_instrumentations
125
- available_instrumentations - disabled_instrumentations
154
+ available_instrumentations - disable_instrumentations
126
155
  end
127
156
 
128
157
  def method_missing(name, *args)
@@ -130,6 +159,15 @@ module ElasticAPM
130
159
  warn "The option `#{name}' has been removed."
131
160
  end
132
161
 
162
+ def replace_options(new_options)
163
+ return if new_options.nil? || new_options.empty?
164
+ options_copy = @options.dup
165
+ new_options.each do |key, value|
166
+ options_copy.fetch(key.to_sym).set(value)
167
+ end
168
+ @options = options_copy
169
+ end
170
+
133
171
  def app=(app)
134
172
  case app_type?(app)
135
173
  when :sinatra
@@ -187,6 +225,49 @@ module ElasticAPM
187
225
  super.split.first + '>'
188
226
  end
189
227
 
228
+ # Deprecations
229
+
230
+ def default_tags=(value)
231
+ warn '[DEPRECATED] The option default_tags has been renamed to ' \
232
+ 'default_labels.'
233
+ self.default_labels = value
234
+ end
235
+
236
+ def custom_key_filters=(value)
237
+ unless value == self.class.schema[:custom_key_filters][:default]
238
+ warn '[DEPRECATED] The option custom_key_filters is being removed. ' \
239
+ 'See sanitize_field_names for an alternative.'
240
+ end
241
+
242
+ set(:custom_key_filters, value)
243
+ end
244
+
245
+ def disabled_instrumentations
246
+ disable_instrumentations
247
+ end
248
+
249
+ def active
250
+ enabled
251
+ end
252
+ alias active? active
253
+
254
+ def disabled_instrumentations=(value)
255
+ warn '[DEPRECATED] The option disabled_instrumentations has been ' \
256
+ 'renamed to disable_instrumentations to align with other agents.'
257
+ self.disable_instrumentations = value
258
+ end
259
+
260
+ def use_experimental_sql_parser=(value)
261
+ warn '[DEPRECATED] The new SQL parser is now the default. To use the old one, '
262
+ 'use use_legacy_sql_parser and please report why you wish to do so.'
263
+ end
264
+
265
+ def active=(value)
266
+ warn '[DEPRECATED] The option active has been renamed to enabled ' \
267
+ 'to align with other agents and with the remote config.'
268
+ self.enabled = value
269
+ end
270
+
190
271
  private
191
272
 
192
273
  def load_config_file
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module ElasticAPM
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module ElasticAPM