newrelic_rpm 9.12.0 → 9.17.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 (114) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +217 -1
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +16 -20
  5. data/lib/boot/strap.rb +4 -3
  6. data/lib/new_relic/agent/agent.rb +4 -0
  7. data/lib/new_relic/agent/agent_helpers/connect.rb +3 -0
  8. data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -0
  9. data/lib/new_relic/agent/agent_helpers/shutdown.rb +3 -0
  10. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -0
  11. data/lib/new_relic/agent/agent_helpers/startup.rb +7 -0
  12. data/lib/new_relic/agent/aws.rb +6 -0
  13. data/lib/new_relic/agent/configuration/default_source.rb +363 -31
  14. data/lib/new_relic/agent/configuration/environment_source.rb +5 -1
  15. data/lib/new_relic/agent/configuration/manager.rb +23 -0
  16. data/lib/new_relic/agent/configuration/yaml_source.rb +6 -1
  17. data/lib/new_relic/agent/database/obfuscation_helpers.rb +11 -11
  18. data/lib/new_relic/agent/database.rb +41 -1
  19. data/lib/new_relic/agent/distributed_tracing.rb +2 -2
  20. data/lib/new_relic/agent/health_check.rb +136 -0
  21. data/lib/new_relic/agent/instrumentation/active_merchant.rb +0 -13
  22. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -8
  23. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +5 -1
  24. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +9 -16
  25. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +0 -2
  26. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +0 -2
  27. data/lib/new_relic/agent/instrumentation/async_http.rb +1 -2
  28. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/chain.rb +21 -0
  29. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/instrumentation.rb +66 -0
  30. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/prepend.rb +15 -0
  31. data/lib/new_relic/agent/instrumentation/aws_sdk_firehose.rb +22 -0
  32. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/chain.rb +21 -0
  33. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +91 -0
  34. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/prepend.rb +15 -0
  35. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis.rb +22 -0
  36. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
  37. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
  38. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
  39. data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
  40. data/lib/new_relic/agent/instrumentation/aws_sqs.rb +0 -2
  41. data/lib/new_relic/agent/instrumentation/bunny.rb +3 -4
  42. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +0 -2
  43. data/lib/new_relic/agent/instrumentation/curb.rb +3 -4
  44. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -23
  45. data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +1 -1
  46. data/lib/new_relic/agent/instrumentation/dynamodb.rb +0 -2
  47. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +0 -2
  48. data/lib/new_relic/agent/instrumentation/ethon.rb +0 -4
  49. data/lib/new_relic/agent/instrumentation/excon.rb +0 -16
  50. data/lib/new_relic/agent/instrumentation/fiber.rb +0 -2
  51. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +0 -3
  52. data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
  53. data/lib/new_relic/agent/instrumentation/httpclient.rb +0 -1
  54. data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
  55. data/lib/new_relic/agent/instrumentation/httpx.rb +0 -4
  56. data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
  57. data/lib/new_relic/agent/instrumentation/logstasher.rb +0 -2
  58. data/lib/new_relic/agent/instrumentation/memcache.rb +0 -1
  59. data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
  60. data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
  61. data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
  62. data/lib/new_relic/agent/instrumentation/opensearch.rb +23 -0
  63. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  64. data/lib/new_relic/agent/instrumentation/rake.rb +0 -1
  65. data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +72 -0
  66. data/lib/new_relic/agent/instrumentation/rdkafka/instrumentation.rb +70 -0
  67. data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +67 -0
  68. data/lib/new_relic/agent/instrumentation/rdkafka.rb +25 -0
  69. data/lib/new_relic/agent/instrumentation/redis.rb +7 -6
  70. data/lib/new_relic/agent/instrumentation/resque.rb +7 -5
  71. data/lib/new_relic/agent/instrumentation/roda.rb +4 -4
  72. data/lib/new_relic/agent/instrumentation/ruby_kafka/chain.rb +55 -0
  73. data/lib/new_relic/agent/instrumentation/ruby_kafka/instrumentation.rb +67 -0
  74. data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +60 -0
  75. data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +25 -0
  76. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  77. data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -14
  78. data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -19
  79. data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
  80. data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
  81. data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
  82. data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +11 -5
  83. data/lib/new_relic/agent/instrumentation/view_component.rb +0 -2
  84. data/lib/new_relic/agent/javascript_instrumentor.rb +2 -3
  85. data/lib/new_relic/agent/local_log_decorator.rb +12 -2
  86. data/lib/new_relic/agent/log_event_aggregator.rb +28 -2
  87. data/lib/new_relic/agent/messaging.rb +11 -5
  88. data/lib/new_relic/agent/new_relic_service.rb +8 -2
  89. data/lib/new_relic/agent/serverless_handler.rb +241 -12
  90. data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
  91. data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
  92. data/lib/new_relic/agent/span_event_primitive.rb +4 -2
  93. data/lib/new_relic/agent/system_info.rb +14 -0
  94. data/lib/new_relic/agent/threading/backtrace_node.rb +10 -1
  95. data/lib/new_relic/agent/transaction/message_broker_segment.rb +3 -0
  96. data/lib/new_relic/agent/transaction/request_attributes.rb +13 -1
  97. data/lib/new_relic/agent/transaction/trace_context.rb +1 -1
  98. data/lib/new_relic/agent.rb +95 -2
  99. data/lib/new_relic/control/frameworks/grape.rb +14 -0
  100. data/lib/new_relic/control/frameworks/padrino.rb +14 -0
  101. data/lib/new_relic/control/frameworks/rails4.rb +1 -3
  102. data/lib/new_relic/dependency_detection.rb +11 -13
  103. data/lib/new_relic/environment_report.rb +2 -2
  104. data/lib/new_relic/helper.rb +15 -0
  105. data/lib/new_relic/language_support.rb +3 -1
  106. data/lib/new_relic/local_environment.rb +1 -4
  107. data/lib/new_relic/version.rb +1 -1
  108. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  109. data/lib/tasks/helpers/newrelicyml.rb +73 -11
  110. data/lib/tasks/instrumentation_generator/instrumentation.thor +1 -1
  111. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +11 -8
  112. data/newrelic.yml +224 -79
  113. data/test/agent_helper.rb +8 -1
  114. metadata +32 -6
