newrelic_rpm 3.9.3.241 → 3.9.4.245

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG +29 -0
  4. data/Rakefile +41 -0
  5. data/cert/cacert.pem +1176 -117
  6. data/lib/new_relic/agent/agent_logger.rb +14 -0
  7. data/lib/new_relic/agent/configuration/default_source.rb +88 -86
  8. data/lib/new_relic/agent/configuration/environment_source.rb +5 -1
  9. data/lib/new_relic/agent/configuration/high_security_source.rb +3 -1
  10. data/lib/new_relic/agent/configuration/yaml_source.rb +3 -3
  11. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +4 -0
  12. data/lib/new_relic/agent/method_tracer.rb +17 -2
  13. data/lib/new_relic/agent/new_relic_service.rb +21 -19
  14. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +8 -2
  15. data/lib/new_relic/agent/request_sampler.rb +9 -11
  16. data/lib/new_relic/version.rb +1 -1
  17. data/lib/tasks/config.html.erb +2 -2
  18. data/lib/tasks/config.rake +6 -6
  19. data/test/environments/lib/environments/runner.rb +4 -4
  20. data/test/environments/rails42/Gemfile +35 -0
  21. data/test/environments/rails42/Rakefile +11 -0
  22. data/test/environments/rails42/config/application.rb +18 -0
  23. data/test/environments/rails42/config/boot.rb +10 -0
  24. data/test/environments/rails42/config/database.yml +26 -0
  25. data/test/environments/rails42/config/environment.rb +6 -0
  26. data/test/environments/rails42/db/schema.rb +5 -0
  27. data/test/fixtures/cross_agent_tests/README.md +40 -1
  28. data/test/fixtures/cross_agent_tests/cat_map.json +305 -73
  29. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/README.md +4 -0
  30. data/test/fixtures/cross_agent_tests/sql_obfuscation/{end_of_line_comments_with_quotes.obfuscated → pathological/end_of_line_comments_with_quotes.obfuscated} +0 -0
  31. data/test/fixtures/cross_agent_tests/sql_obfuscation/{end_of_line_comments_with_quotes.sql → pathological/end_of_line_comments_with_quotes.sql} +0 -0
  32. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_comments_and_quotes.obfuscated → pathological/mixed_comments_and_quotes.obfuscated} +0 -0
  33. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_comments_and_quotes.sql → pathological/mixed_comments_and_quotes.sql} +0 -0
  34. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_comments_and_newlines.obfuscated → pathological/mixed_quotes_comments_and_newlines.obfuscated} +0 -0
  35. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_comments_and_newlines.sql → pathological/mixed_quotes_comments_and_newlines.sql} +0 -0
  36. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_end_of_line_comments.obfuscated → pathological/mixed_quotes_end_of_line_comments.obfuscated} +0 -0
  37. data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_end_of_line_comments.sql → pathological/mixed_quotes_end_of_line_comments.sql} +0 -0
  38. data/test/fixtures/cross_agent_tests/sql_obfuscation/{quote_delimiters_in_comments.obfuscated → pathological/quote_delimiters_in_comments.obfuscated} +0 -0
  39. data/test/fixtures/cross_agent_tests/sql_obfuscation/{quote_delimiters_in_comments.sql → pathological/quote_delimiters_in_comments.sql} +0 -0
  40. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +9 -4
  41. data/test/multiverse/suites/rails/Envfile +6 -0
  42. data/test/multiverse/suites/rails/ignore_test.rb +7 -7
  43. data/test/multiverse/suites/rails/view_instrumentation_test.rb +13 -13
  44. data/test/new_relic/agent/configuration/environment_source_test.rb +8 -0
  45. data/test/new_relic/agent/configuration/yaml_source_test.rb +1 -1
  46. data/test/new_relic/agent/database/sql_obfuscation_test.rb +17 -8
  47. data/test/new_relic/agent/instrumentation/active_record_test.rb +50 -7
  48. data/test/new_relic/agent/new_relic_service_test.rb +17 -4
  49. data/test/new_relic/http_client_test_cases.rb +15 -5
  50. data/test/performance/lib/performance.rb +8 -0
  51. data/test/performance/lib/performance/baseline.rb +36 -0
  52. data/test/performance/lib/performance/baseline_compare_reporter.rb +82 -0
  53. data/test/performance/lib/performance/baseline_save_reporter.rb +24 -0
  54. data/test/performance/lib/performance/console_reporter.rb +7 -20
  55. data/test/performance/lib/performance/reporting.rb +36 -0
  56. data/test/performance/lib/performance/table.rb +105 -0
  57. data/test/performance/script/runner +26 -20
  58. data/test/performance/suites/marshalling.rb +12 -12
  59. data/test/script/path_hash.rb +1 -1
  60. metadata +25 -25
  61. metadata.gz.sig +0 -0
  62. data/cert/oldsite.pem +0 -28
  63. data/cert/site.pem +0 -27
  64. data/test/flaky_proxy/Gemfile +0 -3
  65. data/test/flaky_proxy/README.md +0 -140
  66. data/test/flaky_proxy/lib/flaky_proxy.rb +0 -23
  67. data/test/flaky_proxy/lib/flaky_proxy/connection.rb +0 -45
  68. data/test/flaky_proxy/lib/flaky_proxy/http_message.rb +0 -107
  69. data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +0 -58
  70. data/test/flaky_proxy/lib/flaky_proxy/rule.rb +0 -72
  71. data/test/flaky_proxy/lib/flaky_proxy/rule_set.rb +0 -45
  72. data/test/flaky_proxy/lib/flaky_proxy/sequence.rb +0 -14
  73. data/test/flaky_proxy/lib/flaky_proxy/server.rb +0 -22
  74. data/test/flaky_proxy/script/flaky_proxy +0 -39
