elastic-apm 3.15.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +13 -0
  3. data/.ci/.jenkins_ruby.yml +0 -1
  4. data/.ci/Jenkinsfile +1 -0
  5. data/.github/dependabot.yml +16 -0
  6. data/.rubocop.yml +0 -7
  7. data/CHANGELOG.asciidoc +77 -4
  8. data/Gemfile +4 -1
  9. data/README.md +12 -0
  10. data/SECURITY.md +7 -0
  11. data/bench/report.rb +1 -1
  12. data/bin/run-bdd +17 -0
  13. data/bin/run-tests +1 -1
  14. data/docker-compose.yml +1 -1
  15. data/docs/configuration.asciidoc +62 -147
  16. data/docs/release-notes.asciidoc +1 -0
  17. data/docs/upgrading.asciidoc +0 -27
  18. data/lib/elastic_apm.rb +12 -1
  19. data/lib/elastic_apm/agent.rb +7 -3
  20. data/lib/elastic_apm/central_config.rb +8 -7
  21. data/lib/elastic_apm/config.rb +2 -88
  22. data/lib/elastic_apm/config/regexp_list.rb +1 -1
  23. data/lib/elastic_apm/config/wildcard_pattern_list.rb +1 -1
  24. data/lib/elastic_apm/context/response.rb +1 -3
  25. data/lib/elastic_apm/fields.rb +88 -0
  26. data/lib/elastic_apm/grpc.rb +2 -4
  27. data/lib/elastic_apm/instrumenter.rb +1 -1
  28. data/lib/elastic_apm/metadata/cloud_info.rb +32 -5
  29. data/lib/elastic_apm/metadata/system_info.rb +14 -4
  30. data/lib/elastic_apm/metrics/cpu_mem_set.rb +1 -1
  31. data/lib/elastic_apm/normalizers.rb +2 -2
  32. data/lib/elastic_apm/normalizers/rails/active_record.rb +3 -3
  33. data/lib/elastic_apm/opentracing.rb +3 -2
  34. data/lib/elastic_apm/span.rb +26 -1
  35. data/lib/elastic_apm/span/context.rb +2 -1
  36. data/lib/elastic_apm/span/context/destination.rb +53 -40
  37. data/lib/elastic_apm/span_helpers.rb +6 -8
  38. data/lib/elastic_apm/spies.rb +20 -0
  39. data/lib/elastic_apm/spies/action_dispatch.rb +10 -9
  40. data/lib/elastic_apm/spies/azure_storage_table.rb +148 -0
  41. data/lib/elastic_apm/spies/dynamo_db.rb +12 -12
  42. data/lib/elastic_apm/spies/elasticsearch.rb +32 -29
  43. data/lib/elastic_apm/spies/faraday.rb +83 -63
  44. data/lib/elastic_apm/spies/http.rb +33 -34
  45. data/lib/elastic_apm/spies/mongo.rb +5 -3
  46. data/lib/elastic_apm/spies/net_http.rb +59 -56
  47. data/lib/elastic_apm/spies/rake.rb +28 -26
  48. data/lib/elastic_apm/spies/redis.rb +11 -10
  49. data/lib/elastic_apm/spies/resque.rb +18 -21
  50. data/lib/elastic_apm/spies/s3.rb +14 -15
  51. data/lib/elastic_apm/spies/sequel.rb +42 -48
  52. data/lib/elastic_apm/spies/sidekiq.rb +13 -15
  53. data/lib/elastic_apm/spies/sinatra.rb +20 -21
  54. data/lib/elastic_apm/spies/sns.rb +39 -44
  55. data/lib/elastic_apm/spies/sqs.rb +21 -31
  56. data/lib/elastic_apm/spies/tilt.rb +10 -9
  57. data/lib/elastic_apm/sql/tokenizer.rb +21 -5
  58. data/lib/elastic_apm/stacktrace_builder.rb +3 -1
  59. data/lib/elastic_apm/subscriber.rb +1 -0
  60. data/lib/elastic_apm/trace_context.rb +5 -13
  61. data/lib/elastic_apm/trace_context/traceparent.rb +5 -6
  62. data/lib/elastic_apm/transport/connection.rb +1 -1
  63. data/lib/elastic_apm/transport/connection/http.rb +4 -2
  64. data/lib/elastic_apm/transport/connection/proxy_pipe.rb +1 -2
  65. data/lib/elastic_apm/transport/filters/hash_sanitizer.rb +5 -23
  66. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +3 -2
  67. data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +2 -2
  68. data/lib/elastic_apm/transport/serializers/span_serializer.rb +12 -12
  69. data/lib/elastic_apm/transport/user_agent.rb +3 -2
  70. data/lib/elastic_apm/transport/worker.rb +1 -1
  71. data/lib/elastic_apm/util/deep_dup.rb +1 -1
  72. data/lib/elastic_apm/version.rb +1 -1
  73. metadata +12 -9
  74. data/lib/elastic_apm/sql.rb +0 -36
  75. data/lib/elastic_apm/sql_summarizer.rb +0 -53