@@ -35,6 +35,15 @@ module NewRelic
35
35
  end
36
36
 
37
37
  class DefaultSource
38
+ BOOLEAN_MAP = {
39
+ 'true' => true,
40
+ 'yes' => true,
41
+ 'on' => true,
42
+ 'false' => false,
43
+ 'no' => false,
44
+ 'off' => false
45
+ }.freeze
46
+
38
47
  attr_reader :defaults
39
48
 
40
49
  extend Forwardable
@@ -64,6 +73,12 @@ module NewRelic
64
73
  value_from_defaults(key, :allowlist)
65
74
  end
66
75
 
76
+ def self.boolean_for(key, value)
77
+ string_value = (value.respond_to?(:call) ? value.call : value).to_s
78
+
79
+ BOOLEAN_MAP.fetch(string_value, nil)
80
+ end
81
+
67
82
  def self.default_for(key)
68
83
  value_from_defaults(key, :default)
69
84
  end
@@ -124,14 +139,16 @@ module NewRelic
124
139
  case Rails::VERSION::MAJOR
125
140
  when 3
126
141
  :rails3
127
- when 4..7
142
+ when 4..8
128
143
  :rails_notifications
129
144
  else
130
145
  ::NewRelic::Agent.logger.warn("Detected untested Rails version #{Rails::VERSION::STRING}")
131
146
  :rails_notifications
132
147
  end
148
+ when defined?(::Padrino) && defined?(::Padrino::PathRouter::Router) then :padrino
133
149
  when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
134
150
  when defined?(::Roda) then :roda
151
+ when defined?(::Grape) then :grape
135
152
  when defined?(::NewRelic::IA) then :external
136
153
  else :ruby
137
154
  end
@@ -410,6 +427,7 @@ module NewRelic
410
427
  :public => true,
411
428
  :type => String,
412
429
  :allowed_from_server => false,
430
+ :exclude_from_reported_settings => true,
413
431
  :description => 'Your New Relic <InlinePopover type="userKey" />. Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.'
414
432
  },
415
433
  :backport_fast_active_record_connection_lookup => {
@@ -425,7 +443,7 @@ module NewRelic
425
443
  :public => true,
426
444
  :type => String,
427
445
  :allowed_from_server => false,
428
- :description => "Manual override for the path to your local CA bundle. This CA bundle will be used to validate the SSL certificate presented by New Relic's data collection service."
446
+ :description => "Manual override for the path to your local CA bundle. This CA bundle validates the SSL certificate presented by New Relic's data collection service."
429
447
  },
430
448
  :capture_memcache_keys => {
431
449
  :default => false,
@@ -454,6 +472,14 @@ module NewRelic
454
472
  :allowed_from_server => false,
455
473
  :description => 'If `true`, the agent will clear `Tracer::State` in `Agent.drop_buffered_data`.'
456
474
  },
475
+ :'cloud.aws.account_id' => {
476
+ :default => nil,
477
+ :public => true,
478
+ :type => String,
479
+ :allow_nil => true,
480
+ :allowed_from_server => false,
481
+ :description => 'The AWS account ID for the AWS account associated with this app'
482
+ },
457
483
  :config_path => {
458
484
  :default => DefaultSource.config_path,
459
485
  :public => true,
@@ -620,7 +646,7 @@ module NewRelic
620
646
  :public => true,
621
647
  :type => Boolean,
622
648
  :allowed_from_server => true,
623
- :description => 'If `true`, enables the collection of explain plans in transaction traces. This setting will also apply to explain plans in slow SQL traces if [`slow_sql.explain_enabled`](#slow_sql-explain_enabled) is not set separately.'
649
+ :description => "If `true`, enables the collection of explain plans in transaction traces. This setting will also apply to explain plans in slow SQL traces if [`slow_sql.explain_enabled`](#slow_sql-explain_enabled) isn't set separately."
624
650
  },