@@ -12,11 +12,19 @@ require 'performance/runner'
12
12
  require 'performance/test_case'
13
13
  require 'performance/timer'
14
14
  require 'performance/instrumentor'
15
+
16
+ require 'performance/reporting'
17
+ require 'performance/table'
15
18
  require 'performance/console_reporter'
16
19
  require 'performance/json_reporter'
20
+
17
21
  require 'performance/hako_client'
18
22
  require 'performance/hako_reporter'
19
23
 
24
+ require 'performance/baseline'
25
+ require 'performance/baseline_save_reporter'
26
+ require 'performance/baseline_compare_reporter'
27
+
20
28
  module Performance
21
29
  def self.logger
22
30
  log_path = ENV['LOG'] || $stderr
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module Performance
6
+ class Baseline
7
+ PERSIST_PATH = File.expand_path("~/.newrelic_rpm_baseline")
8
+
9
+ attr_reader :results
10
+
11
+ def self.load!
12
+ self.new.load!
13
+ end
14
+
15
+ def self.save!(results)
16
+ baseline = self.new
17
+ results.each { |r| baseline.results << r }
18
+ baseline.save!
19
+ end
20
+
21
+ def initialize
22
+ @results = []
23
+ end
24
+
25
+ def load!
26
+ result_hashes = JSON.parse(File.read(PERSIST_PATH))
27
+ @results = result_hashes.map { |h| Result.from_hash(h) }
28
+ end
29
+
30
+ def save!
31
+ File.open(PERSIST_PATH, "w") do |f|
32
+ f.write(JSON.dump(@results.map(&:to_h)))
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module Performance
6
+ class BaselineCompareReporter
7
+ include Reporting
8
+
9
+ def initialize(results, elapsed, options={})
10
+ @results = results
11
+ @elapsed = elapsed
12
+ @options = options
13
+ end
14
+
15
+ def report
16
+ report_summary
17
+
18
+ begin
19
+ baseline = Baseline.load!
20
+ rescue => e
21
+ puts "Failed to load baseline results: #{e}\n#{e.backtrace.join("\n\t")}"
22
+ return
23
+ end
24
+
25
+ report_successful_results(baseline, successes) unless successes.empty?
26
+ report_failed_results
27
+ end
28
+
29
+ def report_successful_results(baseline, results)
30
+ baseline_identifiers = baseline.map(&:identifier)
31
+ new_identifiers = results.map(&:identifier)
32
+ missing_from_baseline = new_identifiers - baseline_identifiers
33
+ missing_from_new = baseline_identifiers - new_identifiers
34
+ common_identifiers = new_identifiers & baseline_identifiers
35
+
36
+ if !missing_from_baseline.empty?
37
+ puts "The following tests were not found in the baseline results:\n"
38
+ missing_from_baseline.each do |identifier|
39
+ puts " #{identifier}"
40
+ end
41
+ puts ""
42
+ end
43
+
44
+ if !missing_from_baseline.empty?
45
+ puts "The following tests were not found in the new results:\n"
46
+ missing_from_new.each do |identifier|
47
+ puts " #{identifier}"
48
+ end
49
+ puts ""
50
+ end
51
+
52
+ rows = []
53
+
54
+ common_identifiers.each do |identifier|
55
+ old_result = baseline.find { |r| r.identifier == identifier}
56
+ new_result = results.find { |r| r.identifier == identifier }
57
+
58
+ delta = new_result.elapsed - old_result.elapsed
59
+ percent_delta = delta / old_result.elapsed * 100.0
60
+
61
+ rows << [
62
+ identifier,
63
+ old_result.elapsed,
64
+ new_result.elapsed,
65
+ percent_delta
66
+ ]
67
+ end
68
+
69
+ table = Table.new(rows) do
70
+ column :name
71
+ column :before, "%.2f s"
72
+ column :after, "%.2f s"
73
+ column :delta do |v|
74
+ prefix = v > 0 ? "+" : ''
75
+ sprintf("#{prefix}%.1f%%", v)
76
+ end
77
+ end
78
+
79
+ puts table.render
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module Performance
6
+ class BaselineSaveReporter
7
+ include Reporting
8
+
9
+ def initialize(results, elapsed, options={})
10
+ @results = results
11
+ @elapsed = elapsed
12
+ @options = options
13
+ end
14
+
15
+ def report
16
+ report_summary
17
+
18
+ Baseline.save!(successes)
19
+ puts "Saved #{successes.size} results as baseline."
20
+
21
+ report_failed_results
22
+ end
23
+ end
24
+ end
@@ -4,6 +4,8 @@
4
4
 