@@ -46,8 +46,8 @@ module ElasticAPM
46
46
  private
47
47
 
48
48
  def build_samples(samples)
49
- samples.each_with_object({}) do |(key, value), hsh|
50
- hsh[key] = { value: value }
49
+ samples.transform_values do |value|
50
+ { value: value }
51
51
  end
52
52
  end
53
53
  end
@@ -93,19 +93,19 @@ module ElasticAPM
93
93
  end
94
94
 
95
95
  def build_destination(destination)
96
- base =
97
- {
98
- service: {
99
- name: keyword_field(destination.name),
100
- resource: keyword_field(destination.resource),
101
- type: keyword_field(destination.type)
102
- },
103
- address: keyword_field(destination.address),
104
- port: destination.port
105
- }
96
+ return unless destination
97
+
98
+ base = {
99
+ address: keyword_field(destination.address),
100
+ port: destination.port
101
+ }
102
+
103
+ unless destination.service&.empty?
104
+ base[:service] = destination.service.to_h
105
+ end
106
106
 
107
- if cloud = destination.cloud
108
- base[:cloud] = { region: cloud.region }
107
+ unless destination.cloud&.empty?
108
+ base[:cloud] = destination.cloud.to_h
109
109
  end
110
110
 
111
111
  base
@@ -21,7 +21,8 @@ module ElasticAPM
21
21
  module Transport
22
22
  # @api private
23
23
  class UserAgent
24
- def initialize(config)
24
+ def initialize(config, version: VERSION)
25
+ @version = version
25
26
  @built = build(config)
26
27
  end
27
28
 
@@ -35,7 +36,7 @@ module ElasticAPM
35
36
  service = Metadata::ServiceInfo.new(config)
36
37
 
