elastic-apm 3.2.0 → 3.3.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +8 -1
  3. data/.ci/.jenkins_ruby.yml +1 -0
  4. data/.ci/Jenkinsfile +64 -31
  5. data/.github/workflows/main.yml +14 -0
  6. data/.pre-commit-config.yaml +1 -5
  7. data/.rubocop.yml +35 -29
  8. data/CHANGELOG.asciidoc +20 -4
  9. data/Gemfile +1 -0
  10. data/README.md +2 -2
  11. data/bin/dev +1 -1
  12. data/bin/run-tests +3 -0
  13. data/docs/api.asciidoc +0 -29
  14. data/docs/configuration.asciidoc +11 -0
  15. data/docs/context.asciidoc +4 -4
  16. data/lib/elastic_apm.rb +5 -9
  17. data/lib/elastic_apm/agent.rb +0 -9
  18. data/lib/elastic_apm/central_config.rb +10 -10
  19. data/lib/elastic_apm/central_config/cache_control.rb +1 -1
  20. data/lib/elastic_apm/config.rb +4 -11
  21. data/lib/elastic_apm/config/options.rb +2 -4
  22. data/lib/elastic_apm/config/wildcard_pattern_list.rb +35 -0
  23. data/lib/elastic_apm/context_builder.rb +0 -2
  24. data/lib/elastic_apm/error.rb +1 -1
  25. data/lib/elastic_apm/error/exception.rb +2 -2
  26. data/lib/elastic_apm/error_builder.rb +0 -2
  27. data/lib/elastic_apm/grape.rb +0 -3
  28. data/lib/elastic_apm/instrumenter.rb +3 -13
  29. data/lib/elastic_apm/metadata/service_info.rb +0 -5
  30. data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -6
  31. data/lib/elastic_apm/metrics.rb +0 -3
  32. data/lib/elastic_apm/metrics/cpu_mem_set.rb +0 -10
  33. data/lib/elastic_apm/metrics/metric.rb +6 -2
  34. data/lib/elastic_apm/metrics/set.rb +4 -4
  35. data/lib/elastic_apm/metrics/span_scoped_set.rb +1 -1
  36. data/lib/elastic_apm/metrics/transaction_set.rb +0 -2
  37. data/lib/elastic_apm/metrics/vm_set.rb +0 -3
  38. data/lib/elastic_apm/middleware.rb +0 -2
  39. data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +2 -1
  40. data/lib/elastic_apm/normalizers/rails/active_record.rb +1 -1
  41. data/lib/elastic_apm/opentracing.rb +6 -15
  42. data/lib/elastic_apm/rails.rb +2 -5
  43. data/lib/elastic_apm/sinatra.rb +1 -1
  44. data/lib/elastic_apm/span.rb +2 -2
  45. data/lib/elastic_apm/span/context.rb +17 -1
  46. data/lib/elastic_apm/spies/elasticsearch.rb +0 -3
  47. data/lib/elastic_apm/spies/faraday.rb +2 -4
  48. data/lib/elastic_apm/spies/http.rb +0 -3
  49. data/lib/elastic_apm/spies/mongo.rb +10 -5
  50. data/lib/elastic_apm/spies/net_http.rb +1 -4
  51. data/lib/elastic_apm/spies/rake.rb +0 -2
  52. data/lib/elastic_apm/spies/sequel.rb +0 -2
  53. data/lib/elastic_apm/spies/sidekiq.rb +2 -6
  54. data/lib/elastic_apm/spies/sinatra.rb +0 -2
  55. data/lib/elastic_apm/stacktrace/frame.rb +0 -3
  56. data/lib/elastic_apm/stacktrace_builder.rb +0 -2
  57. data/lib/elastic_apm/subscriber.rb +2 -3
  58. data/lib/elastic_apm/trace_context.rb +0 -3
  59. data/lib/elastic_apm/transaction.rb +2 -2
  60. data/lib/elastic_apm/transport/base.rb +0 -6
  61. data/lib/elastic_apm/transport/connection.rb +1 -4
  62. data/lib/elastic_apm/transport/connection/http.rb +0 -2
  63. data/lib/elastic_apm/transport/filters.rb +1 -1
  64. data/lib/elastic_apm/transport/filters/secrets_filter.rb +1 -3
  65. data/lib/elastic_apm/transport/serializers.rb +0 -3
  66. data/lib/elastic_apm/transport/serializers/context_serializer.rb +0 -2
  67. data/lib/elastic_apm/transport/serializers/error_serializer.rb +0 -2
  68. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +0 -2
  69. data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +0 -2
  70. data/lib/elastic_apm/transport/serializers/span_serializer.rb +0 -3
  71. data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +0 -2
  72. data/lib/elastic_apm/transport/worker.rb +10 -6
  73. data/lib/elastic_apm/util.rb +1 -1
  74. data/lib/elastic_apm/version.rb +1 -1
  75. metadata +5 -5
  76. data/.ci/bin/check_paths_for_matches.py +0 -80
  77. data/.hound.yml +0 -2