5
5
  module Performance
6
6
  class ConsoleReporter
7
+ include Reporting
8
+
7
9
  def initialize(results, elapsed, options={})
8
10
  @results = results
9
11
  @elapsed = elapsed
@@ -11,14 +13,14 @@ module Performance
11
13
  end
12
14
 
13
15
  def report
14
- failures = @results.select { |result| result.failure? }
15
- successes = @results - failures
16
- puts "#{@results.size} tests, #{failures.size} failures, #{@elapsed} s total"
17
- report_successful_results(successes) if successes.any?
18
- report_failed_results(failures) if failures.any?
16
+ report_summary
17
+ report_successful_results(successes) unless successes.empty?
18
+ report_failed_results
19
19
  end
20
20
 
21
21
  def report_successful_results(results)
22
+ return if successes.empty?
23
+
22
24
  puts ''
23
25
  results.each do |result|
24
26
  puts "#{result.identifier}: #{result.elapsed} s"
@@ -36,20 +38,5 @@ module Performance
36
38
  puts '' if !@options[:brief] || !result.artifacts.empty?
37
39
  end
38
40
  end
39
-
40
- def report_failed_results(results)
41
- puts ''
42
- results.each do |failure|
43
- puts "FAILED: #{failure.identifier}"
44
- e = failure.exception
45
- if e
46
- puts "#{e['class']}: #{e['message']}"
47
- puts failure.exception['backtrace'].map { |l| " #{l}" }.join("\n")
48
- else
49
- puts "<No exception recorded>"
50
- end
51
- end
52
- puts ''
53
- end
54
41
  end
55
42
  end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module Performance