37
38
  [
38
- "elastic-apm-ruby/#{VERSION}",
39
+ "elastic-apm-ruby/#{@version}",
39
40
  HTTP::Request::USER_AGENT,
40
41
  [
41
42
  service.runtime.name,
@@ -58,7 +58,7 @@ module ElasticAPM
58
58
  while (msg = queue.pop)
59
59
  case msg
60
60
  when StopMessage
61
- debug 'Stopping worker -- %s', self
61
+ debug 'Stopping worker [%s]', self
62
62
  connection.flush(:halt)
63
63
  break
64
64
  else
@@ -48,7 +48,7 @@ module ElasticAPM
48
48
  end
49
49
 
50
50
  def array(arr)
51
- arr.map(&method(:deep_dup))
51
+ arr.map { |obj| deep_dup(obj) }
52
52
  end
53
53
 
54
54
  def hash(hsh)
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module ElasticAPM
21
- VERSION = '3.15.1'
21
+ VERSION = '4.2.0'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-06 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - mikkel@elastic.co
44
44
  executables: []
@@ -69,6 +69,7 @@ files:
69
69
  - ".github/ISSUE_TEMPLATE/Bug_report.md"
70
70
  - ".github/ISSUE_TEMPLATE/Feature_request.md"
71
71
  - ".github/PULL_REQUEST_TEMPLATE.md"
72
+ - ".github/dependabot.yml"
72
73
  - ".github/labeler-config.yml"
73
74
  - ".github/workflows/addToProject.yml"
74
75
  - ".github/workflows/labeler.yml"
@@ -84,6 +85,7 @@ files:
84
85
  - LICENSE
85
86
  - README.md
86
87
  - Rakefile
88
+ - SECURITY.md
87
89
  - bench/.gitignore
88
90
  - bench/app.rb
89
91
  - bench/benchmark.rb
@@ -95,6 +97,7 @@ files:
95
97
  - bin/build_docs
96
98
  - bin/console
97
99
  - bin/dev
100
+ - bin/run-bdd
98
101
  - bin/run-tests
99
102
  - bin/setup
100
103
  - bin/with_framework
@@ -146,6 +149,7 @@ files:
146
149
  - lib/elastic_apm/error/exception.rb
147
150
  - lib/elastic_apm/error/log.rb
148
151
  - lib/elastic_apm/error_builder.rb
152
+ - lib/elastic_apm/fields.rb
149
153
  - lib/elastic_apm/grape.rb
150
154
  - lib/elastic_apm/graphql.rb
151
155
  - lib/elastic_apm/grpc.rb
@@ -191,6 +195,7 @@ files:
191
195
  - lib/elastic_apm/span_helpers.rb
192
196
  - lib/elastic_apm/spies.rb
193
197
  - lib/elastic_apm/spies/action_dispatch.rb
198
+ - lib/elastic_apm/spies/azure_storage_table.rb
194
199
  - lib/elastic_apm/spies/delayed_job.rb
195
200
  - lib/elastic_apm/spies/dynamo_db.rb
196
201
  - lib/elastic_apm/spies/elasticsearch.rb
@@ -212,11 +217,9 @@ files:
212
217
  - lib/elastic_apm/spies/sqs.rb
213
218
  - lib/elastic_apm/spies/sucker_punch.rb
214
219
  - lib/elastic_apm/spies/tilt.rb
215
- - lib/elastic_apm/sql.rb
216
220
  - lib/elastic_apm/sql/signature.rb
217
221
  - lib/elastic_apm/sql/tokenizer.rb
218
222
  - lib/elastic_apm/sql/tokens.rb
219
- - lib/elastic_apm/sql_summarizer.rb
220
223
  - lib/elastic_apm/stacktrace.rb
221
224
  - lib/elastic_apm/stacktrace/frame.rb
222
225
  - lib/elastic_apm/stacktrace_builder.rb
@@ -254,7 +257,7 @@ licenses:
254
257
  - Apache-2.0
255
258
  metadata:
256
259
  source_code_uri: https://github.com/elastic/apm-agent-ruby
257
- post_install_message:
260
+ post_install_message:
258
261
  rdoc_options: []
259
262
  require_paths:
260
263
  - lib
@@ -269,8 +272,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
272
  - !ruby/object:Gem::Version
270
273
  version: '0'
271
274
  requirements: []
272
- rubygems_version: 3.1.6
273
- signing_key:
275
+ rubygems_version: 3.0.3.1
276
+ signing_key:
274
277
  specification_version: 4
275
278
  summary: The official Elastic APM agent for Ruby
276
279
  test_files: []
@@ -1,36 +0,0 @@
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
-
18
- # frozen_string_literal: true
19
-
20
- module ElasticAPM
21
- # @api private
22
- module Sql
23
- # This method is only here as a shortcut while the agent ships with
24
- # both implementations ~mikker
25
- def self.summarizer
26
- @summarizer ||=
27
- if ElasticAPM.agent&.config&.use_legacy_sql_parser
28
- require 'elastic_apm/sql_summarizer'
29
- SqlSummarizer.new
30
- else
31
- require 'elastic_apm/sql/signature'
32
- Sql::Signature::Summarizer.new
33
- end
34
- end
35
- end
36
- end
@@ -1,53 +0,0 @@
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
-
18
- # frozen_string_literal: true
19
-
20
- require 'elastic_apm/util/lru_cache'
21
-
22
- module ElasticAPM
23
- # @api private
24
- class SqlSummarizer
25
- DEFAULT = 'SQL'
26
- TABLE_REGEX = %{["'`]?([A-Za-z0-9_]+)["'`]?}
27
-
28
- REGEXES = {
29
- /^BEGIN/iu => 'BEGIN',
30
- /^COMMIT/iu => 'COMMIT',
31
- /^SELECT .* FROM #{TABLE_REGEX}/iu => 'SELECT FROM ',
32
- /^INSERT INTO #{TABLE_REGEX}/iu => 'INSERT INTO ',
33
- /^UPDATE #{TABLE_REGEX}/iu => 'UPDATE ',
34
- /^DELETE FROM #{TABLE_REGEX}/iu => 'DELETE FROM '
35
- }.freeze
36
-
37
- FORMAT = '%s%s'
38
-
39
- def self.cache
40
- @cache ||= Util::LruCache.new
41
- end
42
-
43
- def summarize(sql)
44
- sql = sql.encode('utf-8', invalid: :replace, undef: :replace)
45
- self.class.cache[sql] ||=
46
- REGEXES.find do |regex, sig|
47
- if (match = sql[0...1000].match(regex))
48
- break format(FORMAT, sig, match[1] && match[1].gsub(/["']/, ''))
49
- end
50
- end || DEFAULT
51
- end
52
- end
53
- end