625
651
  :'transaction_tracer.explain_threshold' => {
626
652
  :default => 0.5,
@@ -832,7 +858,7 @@ module NewRelic
832
858
  :description => <<~DESCRIPTION
833
859
  Sets the minimum level a log event must have to be forwarded to New Relic.
834
860
 
835
- This is based on the integer values of Ruby's `Logger::Severity` constants: https://github.com/ruby/ruby/blob/master/lib/logger/severity.rb
861
+ This is based on the integer values of [Ruby's `Logger::Severity` constants](https://github.com/ruby/logger/blob/113b82a06b3076b93a71cd467e1605b23afb3088/lib/logger/severity.rb).
836
862
 
837
863
  The intention is to forward logs with the level given to the configuration, as well as any logs with a higher level of severity.
838
864
 
@@ -855,6 +881,21 @@ module NewRelic
855
881
  :allowed_from_server => false,
856
882
  :description => 'A hash with key/value pairs to add as custom attributes to all log events forwarded to New Relic. If sending using an environment variable, the value must be formatted like: "key1=value1,key2=value2"'
857
883
  },
884
+ :'application_logging.forwarding.labels.enabled' => {
885
+ :default => false,
886
+ :public => true,
887
+ :type => Boolean,
888
+ :allowed_from_server => false,
889
+ :description => 'If `true`, the agent attaches [labels](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#labels) to log records.'
890
+ },
891
+ :'application_logging.forwarding.labels.exclude' => {
892
+ :default => [],
893
+ :public => true,
894
+ :type => Array,
895
+ :transform => DefaultSource.method(:convert_to_list),
896
+ :allowed_from_server => false,
897
+ :description => 'A case-insensitive array or comma-delimited string containing the labels to exclude from log records.'
898
+ },
858
899
  :'application_logging.forwarding.max_samples_stored' => {
859
900
  :default => 10000,
860
901
  :public => true,
@@ -1135,6 +1176,56 @@ module NewRelic
1135
1176
  :allowed_from_server => false,
1136
1177
  :description => 'If `false`, custom attributes will not be sent on events.'
1137
1178
  },
1179
+ :automatic_custom_instrumentation_method_list => {
1180
+ :default => NewRelic::EMPTY_ARRAY,
1181
+ :public => true,
1182
+ :type => Array,
1183
+ :allowed_from_server => false,
1184
+ :transform => proc { |arr| NewRelic::Agent.add_automatic_method_tracers(arr) },
1185
+ :description => <<~DESCRIPTION
1186
+ An array of `CLASS#METHOD` (for instance methods) and/or `CLASS.METHOD` (for class methods) strings representing Ruby methods that the agent can automatically add custom instrumentation to. This doesn't require any modifications of the source code that defines the methods.
1187
+
1188
+ Use fully qualified class names (using the `::` delimiter) that include any module or class namespacing.
1189
+
1190
+ Here is some Ruby source code that defines a `render_png` instance method for an `Image` class and a `notify` class method for a `User` class, both within a `MyCompany` module namespace:
1191
+
1192
+ ```rb
1193
+ module MyCompany
1194
+ class Image
1195
+ def render_png
1196
+ # code to render a PNG
1197
+ end
1198
+ end
1199
+
1200
+ class User
1201
+ def self.notify
1202
+ # code to notify users
1203
+ end
1204
+ end
1205
+ end
1206
+ ```
1207
+
1208
+ Given that source code, the `newrelic.yml` config file might request instrumentation for both of these methods like so:
1209
+
1210
+ ```yaml
1211
+ automatic_custom_instrumentation_method_list:
1212
+ - MyCompany::Image#render_png
1213
+ - MyCompany::User.notify
1214
+ ```
1215
+
1216
+ That configuration example uses YAML array syntax to specify both methods. Alternatively, you can use a comma-delimited string:
1217
+
1218
+ ```yaml
1219
+ automatic_custom_instrumentation_method_list: 'MyCompany::Image#render_png, MyCompany::User.notify'
1220
+ ```
1221
+
1222
+ Whitespace around the comma(s) in the list is optional. When configuring the agent with a list of methods via the `NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST` environment variable, use this comma-delimited string format:
1223
+
1224
+ ```sh
1225
+ export NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST='MyCompany::Image#render_png, MyCompany::User.notify'
1226
+ ```
1227
+ DESCRIPTION
1228
+ },
1138
1229
  # Custom events
1139
1230
  :'custom_insights_events.enabled' => {
1140
1231
  :default => true,
@@ -1149,9 +1240,10 @@ module NewRelic
1149
1240
  :type => Integer,
1150
1241
  :allowed_from_server => true,
1151
1242
  :dynamic_name => true,
1243
+ # Keep the extra two-space indent before the second bullet to appease translation tool
1152
1244
  :description => <<~DESC
1153
1245
  * Specify a maximum number of custom events to buffer in memory at a time.
1154
- * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
1246
+ * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
1155
1247
  set to max value `100000`. This ensures the agent captures the maximum amount of LLM events.
1156
1248
  DESC
1157
1249
  },
@@ -1218,6 +1310,7 @@ module NewRelic
1218
1310
  :default => false,
1219
1311
  :public => true,
1220
1312
  :type => Boolean,
1313
+ :aliases => %i[disable_active_job],
1221
1314
  :allowed_from_server => false,
1222
1315
  :description => 'If `true`, disables Active Job instrumentation.'
1223
1316
  },