6
+ module Reporting
7
+ def failures
8
+ @failures ||= @results.select(&:failure?)
9
+ end
10
+
11
+ def successes
12
+ @successes ||= @results.reject(&:failure?)
13
+ end
14
+
15
+ def report_summary
16
+ puts "#{@results.size} tests, #{failures.size} failures, #{@elapsed} s total"
17
+ end
18
+
19
+ def report_failed_results
20
+ return if failures.empty?
21
+
22
+ puts ''
23
+ failures.each do |failure|
24
+ puts "FAILED: #{failure.identifier}"
25
+ e = failure.exception
26
+ if e
27
+ puts "#{e['class']}: #{e['message']}"
28
+ puts failure.exception['backtrace'].map { |l| " #{l}" }.join("\n")
29
+ else
30
+ puts "<No exception recorded>"
31
+ end
32
+ end
33
+ puts ''
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module Performance
6
+ class Table
7
+ class Formatter
8
+ attr_reader :name
9
+
10
+ def initialize(name, format_string=nil, &blk)
11
+ @name = name
12
+ @format_string = format_string
13
+ @format_proc = blk
14
+ end
15
+
16
+ def measure(value)
17
+ format(value).size
18
+ end
19
+
20
+ def format(value, width=nil)
21
+ formatted = if @format_string
22
+ sprintf(@format_string, value)
23
+ elsif @format_proc
24
+ @format_proc.call(value)
25
+ else
26
+ value.to_s
27
+ end
28
+
29
+ formatted = justify(value, formatted, width) if width
30
+ formatted
31
+ end
32
+
33
+ def justify(value, formatted, width)
34
+ case value
35
+ when Numeric then formatted.rjust(width)
36
+ else formatted.ljust(width)
37
+ end
38
+ end
39
+ end
40
+
41
+ class Builder
42
+ attr_reader :formatters
43
+
44
+ def initialize
45
+ @formatters = []
46
+ end
47
+
48
+ def column(name, format_string=nil, &blk)
49
+ @formatters << Formatter.new(name, format_string, &blk)
50
+ end
51
+ end
52
+
53
+ def initialize(rows, &blk)
54
+ @rows = rows
55
+
56
+ builder = Builder.new
57
+ builder.instance_eval(&blk)
58
+ @schema = builder.formatters
59
+ end
60
+
61
+ def column_widths
62
+ widths = Array.new(@schema.size, 0)
63
+ @schema.each_with_index do |col, idx|
64
+ widths[idx] = col.name.size
65
+ end
66
+ @rows.each do |row|
67
+ row.each_with_index do |cell, idx|
68
+ width = @schema[idx].measure(cell)
69
+ widths[idx] = [widths[idx], width].max
70
+ end
71
+ end
72
+ widths
73
+ end
74
+
75
+ def render_row(parts)
76
+ "| " + parts.join(" | ") + " |"
77
+ end
78
+
79
+ def render
80
+ widths = column_widths
81
+
82
+ blanks = widths.map { |w| "-" * w }
83
+ top = '+-' + blanks.join('-+-') + '-+'
84
+ separator = '|-' + blanks.join('-+-') + '-|'
85
+ bottom = '+-' + blanks.join('-+-') + '-+'
86
+
87
+ text_rows = []
88
+
89
+ headers = @schema.zip(widths).map { |(c, w)| c.name.to_s.ljust(w) }
90
+ text_rows << render_row(headers)
91
+
92
+ @rows.each do |row|
93
+ parts = []
94
+ row.each_with_index do |v, i|
95
+ parts << @schema[i].format(v, widths[i])
96
+ end
97
+ text_rows << render_row(parts)
98
+ end
99
+
100
+ puts top + "\n"
101
+ puts text_rows.join("\n" + separator + "\n")
102
+ puts bottom + "\n"
103
+ end
104
+ end
105
+ end
@@ -16,12 +16,6 @@ options = {}
16
16
  parser = OptionParser.new do |opts|
17
17
  opts.banner = "Usage: #{$0} [options]"
18
18
 
19
- opts.on("-p", "--progress", "Print out test names as they run") do |p|
20
- options[:progress] = true
21
- end
22
- opts.on("-i", "--instrumentor=NAME", "Use the named instrumentor") do |name|
23
- options[:instrumentors] = [name]
24
- end
25
19
  opts.on("-P", "--profile", "Do profiling around each test") do