@@ -85,7 +85,6 @@ module ElasticAPM
85
85
  format('[THREAD:%s]', Thread.current.object_id)
86
86
  end
87
87
 
88
- # rubocop:disable Metrics/MethodLength
89
88
  def open_request_in_thread(url)
90
89
  debug '%s: Opening new request', thread_str
91
90
  Thread.new do
@@ -104,7 +103,6 @@ module ElasticAPM
104
103
  end
105
104
  end
106
105
  end
107
- # rubocop:enable Metrics/MethodLength
108
106
 
109
107
  def build_client
110
108
  client = HTTP.headers(@headers)
@@ -19,7 +19,7 @@ module ElasticAPM
19
19
  end
20
20
 
21
21
  def add(key, filter)
22
- @filters[key] = filter
22
+ @filters = @filters.merge(key => filter)
23
23
  end
24
24
 
25
25
  def remove(key)
@@ -40,9 +40,8 @@ module ElasticAPM
40
40
  payload
41
41
  end
42
42
 
43
- # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
44
43
  def strip_from!(obj)
45
- return unless obj && obj.is_a?(Hash)
44
+ return unless obj&.is_a?(Hash)
46
45
 
47
46
  obj.each do |k, v|
48
47
  if filter_key?(k)
@@ -59,7 +58,6 @@ module ElasticAPM
59
58
  end
60
59
  end
61
60
  end
62
- # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
63
61
 
64
62
  def filter_key?(key)
65
63
  @key_filters.any? { |regex| key.match regex }
@@ -55,8 +55,6 @@ module ElasticAPM
55
55
  end
56
56
 
57
57
  attr_reader :transaction, :span, :error, :metadata, :metricset
58
-
59
- # rubocop:disable Metrics/MethodLength
60
58
  def serialize(resource)
61
59
  case resource
62
60
  when Transaction
@@ -73,7 +71,6 @@ module ElasticAPM
73
71
  raise UnrecognizedResource, resource.inspect
74
72
  end
75
73
  end
76
- # rubocop:enable Metrics/MethodLength
77
74
  end
78
75
 
79
76
  def self.new(config)
@@ -20,7 +20,6 @@ module ElasticAPM
20
20
 
21
21
  private
22
22
 
23
- # rubocop:disable Metrics/MethodLength
24
23
  def build_request(request)
25
24
  return unless request
26
25
 
@@ -35,7 +34,6 @@ module ElasticAPM
35
34
  url: build_url(request.url)
36
35
  }
37
36
  end
38
- # rubocop:enable Metrics/MethodLength
39
37
 
40
38
  def build_response(response)
41
39
  return unless response
@@ -9,7 +9,6 @@ module ElasticAPM
9
9
  @context_serializer ||= ContextSerializer.new(config)
10
10
  end
11
11
 
12
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
12
  def build(error)
14
13
  base = {
15
14
  id: error.id,
@@ -36,7 +35,6 @@ module ElasticAPM
36
35
 
37
36
  { error: base }
38
37
  end
39
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
40
38
 
41
39
  private
42
40
 
@@ -18,7 +18,6 @@ module ElasticAPM
18
18
 
19
19
  private
20
20
 
21
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
22
21
  def build_service(service)
23
22
  {
24
23
  name: keyword_field(service.name),
@@ -42,7 +41,6 @@ module ElasticAPM
42
41
  }
43
42
  }
