newrelic_rpm 9.2.2 → 9.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +26 -0
  3. data/CHANGELOG.md +70 -0
  4. data/README.md +4 -4
  5. data/lib/new_relic/agent/configuration/default_source.rb +77 -29
  6. data/lib/new_relic/agent/configuration/manager.rb +3 -2
  7. data/lib/new_relic/agent/configuration/yaml_source.rb +13 -0
  8. data/lib/new_relic/agent/distributed_tracing.rb +1 -1
  9. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
  10. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +2 -1
  11. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
  12. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +1 -2
  13. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
  14. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +10 -3
  15. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +1 -2
  16. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +10 -3
  17. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
  18. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +1 -1
  19. data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +0 -1
  21. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
  22. data/lib/new_relic/agent/log_event_aggregator.rb +49 -2
  23. data/lib/new_relic/agent/log_event_attributes.rb +115 -0
  24. data/lib/new_relic/agent/logging.rb +4 -4
  25. data/lib/new_relic/agent/method_tracer_helpers.rb +26 -5
  26. data/lib/new_relic/agent/tracer.rb +2 -2
  27. data/lib/new_relic/agent.rb +38 -1
  28. data/lib/new_relic/cli/command.rb +1 -0
  29. data/lib/new_relic/dependency_detection.rb +6 -0
  30. data/lib/new_relic/latest_changes.rb +1 -1
  31. data/lib/new_relic/rack/browser_monitoring.rb +1 -1
  32. data/lib/new_relic/supportability_helper.rb +1 -0
  33. data/lib/new_relic/traced_thread.rb +2 -3
  34. data/lib/new_relic/version.rb +2 -2
  35. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  36. data/lib/tasks/bump_version.rake +21 -0
  37. data/lib/tasks/helpers/newrelicyml.rb +144 -0
  38. data/lib/tasks/helpers/version_bump.rb +62 -0
  39. data/lib/tasks/newrelicyml.rake +13 -0
  40. data/newrelic.yml +307 -266
  41. data/newrelic_rpm.gemspec +10 -7
  42. metadata +13 -25
  43. data/.gitignore +0 -43
  44. data/.project +0 -23
  45. data/.rubocop.yml +0 -1845
  46. data/.rubocop_todo.yml +0 -61
  47. data/.simplecov +0 -16
  48. data/.snyk +0 -11
  49. data/.yardopts +0 -27
  50. data/Brewfile +0 -13
  51. data/DOCKER.md +0 -167
  52. data/Dockerfile +0 -10
  53. data/Guardfile +0 -27
  54. data/config/database.yml +0 -5
  55. data/config.dot +0 -278
  56. data/docker-compose.yml +0 -107
  57. data/lefthook.yml +0 -9
  58. data/lib/tasks/helpers/removers.rb +0 -33
  59. data/lib/tasks/multiverse.rake +0 -6
  60. data/lib/tasks/multiverse.rb +0 -84