@@ -1460,6 +1553,58 @@ module NewRelic
1460
1553
  :allowed_from_server => false,
1461
1554
  :description => 'Controls auto-instrumentation of bunny at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1462
1555
  },
1556
+ :'instrumentation.aws_sdk_firehose' => {
1557
+ :default => 'auto',
1558
+ :documentation_default => 'auto',
1559
+ :public => true,
1560
+ :type => String,
1561
+ :dynamic_name => true,
1562
+ :allowed_from_server => false,
1563
+ :description => 'Controls auto-instrumentation of the aws-sdk-firehose library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1564
+ },
1565
+ :'instrumentation.aws_sdk_lambda' => {
1566
+ :default => 'auto',
1567
+ :documentation_default => 'auto',
1568
+ :public => true,
1569
+ :type => String,
1570
+ :dynamic_name => true,
1571
+ :allowed_from_server => false,
1572
+ :description => 'Controls auto-instrumentation of the aws_sdk_lambda library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1573
+ },
1574
+ :'instrumentation.aws_sdk_kinesis' => {
1575
+ :default => 'auto',
1576
+ :documentation_default => 'auto',
1577
+ :public => true,
1578
+ :type => String,
1579
+ :dynamic_name => true,
1580
+ :allowed_from_server => false,
1581
+ :description => 'Controls auto-instrumentation of the aws-sdk-kinesis library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1582
+ },
1583
+ :'instrumentation.ruby_kafka' => {
1584
+ :default => 'auto',
1585
+ :public => true,
1586
+ :type => String,
1587
+ :dynamic_name => true,
1588
+ :allowed_from_server => false,
1589
+ :description => 'Controls auto-instrumentation of the ruby-kafka library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1590
+ },
1591
+ :'instrumentation.opensearch' => {
1592
+ :default => 'auto',
1593
+ :documentation_default => 'auto',
1594
+ :public => true,
1595
+ :type => String,
1596
+ :dynamic_name => true,
1597
+ :allowed_from_server => false,
1598
+ :description => 'Controls auto-instrumentation of the opensearch-ruby library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1599
+ },
1600
+ :'instrumentation.rdkafka' => {
1601
+ :default => 'auto',
1602
+ :public => true,
1603
+ :type => String,
1604
+ :dynamic_name => true,
1605
+ :allowed_from_server => false,
1606
+ :description => 'Controls auto-instrumentation of the rdkafka library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1607
+ },
1463
1608
  :'instrumentation.aws_sqs' => {
1464
1609
  :default => 'auto',
1465
1610
  :public => true,
@@ -1785,7 +1930,7 @@ module NewRelic
1785
1930
  :description => <<~DESCRIPTION
1786
1931
  An array of strings to specify which keys inside a Stripe event's `user_data` hash should be reported
1787
1932
  to New Relic. Each string in this array will be turned into a regular expression via `Regexp.new` to
1788
- permit advanced matching. Setting the value to `["."]` will report all `user_data`.
1933
+ enable advanced matching. Setting the value to `["."]` will report all `user_data`.
1789
1934
  DESCRIPTION
1790
1935
  },
1791
1936
  :'stripe.user_data.exclude' => {
@@ -1798,9 +1943,9 @@ module NewRelic
1798
1943
  :description => <<~DESCRIPTION
1799
1944
  An array of strings to specify which keys and/or values inside a Stripe event's `user_data` hash should
1800
1945
  not be reported to New Relic. Each string in this array will be turned into a regular expression via
1801
- `Regexp.new` to permit advanced matching. For each hash pair, if either the key or value is matched the
1802
- pair will not be reported. By default, no `user_data` is reported, so this option should only be used if
1803
- the `stripe.user_data.include` option is being used.
1946
+ `Regexp.new` to permit advanced matching. For each hash pair, if either the key or value is matched the pair
1947
+ isn't reported. By default, no `user_data` is reported. Use this option only if the
1948
+ `stripe.user_data.include` option is also used.
1804
1949
  DESCRIPTION
1805
1950
  },