26
20
  best_profiling_instrumentor = [
27
21
  Performance::Instrumentation::StackProfProfile,
@@ -35,46 +29,68 @@ parser = OptionParser.new do |opts|
35
29
  Performance.logger.warn("Could not find a supported instrumentor for profiling.")
36
30
  end
37
31
  end
32
+
38
33
  opts.on("-s", "--suite=NAME", "Filter to just run a single test suite") do |name|
39
34
  options[:suite] = name
40
35
  end
36
+
41
37
  opts.on("-n", "--name=NAME", "Filter tests to those matching NAME") do |name|
42
38
  options[:name] = name
43
39
  end
40
+
41
+ opts.on("-B", "--baseline", "Save results as a baseline") do |b|
42
+ options[:reporter_classes] = ['BaselineSaveReporter']
43
+ end
44
+
45
+ opts.on("-C", "--compare", "Compare results to a saved baseline") do |c|
46
+ options[:reporter_classes] = ['BaselineCompareReporter']
47
+ end
48
+
44
49
  opts.on("-N", "--iterations=NUM", "Change the number of iterations for each test") do |iterations|
45
50
  options[:iterations] = iterations.to_i
46
51
  end
52
+
47
53
  opts.on("-I", "--inline", "Run tests inline - do not isolate each test into a sub-invocation") do |i|
48
54
  options[:inline] = true
49
55
  end
56
+
50
57
  opts.on("-j", "--json", "Produce JSON output") do |q|
51
58
  options[:reporter_classes] = ['JSONReporter']
52
59
  end
60
+
53
61
  opts.on("-R", "--reporters=NAMES", "Use the specified reporters (comma-separated list of class names)") do |reporter_names|
54
62
  reporter_names = reporter_names.split(',')
55
63
  options[:reporter_classes] = reporter_names
56
64
  end
65
+
57
66
  opts.on("-r", "--randomize", "Randomize test order") do |r|
58
67
  options[:randomize] = r
59
68
  end
69
+
60
70
  opts.on("-b", "--brief", "Don't print out details for each test, just the elapsed time") do |b|
61
71
  options[:brief] = b
62
72
  end
73
+
63
74
  opts.on("-T", "--test=NAME", "Run one specific test, identified by <suite name>#<test_name>") do |identifier|
64
75
  options[:identifier] = identifier
65
76
  end
77
+
78
+ opts.on("-i", "--instrumentor=NAME", "Use the named instrumentor") do |name|
79
+ options[:instrumentors] = [name]
80
+ end
81
+
66
82
  opts.on("-q", "--quiet", "Disable diagnostic logging") do
67
83
  Performance.log_path = "/dev/null"
68
84
  end
85
+
69
86
  opts.on("-L", "--log=PATH", "Log diagnostic information to PATH") do |log_path|
70
87
  Performance.log_path = log_path
71
88
  end
89
+
72
90
  opts.on("-A", "--agent=PATH", "Run tests against the copy of the agent at PATH") do |path|
73
91
  options[:agent_path] = path
74
92
  end
75
- opts.on("-c", "--compare=VERSIONS", "Run tests against the specified VERSIONS of the agent. Use with -A") do |versions|
76
- target_versions = versions.split(',')
77
- end
93
+
78
94
  opts.on("-m", "--metadata=METADATA", "Attach metadata to the run. Format: 'key:value'. May be specified multiple times.") do |tag_string|
79
95
  key, value = tag_string.split(":", 2)
80
96
  options[:tags] ||= {}
@@ -84,14 +100,4 @@ end
84
100
  parser.parse!
85
101
 
86
102
  runner = Performance::Runner.new(options)
87
-
88
- if target_versions
89
- target_versions.each do |version|
90
- Performance.logger.info("Running tests against version #{version}")
91
- cmd = "cd #{options[:agent_path]} && git checkout #{version}"
92
- system(cmd)
93
- runner.run_and_report
94
- end
95
- else
96
- runner.run_and_report
97
- end
103
+ runner.run_and_report