@@ -0,0 +1,144 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ require_relative '../../new_relic/agent/configuration/default_source'
6
+
7
+ module NewRelicYML
8
+ CRITICAL = [:'agent_enabled', :'app_name', :'license_key', :'log_level']
9
+ DEFAULTS = NewRelic::Agent::Configuration::DEFAULTS
10
+ # Skip because not configurable via yml
11
+ SKIP = [:'defer_rails_initialization']
12
+ # Don't evaluate Procs, instead use set values
13
+ PROCS = {:'config_path' => 'newrelic.yml',
14
+ :'process_host.display_name' => 'default hostname',
15
+ :'transaction_tracer.transaction_threshold' => 1.0}
16
+
17
+ HEADER = <<~HEADER
18
+ #
19
+ # This file configures the New Relic Agent. New Relic monitors Ruby, Java,
20
+ # .NET, PHP, Python, Node, and Go applications with deep visibility and low
21
+ # overhead. For more information, visit www.newrelic.com.
22
+
23
+ # Generated <%= Time.now.strftime('%B %d, %Y') %><%= ", for version \#{@agent_version}" if @agent_version %>
24
+ #<%= "\\n# \#{generated_for_user}\\n#" if generated_for_user %>
25
+ # For full documentation of agent configuration options, please refer to
26
+ # https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
27
+
28
+ common: &default_settings
29
+ # Required license key associated with your New Relic account.
30
+ license_key: <%= license_key %>
31
+
32
+ # Your application name. Renaming here affects where data displays in New
33
+ # Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
34
+ app_name: <%= app_name %>
35
+
36
+ # To disable the agent regardless of other settings, uncomment the following:
37
+ # agent_enabled: false
38
+
39
+ # Logging level for log/newrelic_agent.log; options are error, warn, info, or
40
+ # debug.
41
+ log_level: info
42
+
43
+ # All of the following configuration options are optional. Review them, and
44
+ # uncomment or edit them if they appear relevant to your application needs.
45
+
46
+ HEADER
47
+
48
+ FOOTER = <<~FOOTER
49
+ # Environment-specific settings are in this section.
50
+ # RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
51
+ # If your application has other named environments, configure them here.
52
+ development:
53
+ <<: *default_settings
54
+ app_name: <%= app_name %> (Development)
55
+
56
+ test:
57
+ <<: *default_settings
58
+ # It doesn't make sense to report to New Relic from automated test runs.
59
+ monitor_mode: false
60
+
61
+ staging:
62
+ <<: *default_settings
63
+ app_name: <%= app_name %> (Staging)
64
+
65
+ production:
66
+ <<: *default_settings
67
+ FOOTER
68
+
69
+ def self.get_configs(defaults)
70
+ defaults.sort.each_with_object({}) do |(key, value), final_configs|
71
+ next if CRITICAL.include?(key) || SKIP.include?(key)
72
+
73
+ next unless public_config?(value) && !deprecated?(value)
74
+
75
+ sanitized_description = sanitize_description(value[:description])
76
+ description = format_description(sanitized_description)
77
+ default = default_value(key, value)
78
+ final_configs[key] = {description: description, default: default}
79
+ end
80
+ end
81
+
82
+ def self.public_config?(value)
83
+ value[:public] == true
84
+ end
85
+
86
+ def self.deprecated?(value)
87
+ value[:deprecated] == true
88
+ end
89
+
90
+ def self.sanitize_description(description)
91
+ # remove callouts
92
+ description = description.split("\n").reject { |line| line.match?('</?Callout') }.join("\n")
93
+ # remove InlinePopover, keep the text inside type
94
+ description.gsub!(/<InlinePopover type="(.*)" \/>/, '\1')
95
+ # remove hyperlinks
96
+ description.gsub!(/\[([^\]]+)\]\([^\)]+\)/, '\1')
97
+ # remove single pairs of backticks
98
+ description.gsub!(/`([^`]+)`/, '\1')
99
+ # removed href links
100
+ description.gsub!(/<a href="(.*)">(.*)<\/a>/, '\2')
101
+
102
+ description
103
+ end
104
+
105
+ def self.format_description(description)
106
+ # remove leading and trailing whitespace
107
+ description.strip!
108
+ # wrap text after 80 characters
109
+ description.gsub!(/(.{1,80})(\s+|\Z)/, "\\1\n")
110
+ # add hashtags to lines
111
+ description = description.split("\n").map { |line| " # #{line}" }.join("\n")
112
+
113
+ description
114
+ end
115
+
116
+ def self.default_value(key, config_hash)
117
+ if PROCS.include?(key)
118
+ PROCS[key]
119
+ else
120
+ default = config_hash[:documentation_default].nil? ? config_hash[:default] : config_hash[:documentation_default]
121
+ default = 'nil' if default.nil?
122
+ default = '""' if default == ''
123
+
124
+ default
125
+ end
126
+ end
127
+
128
+ def self.build_string(defaults)
129
+ configs = get_configs(defaults)
130
+ yml_string = ''
131
+
132
+ configs.each do |key, value|
133
+ yml_string += "#{value[:description]}\n # #{key}: #{value[:default]}\n\n"
134
+ end
135
+
136
+ yml_string
137
+ end
138
+
139
+ # :nocov:
140
+ def self.write_file(defaults = DEFAULTS)
141
+ File.write('newrelic.yml', HEADER + build_string(defaults) + FOOTER)
142
+ end
143
+ # :nocov:
144
+ end
@@ -0,0 +1,62 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module VersionBump
6
+ MAJOR = 0
7
+ MINOR = 1
8
+ TINY = 2
9
+ VERSION = {major: MAJOR, minor: MINOR, tiny: TINY}
10
+
11
+ # Updates version.rb with new version number
12
+ def self.update_version
13
+ bump_type = determine_bump_type
14
+ file = read_file('lib/new_relic/version.rb')
15
+ new_version = {}
16
+
17
+ VERSION.each do |key, current|
18
+ file.gsub!(/(#{key.to_s.upcase} = )(\d+)/) do
19
+ match = Regexp.last_match
20
+
21
+ new_version[key] = if bump_type == current # bump type, increase by 1
22
+ match[2].to_i + 1
23
+ elsif bump_type < current # right of bump type, goes to 0
24
+ 0
25
+ else # left of bump type, stays the same
26
+ match[2].to_i
27
+ end
28
+
29
+ match[1] + new_version[key].to_s
30
+ end
31
+ end
32
+
33
+ write_file('lib/new_relic/version.rb', file)
34
+ new_version.values.join('.')
35
+ end
36
+
37
+ def self.read_file(path)
38
+ File.read(File.expand_path(path))
39
+ end
40
+
41
+ def self.write_file(path, file)
42
+ File.write(File.expand_path(path), file)
43
+ end
44
+
45
+ # Determined version based on if changelog has a feature or not for version
46
+ def self.determine_bump_type
47
+ file = read_file('CHANGELOG.md')
48
+ lines = file.split('## ')[1].split('- **')
49
+ return MAJOR if lines.first.include?('Major version')
50
+ return MINOR if lines.any? { |line| line.include?('Feature:') }
51
+
52
+ TINY
53
+ end
54
+
55
+ # Replace dev with version number in changelog
56
+ def self.update_changelog(version)
57
+ file = read_file('CHANGELOG.md')
58
+ file.gsub!(/## dev/, "## v#{version}")
59
+ file.gsub!(/Version <dev>/, "Version #{version}")
60
+ write_file('CHANGELOG.md', file)
61
+ end
62
+ end
@@ -0,0 +1,13 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ require_relative './helpers/newrelicyml'
6
+
7
+ namespace :newrelic do
8
+ desc 'Update newrelic.yml with latest config options from default_source.rb'
9
+ task :update_newrelicyml do
10
+ NewRelicYML.write_file
11
+ puts 'newrelic.yml updated'
12
+ end
13
+ end