1806
1951
  :'instrumentation.thread' => {
@@ -1867,6 +2012,21 @@ module NewRelic
1867
2012
  :allowed_from_server => true,
1868
2013
  :description => 'If `true`, the agent obfuscates Mongo queries in transaction traces.'
1869
2014
  },
2015
+ # OpenSearch
2016
+ :'opensearch.capture_queries' => {
2017
+ :default => true,
2018
+ :public => true,
2019
+ :type => Boolean,
2020
+ :allowed_from_server => true,
2021
+ :description => 'If `true`, the agent captures OpenSearch queries in transaction traces.'
2022
+ },
2023
+ :'opensearch.obfuscate_queries' => {
2024
+ :default => true,
2025
+ :public => true,
2026
+ :type => Boolean,
2027
+ :allowed_from_server => true,
2028
+ :description => 'If `true`, the agent obfuscates OpenSearch queries in transaction traces.'
2029
+ },
1870
2030
  # Process host
1871
2031
  :'process_host.display_name' => {
1872
2032
  :default => proc { NewRelic::Agent::Hostname.get },
@@ -1928,7 +2088,7 @@ module NewRelic
1928
2088
  :transform => proc { |bool| NewRelic::Agent::ServerlessHandler.env_var_set? || bool },
1929
2089
  :description => 'If `true`, the agent will operate in a streamlined mode suitable for use with short-lived ' \
1930
2090
  'serverless functions. NOTE: Only AWS Lambda functions are supported currently and this ' \
1931
- "option is not intended for use without [New Relic's Ruby Lambda layer](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/monitoring-aws-lambda-serverless-monitoring/) offering."
2091
+ "option isn't intended for use without [New Relic's Ruby Lambda layer](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/monitoring-aws-lambda-serverless-monitoring/) offering."
1932
2092
  },
1933
2093
  # Sidekiq
1934
2094
  :'sidekiq.args.include' => {
@@ -2022,9 +2182,10 @@ module NewRelic
2022
2182
  :public => true,
2023
2183
  :type => Integer,
2024
2184
  :allowed_from_server => true,
2185
+ # Keep the extra two-space indent before the second bullet to appease translation tool
2025
2186
  :description => <<~DESC
2026
2187
  * Defines the maximum number of span events reported from a single harvest. Any Integer between `1` and `10000` is valid.'
2027
- * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
2188
+ * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
2028
2189
  This ensures the agent captures the maximum amount of distributed traces.
2029
2190
  DESC
2030
2191
  },
@@ -2035,7 +2196,7 @@ module NewRelic
2035
2196
  :public => true,
2036
2197
  :type => Boolean,
2037
2198
  :allowed_from_server => false,
2038
- :description => 'If true, the agent strips messages from all exceptions except those in the [allowlist](#strip_exception_messages-allowlist). Enabled automatically in [high security mode](/docs/accounts-partnerships/accounts/security/high-security).'
2199
+ :description => 'If true, the agent strips messages from all exceptions except those in the [allowed classes list](#strip_exception_messages-allowed_classes). Enabled automatically in [high security mode](/docs/accounts-partnerships/accounts/security/high-security).'
2039
2200
  },
2040
2201
  :'strip_exception_messages.allowed_classes' => {
2041
2202
  :default => '',
@@ -2045,6 +2206,28 @@ module NewRelic
2045
2206
  :transform => DefaultSource.method(:convert_to_constant_list),
2046
2207
  :description => 'Specify a list of exceptions you do not want the agent to strip when [strip_exception_messages](#strip_exception_messages-enabled) is `true`. Separate exceptions with a comma. For example, `"ImportantException,PreserveMessageException"`.'
2047
2208
  },
2209
+ # Agent Control
2210
+ :'agent_control.enabled' => {
2211
+ :default => false,
2212
+ :public => false,
2213
+ :type => Boolean,
2214
+ :allowed_from_server => false,
2215
+ :description => 'Boolean value that denotes whether Agent Control functionality should be enabled. At the moment, this functionality is limited to whether agent health should be reported. This configuration will be set using an environment variable by Agent Control, or one of its components, prior to agent startup.'
2216
+ },
2217
+ :'agent_control.health.delivery_location' => {
2218
+ :default => '/newrelic/apm/health',
2219
+ :public => false,
2220
+ :type => String,
2221
+ :allowed_from_server => false,
2222
+ :description => 'A `file:` URI that specifies the fully qualified directory path for health file(s) to be written to. This defaults to: `file:///newrelic/apm/health`. This configuration will be set using an environment variable by Agent Control, or one of its components, prior to agent startup.'
2223
+ },
2224
+ :'agent_control.health.frequency' => {
2225
+ :default => 5,
2226
+ :public => false,
2227
+ :type => Integer,
2228
+ :allowed_from_server => false,
2229
+ :description => 'The interval, in seconds, of how often the health file(s) will be written to. This configuration will be set using an environment variable by Agent Control, or one of its components, prior to agent startup.'
2230
+ },
2048
2231
  # Thread profiler