44
43
  end
45
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
46
44
 
47
45
  def build_process(process)
48
46
  {
@@ -5,7 +5,6 @@ module ElasticAPM
5
5
  module Serializers
6
6
  # @api private
7
7
  class MetricsetSerializer < Serializer
8
- # rubocop:disable Metrics/MethodLength
9
8
  def build(metricset)
10
9
  payload = {
11
10
  timestamp: metricset.timestamp.to_i,
@@ -26,7 +25,6 @@ module ElasticAPM
26
25
 
27
26
  { metricset: payload }
28
27
  end
29
- # rubocop:enable Metrics/MethodLength
30
28
 
31
29
  private
32
30
 
@@ -12,8 +12,6 @@ module ElasticAPM
12
12
  end
13
13
 
14
14
  attr_reader :context_serializer
15
-
16
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
17
15
  def build(span)
18
16
  {
19
17
  span: {
@@ -30,7 +28,6 @@ module ElasticAPM
30
28
  }
31
29
  }
32
30
  end
33
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
34
31
 
35
32
  # @api private
36
33
  class ContextSerializer < Serializer
@@ -9,7 +9,6 @@ module ElasticAPM
9
9
  @context_serializer ||= ContextSerializer.new(config)
10
10
  end
11
11
 
12
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
12
  def build(transaction)
14
13
  {
15
14
  transaction: {
@@ -30,7 +29,6 @@ module ElasticAPM
30
29
  }
31
30
  }
32
31
  end
33
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
34
32
  end
35
33
  end
36
34
  end
@@ -6,6 +6,14 @@ module ElasticAPM
6
6
  class Worker
7
7
  include Logging
8
8
 
9
+ class << self
10
+ def adapter
11
+ @adapter ||= Connection
12
+ end
13
+
14
+ attr_writer :adapter
15
+ end
16
+
9
17
  # @api private
10
18
  class StopMessage; end
11
19
 
@@ -16,8 +24,7 @@ module ElasticAPM
16
24
  config,
17
25
  queue,
18
26
  serializers:,
19
- filters:,
20
- conn_adapter: Connection
27
+ filters:
21
28
  )
22
29
  @config = config
23
30
  @queue = queue
@@ -25,12 +32,10 @@ module ElasticAPM
25
32
  @serializers = serializers
26
33
  @filters = filters
27
34
 
28
- @connection = conn_adapter.new(config)
35
+ @connection = self.class.adapter.new(config)
29
36
  end
30
37
 
31
38
  attr_reader :queue, :filters, :name, :connection, :serializers
32
-
33
- # rubocop:disable Metrics/MethodLength
34
39
  def work_forever
35
40
  while (msg = queue.pop)
36
41
  case msg
@@ -46,7 +51,6 @@ module ElasticAPM
46
51
  warn 'Worker died with exception: %s', e.inspect
47
52
  debug e.backtrace.join("\n")
48
53
  end
49
- # rubocop:enable Metrics/MethodLength
50
54
 
51
55
  def process(resource)
52
56
  return unless (json = serialize_and_filter(resource))
@@ -14,7 +14,7 @@ module ElasticAPM
14
14
 
15
15
  def self.git_sha
16
16
  sha = `git rev-parse --verify HEAD 2>&1`.chomp
17
- $? && $?.success? ? sha : nil
17
+ $?&.success? ? sha : nil
18
18
  end
19
19
 
20
20
  def self.hex_to_bits(str)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ElasticAPM
4
- VERSION = '3.2.0'
4
+ VERSION = '3.3.0'
5
5
  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.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -51,7 +51,6 @@ files:
51
51
  - ".ci/.jenkins_master_framework.yml"
52
52
  - ".ci/.jenkins_ruby.yml"
53
53
  - ".ci/Jenkinsfile"
54
- - ".ci/bin/check_paths_for_matches.py"
55
54
  - ".ci/downstreamTests.groovy"
56
55
  - ".ci/jobs/apm-agent-ruby-downstream.yml"
57
56
  - ".ci/jobs/apm-agent-ruby-linting-mbp.yml"
@@ -60,8 +59,8 @@ files:
60
59
  - ".ci/jobs/defaults.yml"
61
60
  - ".ci/linting.groovy"
62
61
  - ".ci/prepare-git-context.sh"
62
+ - ".github/workflows/main.yml"
63
63
  - ".gitignore"
64
- - ".hound.yml"
65
64
  - ".pre-commit-config.yaml"
66
65
  - ".rspec"
67
66
  - ".rubocop.yml"
@@ -116,6 +115,7 @@ files:
116
115
  - lib/elastic_apm/config/duration.rb
117
116
  - lib/elastic_apm/config/options.rb
118
117
  - lib/elastic_apm/config/regexp_list.rb
118
+ - lib/elastic_apm/config/wildcard_pattern_list.rb
119
119
  - lib/elastic_apm/context.rb
120
120
  - lib/elastic_apm/context/request.rb
121
121
  - lib/elastic_apm/context/request/socket.rb
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []
230
- rubygems_version: 3.0.6
230
+ rubygems_version: 3.0.3
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: The official Elastic APM agent for Ruby
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Small wrapper script for jenkins to see if a regex pattern matches any of the
4
- paths generated by diffing between two commits.
5
- """
6
- import argparse
7
- import os
8
- import re
9
- import subprocess
10
- import sys
11
-
12
- debug = "DEBUG" in os.environ
13
-
14
-
15
- def check_paths_for_matches(pattern, git_commit, git_previous_commit):
16
- """Check if any paths between GIT_PREVIOUS_COMMIT and GIT_COMMIT match our pattern.
17
-
18
- For merge commits only actual path changes are included rather than changes
19
- from all parents. If GIT_PREVIOUS_COMMIT is not populated, use just the
20
- paths that GIT_COMMIT represents. If GIT_PREVIOUS_COMMIT is not populated
21
- and GIT_COMMIT is a merge commit, use all path changes from each parent. If
22
- GIT_PREVIOUS_COMMIT is the same as GIT_COMMIT, that should generate no path
23
- changes.
24
- """
25
- # Handle case where GIT_PREVIOUS_COMMIT isn't set (e.g. the first build),
26
- if not git_previous_commit:
27
- command = [
28
- "git",
29
- "diff-tree",
30
- "-m",
31
- "--no-commit-id",
32
- "--name-only",
33
- "-r",
34
- git_commit,
35
- ]
36
- else:
37
- command = ["git", "diff", "--name-only", git_previous_commit, git_commit]
38
-
39
- # Run the command and populate paths.
40
- completed_process = subprocess.run(
41
- command, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
42
- )
43
- paths = completed_process.stdout.decode().strip().split("\n")
44
-
45
- # Look for any matches of pattern -> path.
46
- possible_matches = [(path, pattern.match(path)) for path in paths]
47
- if any([match for path, match in possible_matches]):
48
- if debug:
49
- print("matching change(s) found for {}".format(git_commit))
50
- for path, match in possible_matches:
51
- if match:
52
- print(path)
53
- sys.stdout.write("match")
54
- sys.stdout.flush()
55
- exit(0)
56
- else:
57
- if debug:
58
- print("no matching change(s) found for {}".format(git_commit))
59
- exit(1)
60
-
61
-
62
- if __name__ == "__main__":
63
- # Change our working directory so we're in $WORKSPACE.
64
- os.chdir(os.path.dirname(os.path.abspath(__file__)))
65
-
66
- # Define and parse arguments.
67
- parser = argparse.ArgumentParser()
68
- parser.add_argument("--pattern", help="A regular expression pattern.")
69
- parser.add_argument(
70
- "--git-commit", help="The contents of the GIT_COMMIT environmental variable."
71
- )
72
- parser.add_argument(
73
- "--git-previous-commit",
74
- nargs="?",
75
- help="The contents of the GIT_PREVIOUS_COMMIT environmental variable.",
76
- )
77
- args = parser.parse_args()
78
-
79
- compiled_pattern = re.compile(args.pattern)
80
- check_paths_for_matches(compiled_pattern, args.git_commit, args.git_previous_commit)
data/.hound.yml DELETED
@@ -1,2 +0,0 @@
1
- ruby:
2
- config_file: .rubocop.yml