2049
2232
  :'thread_profiler.enabled' => {
2050
2233
  :default => DefaultSource.thread_profiler_enabled,
@@ -2174,7 +2357,7 @@ module NewRelic
2174
2357
  :description => 'Enable or disable debugging version of JavaScript agent loader for browser monitoring instrumentation.'
2175
2358
  },
2176
2359
  :'browser_monitoring.ssl_for_http' => {
2177
- :default => nil,
2360
+ :default => false,
2178
2361
  :allow_nil => true,
2179
2362
  :public => false,
2180
2363
  :type => Boolean,
@@ -2576,47 +2759,196 @@ module NewRelic
2576
2759
  :description => 'Defines the endpoint URL for posting security-related data',
2577
2760
  :dynamic_name => true
2578
2761
  },
2579
- :'security.detection.rci.enabled' => {
2580
- :default => true,
2762
+ :'security.application_info.port' => {
2763
+ :default => nil,
2764
+ :allow_nil => true,
2765
+ :public => true,
2766
+ :type => Integer,
2767
+ :external => true,
2768
+ :allowed_from_server => false,
2769
+ :description => 'The port the application is listening on. This setting is mandatory for Passenger servers. The agent detects other servers by default.'
2770
+ },
2771
+ :'security.exclude_from_iast_scan.api' => {
2772
+ :default => [],
2773
+ :public => true,
2774
+ :type => Array,
2775
+ :external => true,
2776
+ :allowed_from_server => true,
2777
+ :transform => DefaultSource.method(:convert_to_list),
2778
+ :description => 'Defines API paths the security agent should ignore in IAST scans. Accepts an array of regex patterns matching the URI to ignore. The regex pattern should find a complete match for the URL without the endpoint. For example, `[".*account.*"], [".*/\api\/v1\/.*?\/login"]`'
2779
+ },
2780
+ :'security.exclude_from_iast_scan.http_request_parameters.header' => {
2781
+ :default => [],
2782
+ :public => true,
2783
+ :type => Array,
2784
+ :external => true,
2785
+ :allowed_from_server => true,
2786
+ :transform => DefaultSource.method(:convert_to_list),
2787
+ :description => 'An array of HTTP request headers the security agent should ignore in IAST scans. The array should specify a list of patterns matching the headers to ignore.'
2788
+ },
2789
+ :'security.exclude_from_iast_scan.http_request_parameters.query' => {
2790
+ :default => [],
2791
+ :public => true,
2792
+ :type => Array,
2793
+ :external => true,
2794
+ :allowed_from_server => true,
2795
+ :transform => DefaultSource.method(:convert_to_list),
2796
+ :description => 'An array of HTTP request query parameters the security agent should ignore in IAST scans. The array should specify a list of patterns matching the HTTP request query parameters to ignore.'
2797
+ },
2798
+ :'security.exclude_from_iast_scan.http_request_parameters.body' => {
2799
+ :default => [],
2800
+ :public => true,
2801
+ :type => Array,
2802
+ :external => true,
2803
+ :allowed_from_server => true,
2804
+ :transform => DefaultSource.method(:convert_to_list),
2805
+ :description => 'An array of HTTP request body keys the security agent should ignore in IAST scans.'
2806
+ },
2807
+ :'security.exclude_from_iast_scan.iast_detection_category.insecure_settings' => {
2808
+ :default => false,
2581
2809
  :external => true,
2582
2810
  :public => true,
2583
2811
  :type => Boolean,
2584
2812
  :allowed_from_server => false,
2585
- :description => 'If `true`, enables RCI (remote code injection) detection'
2813
+ :description => 'If `true`, disables the detection of low-severity insecure settings. For example, hash, crypto, cookie, random generators, trust boundary).'
2586
2814
  },
2587
- :'security.detection.rxss.enabled' => {
2588
- :default => true,
2815
+ :'security.exclude_from_iast_scan.iast_detection_category.invalid_file_access' => {
2816
+ :default => false,
2589
2817
  :external => true,
2590
2818
  :public => true,
2591
2819
  :type => Boolean,
2592
2820
  :allowed_from_server => false,
2593
- :description => 'If `true`, enables RXSS (reflected cross-site scripting) detection'
2821
+ :description => 'If `true`, disables file operation-related IAST detections (File Access & Application integrity violation)'
2594
2822
  },
2595
- :'security.detection.deserialization.enabled' => {
2596
- :default => true,
2823
+ :'security.exclude_from_iast_scan.iast_detection_category.sql_injection' => {
2824
+ :default => false,
2597
2825
  :external => true,
2598
2826
  :public => true,
2599
2827
  :type => Boolean,
2600
2828
  :allowed_from_server => false,
2601
- :description => 'If `true`, enables deserialization detection'
2829
+ :description => 'If `true`, disables SQL injection detection in IAST scans.'
2602
2830
  },
2603
- :'security.application_info.port' => {
2604
- :default => nil,
2605
- :allow_nil => true,
2831
+ :'security.exclude_from_iast_scan.iast_detection_category.nosql_injection' => {
2832
+ :default => false,
2833
+ :external => true,
2606
2834
  :public => true,
2607
- :type => Integer,
2835
+ :type => Boolean,
2836
+ :allowed_from_server => false,
2837
+ :description => 'If `true`, disables NOSQL injection detection in IAST scans.'
2838
+ },
2839
+ :'security.exclude_from_iast_scan.iast_detection_category.ldap_injection' => {
2840
+ :default => false,
2608
2841
  :external => true,
2842
+ :public => true,
2843
+ :type => Boolean,
2609
2844
  :allowed_from_server => false,
2610
- :description => 'The port the application is listening on. This setting is mandatory for Passenger servers. Other servers should be detected by default.'
2845
+ :description => 'If `true`, disables LDAP injection detection in IAST scans.'
2611
2846
  },
2612
- :'security.request.body_limit' => {
2613
- :default => 300,
2614
- :allow_nil => true,
2847
+ :'security.exclude_from_iast_scan.iast_detection_category.javascript_injection' => {
2848
+ :default => false,
2849
+ :external => true,
2850
+ :public => true,
2851
+ :type => Boolean,
2852
+ :allowed_from_server => false,
2853
+ :description => 'If `true`, disables Javascript injection detection in IAST scans.'
2854
+ },
2855
+ :'security.exclude_from_iast_scan.iast_detection_category.command_injection' => {
2856
+ :default => false,
2857
+ :external => true,
2858
+ :public => true,
2859
+ :type => Boolean,
2860
+ :allowed_from_server => false,
2861
+ :description => 'If `true`, disables system command injection detection in IAST scans.'
2862
+ },
2863
+ :'security.exclude_from_iast_scan.iast_detection_category.xpath_injection' => {
2864
+ :default => false,
2865
+ :external => true,
2866
+ :public => true,
2867
+ :type => Boolean,
2868
+ :allowed_from_server => false,
2869
+ :description => 'If `true`, disables XPATH injection detection in IAST scans.'
2870
+ },
2871
+ :'security.exclude_from_iast_scan.iast_detection_category.ssrf' => {
2872
+ :default => false,
2873
+ :external => true,
2874
+ :public => true,
2875
+ :type => Boolean,
2876
+ :allowed_from_server => false,
2877
+ :description => 'If `true`, disables Sever-Side Request Forgery (SSRF) detection in IAST scans.'
2878
+ },
2879
+ :'security.exclude_from_iast_scan.iast_detection_category.rxss' => {
2880
+ :default => false,
2881
+ :external => true,
2882
+ :public => true,
2883
+ :type => Boolean,
2884
+ :allowed_from_server => false,
2885
+ :description => 'If `true`, disables Reflected Cross-Site Scripting (RXSS) detection in IAST scans.'
2886
+ },
2887
+ :'security.scan_schedule.delay' => {
2888
+ :default => 0,
2889
+ :public => true,
2890
+ :type => Integer,
2891
+ :external => true,
2892
+ :allowed_from_server => true,
2893
+ :description => 'Specifies the delay time (in minutes) before the IAST scan begins after the application starts.'
2894
+ },
2895
+ :'security.scan_schedule.duration' => {
2896
+ :default => 0,
2615
2897
  :public => true,
2616
2898
  :type => Integer,
2617
2899
  :external => true,
2900
+ :allowed_from_server => true,
2901
+ :description => 'Indicates the duration (in minutes) for which the IAST scan will be performed.'
2902
+ },
2903
+ :'security.scan_schedule.schedule' => {
2904
+ :default => '',
2905
+ :public => true,
2906
+ :type => String,
2907
+ :external => true,
2908
+ :allowed_from_server => true,
2909
+ :description => 'Specifies a cron expression that sets when the IAST scan should run.',
2910
+ :dynamic_name => true
2911
+ },
2912
+ :'security.scan_schedule.always_sample_traces' => {
2913
+ :default => false,
2914
+ :external => true,
2915
+ :public => true,
2916
+ :type => Boolean,
2618
2917
  :allowed_from_server => false,
2619
- :description => 'Defines the request body limit to process in security events (in KB). The default value is 300, for 300KB.'
2918
+ :description => 'If `true`, allows IAST to continuously gather trace data in the background. The security agent uses collected data to perform an IAST scan at the scheduled time.'
2919
+ },
2920
+ :'security.scan_controllers.iast_scan_request_rate_limit' => {
2921
+ :default => 3600,
2922
+ :public => true,
2923
+ :type => Integer,
2924
+ :external => true,
2925
+ :allowed_from_server => true,
2926
+ :description => 'Sets the maximum number of HTTP requests allowed for the IAST scan per minute. Any Integer between 12 and 3600 is valid. The default value is 3600.'
2927
+ },
2928
+ :'security.scan_controllers.scan_instance_count' => {
2929
+ :default => 0,
2930
+ :public => true,
2931
+ :type => Integer,
2932
+ :external => true,
2933
+ :allowed_from_server => true,
2934
+ :description => 'The number of application instances for a specific entity to perform IAST analysis on.'
2935
+ },
2936
+ :'security.scan_controllers.report_http_response_body' => {
2937
+ :default => true,
2938
+ :public => true,
2939
+ :type => Boolean,
2940
+ :external => true,
2941
+ :allowed_from_server => true,
2942
+ :description => 'If `true`, enables the sending of HTTP responses bodies. Disabling this also disables Reflected Cross-Site Scripting (RXSS) vulnerability detection.'
2943
+ },
2944
+ :'security.iast_test_identifier' => {
2945
+ :default => nil,
2946
+ :allow_nil => true,
2947
+ :public => true,
2948
+ :type => String,
2949
+ :external => true,
2950
+ :allowed_from_server => true,
2951
+ :description => 'A unique test identifier when runnning IAST in a CI/CD environment to differentiate between different test runs. For example, a build number.'
2620
2952
  }
2621
2953
  }.freeze
2622
2954
  # rubocop:enable Metrics/CollectionLiteralLength
@@ -92,7 +92,11 @@ module NewRelic
92
92
  elsif type == Symbol
93
93
  self[config_key] = value.to_sym
94
94
  elsif type == Array
95
- self[config_key] = value.split(/\s*,\s*/)
95
+ self[config_key] = if DEFAULTS[config_key].key?(:transform)
96
+ DEFAULTS[config_key][:transform].call(value)
97
+ else
98
+ value.split(/\s*,\s*/)
99
+ end
96
100
  elsif type == NewRelic::Agent::Configuration::Boolean
97
101
  if /false|off|no/i.match?(value)
98
102
  self[config_key] = false
@@ -142,6 +142,9 @@ module NewRelic
142
142
  default = enforce_allowlist(key, evaluated)
143
143
  return default if default
144
144
 
145
+ boolean = enforce_boolean(key, value)
146
+ evaluated = boolean if [true, false].include?(boolean)
147
+
145
148
  apply_transformations(key, evaluated)
146
149
  end
147
150
 
@@ -167,6 +170,18 @@ module NewRelic
167
170
  default
168
171
  end
169
172
 
173
+ def enforce_boolean(key, value)
174
+ type = default_source.value_from_defaults(key, :type)
175
+ return unless type == Boolean
176
+
177
+ bool_value = default_source.boolean_for(key, value)
178
+ return bool_value unless bool_value.nil?
179
+
180
+ default = default_source.default_for(key)
181
+ NewRelic::Agent.logger.warn "Invalid value '#{value}' for #{key}, applying default value of '#{default}'"
182
+ default
183
+ end
184
+
170
185
  def transform_from_default(key)
171
186
  default_source.transform_for(key)
172
187
  end
@@ -382,6 +397,14 @@ module NewRelic
382
397
  def reset_cache
383
398
  return new_cache unless defined?(@cache) && @cache
384
399
 
400
+ # Modifying the @cache hash under JRuby - even with a `synchronize do`
401
+ # block and a `Hash#dup` operation - has been known to cause issues
402
+ # with JRuby for concurrent access of the hash while it is being
403
+ # modified. The hash really only needs to be modified for the benefit
404
+ # of the security agent, so if JRuby is in play and the security agent
405
+ # is not, don't attempt to modify the hash at all and return early.
406
+ return new_cache if NewRelic::LanguageSupport.jruby? && !Agent.config[:'security.agent.enabled']
407
+
385
408
  @lock.synchronize do
386
409
  preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
387
410
  new_cache
@@ -36,6 +36,7 @@ module NewRelic
36
36
  erb_file = process_erb(raw_file)
37
37
  config = process_yaml(erb_file, env, config, @file_path)
38
38
  rescue ScriptError, StandardError => e
39
+ NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_PARSE_CONFIG)
39
40
  log_failure("Failed to read or parse configuration file at #{path}", e)
40
41
  end
41
42
 
@@ -99,7 +100,11 @@ module NewRelic
99
100
  file.gsub!(/^\s*#.*$/, '#')
100
101
  ERB.new(file).result(binding)
101
102
  rescue ScriptError, StandardError => e
102
- log_failure('Failed ERB processing configuration file. This is typically caused by a Ruby error in <% %> templating blocks in your newrelic.yml file.', e)
103
+ NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_PARSE_CONFIG)
104
+ message = 'Failed ERB processing configuration file. This is typically caused by a Ruby error in <% %> templating blocks in your newrelic.yml file.'
105
+ failure_array = [message, e]
106
+ failure_array << e.backtrace[0] if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0')
107
+ log_failure(*failure_array)
103
108
  nil
104
109
  end
105
110
  end