newrelic_rpm 9.5.0 → 9.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -7
  3. data/CONTRIBUTING.md +0 -7
  4. data/README.md +1 -1
  5. data/Rakefile +1 -1
  6. data/bin/newrelic +2 -9
  7. data/bin/newrelic_rpm +15 -0
  8. data/init.rb +2 -2
  9. data/lib/new_relic/agent/agent.rb +1 -1
  10. data/lib/new_relic/agent/agent_helpers/shutdown.rb +1 -1
  11. data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -1
  12. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +2 -2
  13. data/lib/new_relic/agent/agent_helpers/startup.rb +2 -2
  14. data/lib/new_relic/agent/attribute_filter.rb +3 -3
  15. data/lib/new_relic/agent/configuration/default_source.rb +131 -36
  16. data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
  17. data/lib/new_relic/agent/configuration/manager.rb +13 -9
  18. data/lib/new_relic/agent/configuration/security_policy_source.rb +11 -0
  19. data/lib/new_relic/agent/custom_event_aggregator.rb +27 -1
  20. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
  21. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +3 -3
  22. data/lib/new_relic/agent/error_collector.rb +2 -0
  23. data/lib/new_relic/agent/event_loop.rb +1 -1
  24. data/lib/new_relic/agent/http_clients/abstract.rb +4 -0
  25. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +80 -0
  26. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -3
  27. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +109 -0
  28. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +0 -3
  29. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +1 -3
  30. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +0 -3
  31. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +91 -0
  32. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +1 -4
  33. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +0 -3
  34. data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -2
  36. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  37. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +17 -0
  38. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  39. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
  40. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
  41. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  42. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  43. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  44. data/lib/new_relic/agent/instrumentation/async_http.rb +28 -0
  45. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +1 -0
  46. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +1 -1
  47. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  48. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  49. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  50. data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
  51. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +1 -4
  52. data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
  53. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  54. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  55. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  56. data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
  57. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -3
  58. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +7 -1
  59. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +1 -0
  60. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  61. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +12 -0
  62. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +1 -2
  63. data/lib/new_relic/agent/instrumentation/roda.rb +2 -0
  64. data/lib/new_relic/agent/instrumentation/ruby_openai/chain.rb +36 -0
  65. data/lib/new_relic/agent/instrumentation/ruby_openai/instrumentation.rb +197 -0
  66. data/lib/new_relic/agent/instrumentation/ruby_openai/prepend.rb +20 -0
  67. data/lib/new_relic/agent/instrumentation/ruby_openai.rb +35 -0
  68. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -1
  69. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
  70. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
  71. data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
  72. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -4
  73. data/lib/new_relic/agent/instrumentation/view_component/chain.rb +21 -0
  74. data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +39 -0
  75. data/lib/new_relic/agent/instrumentation/view_component/prepend.rb +13 -0
  76. data/lib/new_relic/agent/instrumentation/view_component.rb +26 -0
  77. data/lib/new_relic/agent/javascript_instrumentor.rb +0 -1
  78. data/lib/new_relic/agent/llm/chat_completion_message.rb +25 -0
  79. data/lib/new_relic/agent/llm/chat_completion_summary.rb +66 -0
  80. data/lib/new_relic/agent/llm/embedding.rb +60 -0
  81. data/lib/new_relic/agent/llm/llm_event.rb +95 -0
  82. data/lib/new_relic/agent/llm/response_headers.rb +80 -0
  83. data/lib/new_relic/agent/llm.rb +49 -0
  84. data/lib/new_relic/agent/messaging.rb +2 -2
  85. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  86. data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
  87. data/lib/new_relic/agent/new_relic_service.rb +8 -6
  88. data/lib/new_relic/agent/obfuscator.rb +0 -2
  89. data/lib/new_relic/agent/pipe_channel_manager.rb +2 -2
  90. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -2
  91. data/lib/new_relic/agent/rules_engine.rb +1 -1
  92. data/lib/new_relic/agent/span_event_primitive.rb +16 -4
  93. data/lib/new_relic/agent/sql_sampler.rb +0 -1
  94. data/lib/new_relic/agent/system_info.rb +26 -0
  95. data/lib/new_relic/agent/threading/agent_thread.rb +1 -2
  96. data/lib/new_relic/agent/tracer.rb +9 -10
  97. data/lib/new_relic/agent/transaction/abstract_segment.rb +4 -1
  98. data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -2
  99. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -2
  100. data/lib/new_relic/agent/transaction/request_attributes.rb +1 -3
  101. data/lib/new_relic/agent/transaction/tracing.rb +11 -1
  102. data/lib/new_relic/agent/transaction.rb +25 -2
  103. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -0
  104. data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
  105. data/lib/new_relic/agent/utilization/gcp.rb +1 -3
  106. data/lib/new_relic/agent/vm/{mri_vm.rb → c_ruby_vm.rb} +7 -15
  107. data/lib/new_relic/agent/vm.rb +2 -2
  108. data/lib/new_relic/agent/worker_loop.rb +1 -1
  109. data/lib/new_relic/agent.rb +102 -7
  110. data/lib/new_relic/base64.rb +25 -0
  111. data/lib/new_relic/cli/command.rb +6 -4
  112. data/lib/new_relic/constants.rb +5 -0
  113. data/lib/new_relic/control/frameworks/rails.rb +17 -5
  114. data/lib/new_relic/control/instrumentation.rb +1 -1
  115. data/lib/new_relic/language_support.rb +4 -0
  116. data/lib/new_relic/local_environment.rb +22 -13
  117. data/lib/new_relic/rack/browser_monitoring.rb +8 -4
  118. data/lib/new_relic/supportability_helper.rb +3 -1
  119. data/lib/new_relic/thread_local_storage.rb +31 -0
  120. data/lib/new_relic/version.rb +1 -1
  121. data/lib/tasks/config.rake +1 -1
  122. data/lib/tasks/helpers/config.html.erb +6 -6
  123. data/lib/tasks/helpers/newrelicyml.rb +1 -1
  124. data/lib/tasks/instrumentation_generator/instrumentation.thor +3 -3
  125. data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -1
  126. data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -1
  127. data/lib/tasks/tests.rake +71 -0
  128. data/newrelic.yml +76 -36
  129. data/newrelic_rpm.gemspec +5 -4
  130. data/test/agent_helper.rb +14 -2
  131. metadata +43 -7
  132. data/bin/newrelic_cmd +0 -7
@@ -313,6 +313,7 @@ module NewRelic
313
313
  'webpacker:compile'
314
314
  ].join(',').freeze
315
315
 
316
+ # rubocop:disable Metrics/CollectionLiteralLength
316
317
  DEFAULTS = {
317
318
  # Critical
318
319
  :agent_enabled => {
@@ -336,6 +337,7 @@ module NewRelic
336
337
  :public => true,
337
338
  :type => String,
338
339
  :allowed_from_server => false,
340
+ :exclude_from_reported_settings => true,
339
341
  :description => 'Your New Relic <InlinePopover type="licenseKey" />.'
340
342
  },
341
343
  :log_level => {
@@ -358,6 +360,26 @@ module NewRelic
358
360
  - a.third.event
359
361
  DESCRIPTION
360
362
  },
363
+ :'ai_monitoring.enabled' => {
364
+ :default => false,
365
+ :public => true,
366
+ :type => Boolean,
367
+ :allowed_from_server => false,
368
+ :description => 'If `false`, all LLM instrumentation (OpenAI only for now) will be disabled and no metrics, events, or spans will be sent. AI Monitoring is automatically disabled if `high_security` mode is enabled.'
369
+ },
370
+ :'ai_monitoring.record_content.enabled' => {
371
+ :default => true,
372
+ :public => true,
373
+ :type => Boolean,
374
+ :allowed_from_server => false,
375
+ :description => <<~DESCRIPTION
376
+ If `false`, LLM instrumentation (OpenAI only for now) will not capture input and output content on specific LLM events.
377
+
378
+ The excluded attributes include:
379
+ * `content` from LlmChatCompletionMessage events
380
+ * `input` from LlmEmbedding events
381
+ DESCRIPTION
382
+ },
361
383
  # this is only set via server side config
362
384
  :apdex_t => {
363
385
  :default => 0.5,
@@ -444,7 +466,7 @@ module NewRelic
444
466
  'before shutting down to be installed regardless of detecting scenarios where it generally should not be. ' \
445
467
  'Known use-case for this option is where Sinatra is running as an embedded service within another framework ' \
446
468
  'and the agent is detecting the Sinatra app and skipping the `at_exit` handler as a result. Sinatra classically ' \
447
- 'runs the entire application in an `at_exit` block and would otherwise misbehave if the Agent\'s `at_exit` handler ' \
469
+ 'runs the entire application in an `at_exit` block and would otherwise misbehave if the agent\'s `at_exit` handler ' \
448
470
  'was also installed in those circumstances. Note: `send_data_on_exit` should also be set to `true` in tandem with this setting.'
449
471
  },
450
472
  :high_security => {
@@ -552,6 +574,13 @@ module NewRelic
552
574
  :allowed_from_server => false,
553
575
  :description => 'When set to `true`, forces a synchronous connection to the New Relic [collector](/docs/using-new-relic/welcome-new-relic/get-started/glossary/#collector) during application startup. For very short-lived processes, this helps ensure the New Relic agent has time to report.'
554
576
  },
577
+ :thread_local_tracer_state => {
578
+ :default => false,
579
+ :public => true,
580
+ :type => Boolean,
581
+ :allowed_from_server => false,
582
+ :description => 'If `true`, tracer state storage is thread-local, otherwise, fiber-local'
583
+ },
555
584
  :timeout => {
556
585
  :default => 2 * 60, # 2 minutes
557
586
  :public => true,
@@ -718,7 +747,7 @@ module NewRelic
718
747
  :public => true,
719
748
  :type => Integer,
720
749
  :allowed_from_server => false,
721
- :description => 'Defines the maximum number of frames in an error backtrace. Backtraces over this amount are truncated at the beginning and end.'
750
+ :description => 'Defines the maximum number of frames in an error backtrace. Backtraces over this amount are truncated in the middle, preserving the beginning and the end of the stack trace.'
722
751
  },
723
752
  :'error_collector.max_event_samples_stored' => {
724
753
  :default => 100,
@@ -1014,7 +1043,20 @@ module NewRelic
1014
1043
  },
1015
1044
  # Autostart
1016
1045
  :'autostart.denylisted_constants' => {
1017
- :default => 'Rails::Console',
1046
+ :default => %w[Rails::Command::ConsoleCommand
1047
+ Rails::Command::CredentialsCommand
1048
+ Rails::Command::Db::System::ChangeCommand
1049
+ Rails::Command::DbConsoleCommand
1050
+ Rails::Command::DestroyCommand
1051
+ Rails::Command::DevCommand
1052
+ Rails::Command::EncryptedCommand
1053
+ Rails::Command::GenerateCommand
1054
+ Rails::Command::InitializersCommand
1055
+ Rails::Command::NotesCommand
1056
+ Rails::Command::RoutesCommand
1057
+ Rails::Command::SecretsCommand
1058
+ Rails::Console
1059
+ Rails::DBConsole].join(','),
1018
1060
  :public => true,
1019
1061
  :type => String,
1020
1062
  :allowed_from_server => false,
@@ -1348,6 +1390,15 @@ module NewRelic
1348
1390
  :description => 'Configures the TCP/IP port for the trace observer Host'
1349
1391
  },
1350
1392
  # Instrumentation
1393
+ :'instrumentation.active_support_broadcast_logger' => {
1394
+ :default => instrumentation_value_from_boolean(:'application_logging.enabled'),
1395
+ :documentation_default => 'auto',
1396
+ :dynamic_name => true,
1397
+ :public => true,
1398
+ :type => String,
1399
+ :allowed_from_server => false,
1400
+ :description => 'Controls auto-instrumentation of `ActiveSupport::BroadcastLogger` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`. Used in Rails versions >= 7.1.'
1401
+ },
1351
1402
  :'instrumentation.active_support_logger' => {
1352
1403
  :default => instrumentation_value_from_boolean(:'application_logging.enabled'),
1353
1404
  :documentation_default => 'auto',
@@ -1355,7 +1406,15 @@ module NewRelic
1355
1406
  :public => true,
1356
1407
  :type => String,
1357
1408
  :allowed_from_server => false,
1358
- :description => 'Controls auto-instrumentation of `ActiveSupport::Logger` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1409
+ :description => 'Controls auto-instrumentation of `ActiveSupport::Logger` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`. Used in Rails versions below 7.1.'
1410
+ },
1411
+ :'instrumentation.async_http' => {
1412
+ :default => 'auto',
1413
+ :public => true,
1414
+ :type => String,
1415
+ :dynamic_name => true,
1416
+ :allowed_from_server => false,
1417
+ :description => 'Controls auto-instrumentation of Async::HTTP at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1359
1418
  },
1360
1419
  :'instrumentation.bunny' => {
1361
1420
  :default => 'auto',
@@ -1363,7 +1422,7 @@ module NewRelic
1363
1422
  :type => String,
1364
1423
  :dynamic_name => true,
1365
1424
  :allowed_from_server => false,
1366
- :description => 'Controls auto-instrumentation of bunny at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1425
+ :description => 'Controls auto-instrumentation of bunny at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1367
1426
  },
1368
1427
  :'instrumentation.fiber' => {
1369
1428
  :default => 'auto',
@@ -1371,7 +1430,7 @@ module NewRelic
1371
1430
  :type => String,
1372
1431
  :dynamic_name => true,
1373
1432
  :allowed_from_server => false,
1374
- :description => 'Controls auto-instrumentation of the Fiber class at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1433
+ :description => 'Controls auto-instrumentation of the Fiber class at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1375
1434
  },
1376
1435
  :'instrumentation.concurrent_ruby' => {
1377
1436
  :default => 'auto',
@@ -1379,7 +1438,7 @@ module NewRelic
1379
1438
  :type => String,
1380
1439
  :dynamic_name => true,
1381
1440
  :allowed_from_server => false,
1382
- :description => 'Controls auto-instrumentation of the concurrent-ruby library at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1441
+ :description => 'Controls auto-instrumentation of the concurrent-ruby library at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1383
1442
  },
1384
1443
  :'instrumentation.curb' => {
1385
1444
  :default => 'auto',
@@ -1388,7 +1447,7 @@ module NewRelic
1388
1447
  :type => String,
1389
1448
  :dynamic_name => true,
1390
1449
  :allowed_from_server => false,
1391
- :description => 'Controls auto-instrumentation of Curb at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1450
+ :description => 'Controls auto-instrumentation of Curb at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1392
1451
  },
1393
1452
  :'instrumentation.delayed_job' => {
1394
1453
  :default => 'auto',
@@ -1397,7 +1456,7 @@ module NewRelic
1397
1456
  :type => String,
1398
1457
  :dynamic_name => true,
1399
1458
  :allowed_from_server => false,
1400
- :description => 'Controls auto-instrumentation of Delayed Job at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1459
+ :description => 'Controls auto-instrumentation of Delayed Job at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1401
1460
  },
1402
1461
  :'instrumentation.elasticsearch' => {
1403
1462
  :default => 'auto',
@@ -1405,7 +1464,15 @@ module NewRelic
1405
1464
  :type => String,
1406
1465
  :dynamic_name => true,
1407
1466
  :allowed_from_server => false,
1408
- :description => 'Controls auto-instrumentation of the elasticsearch library at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1467
+ :description => 'Controls auto-instrumentation of the elasticsearch library at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1468
+ },
1469
+ :'instrumentation.ethon' => {
1470
+ :default => 'auto',
1471
+ :public => true,
1472
+ :type => String,
1473
+ :dynamic_name => true,
1474
+ :allowed_from_server => false,
1475
+ :description => 'Controls auto-instrumentation of ethon at start up. May be one of [auto|prepend|chain|disabled]'
1409
1476
  },
1410
1477
  :'instrumentation.excon' => {
1411
1478
  :default => 'enabled',
@@ -1414,7 +1481,7 @@ module NewRelic
1414
1481
  :type => String,
1415
1482
  :dynamic_name => true,
1416
1483
  :allowed_from_server => false,
1417
- :description => 'Controls auto-instrumentation of Excon at start up. May be one of: `enabled`, `disabled`.'
1484
+ :description => 'Controls auto-instrumentation of Excon at start-up. May be one of: `enabled`, `disabled`.'
1418
1485
  },
1419
1486
  :'instrumentation.grape' => {
1420
1487
  :default => 'auto',
@@ -1422,7 +1489,7 @@ module NewRelic
1422
1489
  :type => String,
1423
1490
  :dynamic_name => true,
1424
1491
  :allowed_from_server => false,
1425
- :description => 'Controls auto-instrumentation of Grape at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1492
+ :description => 'Controls auto-instrumentation of Grape at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1426
1493
  },
1427
1494
  :'instrumentation.grpc_client' => {
1428
1495
  :default => 'auto',
@@ -1431,7 +1498,7 @@ module NewRelic
1431
1498
  :type => String,
1432
1499
  :dynamic_name => true,
1433
1500
  :allowed_from_server => false,
1434
- :description => 'Controls auto-instrumentation of gRPC clients at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1501
+ :description => 'Controls auto-instrumentation of gRPC clients at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1435
1502
  },
1436
1503
  :'instrumentation.grpc.host_denylist' => {
1437
1504
  :default => [],
@@ -1448,7 +1515,7 @@ module NewRelic
1448
1515
  :type => String,
1449
1516
  :dynamic_name => true,
1450
1517
  :allowed_from_server => false,
1451
- :description => 'Controls auto-instrumentation of gRPC servers at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1518
+ :description => 'Controls auto-instrumentation of gRPC servers at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1452
1519
  },
1453
1520
  :'instrumentation.httpclient' => {
1454
1521
  :default => 'auto',
@@ -1457,7 +1524,7 @@ module NewRelic
1457
1524
  :type => String,
1458
1525
  :dynamic_name => true,
1459
1526
  :allowed_from_server => false,
1460
- :description => 'Controls auto-instrumentation of HTTPClient at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1527
+ :description => 'Controls auto-instrumentation of HTTPClient at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1461
1528
  },
1462
1529
  :'instrumentation.httprb' => {
1463
1530
  :default => 'auto',
@@ -1466,7 +1533,16 @@ module NewRelic
1466
1533
  :type => String,
1467
1534
  :dynamic_name => true,
1468
1535
  :allowed_from_server => false,
1469
- :description => 'Controls auto-instrumentation of http.rb gem at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1536
+ :description => 'Controls auto-instrumentation of http.rb gem at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1537
+ },
1538
+ :'instrumentation.httpx' => {
1539
+ :default => 'auto',
1540
+ :documentation_default => 'auto',
1541
+ :public => true,
1542
+ :type => String,
1543
+ :dynamic_name => true,
1544
+ :allowed_from_server => false,
1545
+ :description => 'Controls auto-instrumentation of httpx at start up. May be one of [auto|prepend|chain|disabled]'
1470
1546
  },
1471
1547
  :'instrumentation.logger' => {
1472
1548
  :default => instrumentation_value_from_boolean(:'application_logging.enabled'),
@@ -1475,7 +1551,7 @@ module NewRelic
1475
1551
  :type => String,
1476
1552
  :dynamic_name => true,
1477
1553
  :allowed_from_server => false,
1478
- :description => 'Controls auto-instrumentation of Ruby standard library Logger at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1554
+ :description => 'Controls auto-instrumentation of Ruby standard library Logger at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1479
1555
  },
1480
1556
  :'instrumentation.memcache' => {
1481
1557
  :default => 'auto',
@@ -1483,7 +1559,7 @@ module NewRelic
1483
1559
  :type => String,
1484
1560
  :dynamic_name => true,
1485
1561
  :allowed_from_server => false,
1486
- :description => 'Controls auto-instrumentation of dalli gem for Memcache at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1562
+ :description => 'Controls auto-instrumentation of dalli gem for Memcache at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1487
1563
  },
1488
1564
  :'instrumentation.memcached' => {
1489
1565
  :default => 'auto',
@@ -1492,7 +1568,7 @@ module NewRelic
1492
1568
  :type => String,
1493
1569
  :dynamic_name => true,
1494
1570
  :allowed_from_server => false,
1495
- :description => 'Controls auto-instrumentation of memcached gem for Memcache at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1571
+ :description => 'Controls auto-instrumentation of memcached gem for Memcache at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1496
1572
  },
1497
1573
  :'instrumentation.memcache_client' => {
1498
1574
  :default => 'auto',
@@ -1501,7 +1577,7 @@ module NewRelic
1501
1577
  :type => String,
1502
1578
  :dynamic_name => true,
1503
1579
  :allowed_from_server => false,
1504
- :description => 'Controls auto-instrumentation of memcache-client gem for Memcache at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1580
+ :description => 'Controls auto-instrumentation of memcache-client gem for Memcache at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1505
1581
  },
1506
1582
  :'instrumentation.mongo' => {
1507
1583
  :default => 'enabled',
@@ -1510,7 +1586,7 @@ module NewRelic
1510
1586
  :type => String,
1511
1587
  :dynamic_name => true,
1512
1588
  :allowed_from_server => false,
1513
- :description => 'Controls auto-instrumentation of Mongo at start up. May be one of: `enabled`, `disabled`.'
1589
+ :description => 'Controls auto-instrumentation of Mongo at start-up. May be one of: `enabled`, `disabled`.'
1514
1590
  },
1515
1591
  :'instrumentation.net_http' => {
1516
1592
  :default => 'auto',
@@ -1519,7 +1595,16 @@ module NewRelic
1519
1595
  :type => String,
1520
1596
  :dynamic_name => true,
1521
1597
  :allowed_from_server => false,
1522
- :description => 'Controls auto-instrumentation of `Net::HTTP` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1598
+ :description => 'Controls auto-instrumentation of `Net::HTTP` at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1599
+ },
1600
+ :'instrumentation.ruby_openai' => {
1601
+ :default => 'auto',
1602
+ :documentation_default => 'auto',
1603
+ :public => true,
1604
+ :type => String,
1605
+ :dynamic_name => true,
1606
+ :allowed_from_server => false,
1607
+ :description => 'Controls auto-instrumentation of the ruby-openai gem at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1523
1608
  },
1524
1609
  :'instrumentation.puma_rack' => {
1525
1610
  :default => value_of(:'instrumentation.rack'),
@@ -1539,7 +1624,7 @@ module NewRelic
1539
1624
  :type => String,
1540
1625
  :dynamic_name => true,
1541
1626
  :allowed_from_server => false,
1542
- :description => 'Controls auto-instrumentation of `Puma::Rack::URLMap` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1627
+ :description => 'Controls auto-instrumentation of `Puma::Rack::URLMap` at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1543
1628
  },
1544
1629
  :'instrumentation.rack' => {
1545
1630
  :default => 'auto',
@@ -1559,7 +1644,7 @@ module NewRelic
1559
1644
  :type => String,
1560
1645
  :dynamic_name => true,
1561
1646
  :allowed_from_server => false,
1562
- :description => 'Controls auto-instrumentation of `Rack::URLMap` at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1647
+ :description => 'Controls auto-instrumentation of `Rack::URLMap` at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1563
1648
  },
1564
1649
  :'instrumentation.rake' => {
1565
1650
  :default => 'auto',
@@ -1567,7 +1652,7 @@ module NewRelic
1567
1652
  :type => String,
1568
1653
  :dynamic_name => true,
1569
1654
  :allowed_from_server => false,
1570
- :description => 'Controls auto-instrumentation of rake at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1655
+ :description => 'Controls auto-instrumentation of rake at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1571
1656
  },
1572
1657
  :'instrumentation.redis' => {
1573
1658
  :default => 'auto',
@@ -1575,7 +1660,7 @@ module NewRelic
1575
1660
  :type => String,
1576
1661
  :dynamic_name => true,
1577
1662
  :allowed_from_server => false,
1578
- :description => 'Controls auto-instrumentation of Redis at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1663
+ :description => 'Controls auto-instrumentation of Redis at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1579
1664
  },
1580
1665
  :'instrumentation.resque' => {
1581
1666
  :default => 'auto',
@@ -1584,7 +1669,7 @@ module NewRelic
1584
1669
  :type => String,
1585
1670
  :dynamic_name => true,
1586
1671
  :allowed_from_server => false,
1587
- :description => 'Controls auto-instrumentation of resque at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1672
+ :description => 'Controls auto-instrumentation of resque at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1588
1673
  },
1589
1674
  :'instrumentation.roda' => {
1590
1675
  :default => 'auto',
@@ -1592,7 +1677,7 @@ module NewRelic
1592
1677
  :type => String,
1593
1678
  :dynamic_name => true,
1594
1679
  :allowed_from_server => false,
1595
- :description => 'Controls auto-instrumentation of Roda at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1680
+ :description => 'Controls auto-instrumentation of Roda at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1596
1681
  },
1597
1682
  :'instrumentation.sinatra' => {
1598
1683
  :default => 'auto',
@@ -1600,7 +1685,7 @@ module NewRelic
1600
1685
  :type => String,
1601
1686
  :dynamic_name => true,
1602
1687
  :allowed_from_server => false,
1603
- :description => 'Controls auto-instrumentation of Sinatra at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1688
+ :description => 'Controls auto-instrumentation of Sinatra at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1604
1689
  },
1605
1690
  :'instrumentation.stripe' => {
1606
1691
  :default => 'enabled',
@@ -1609,6 +1694,14 @@ module NewRelic
1609
1694
  :allowed_from_server => false,
1610
1695
  :description => 'Controls auto-instrumentation of Stripe at startup. May be one of: `enabled`, `disabled`.'
1611
1696
  },
1697
+ :'instrumentation.view_component' => {
1698
+ :default => 'auto',
1699
+ :public => true,
1700
+ :type => String,
1701
+ :dynamic_name => true,
1702
+ :allowed_from_server => false,
1703
+ :description => 'Controls auto-instrumentation of ViewComponent at startup. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1704
+ },
1612
1705
  :'stripe.user_data.include' => {
1613
1706
  default: NewRelic::EMPTY_ARRAY,
1614
1707
  public: true,
@@ -1633,7 +1726,7 @@ module NewRelic
1633
1726
  An array of strings to specify which keys and/or values inside a Stripe event's `user_data` hash should
1634
1727
  not be reported to New Relic. Each string in this array will be turned into a regular expression via
1635
1728
  `Regexp.new` to permit advanced matching. For each hash pair, if either the key or value is matched the
1636
- pair will not be reported. By default, no `user_data` is reported, so this option should only be used if
1729
+ pair will not be reported. By default, no `user_data` is reported, so this option should only be used if
1637
1730
  the `stripe.user_data.include` option is being used.
1638
1731
  DESCRIPTION
1639
1732
  },
@@ -1643,14 +1736,14 @@ module NewRelic
1643
1736
  :type => String,
1644
1737
  :dynamic_name => true,
1645
1738
  :allowed_from_server => false,
1646
- :description => 'Controls auto-instrumentation of the Thread class at start up to allow the agent to correctly nest spans inside of an asynchronous transaction. This does not enable the agent to automatically trace all threads created (see `instrumentation.thread.tracing`). May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1739
+ :description => 'Controls auto-instrumentation of the Thread class at start-up to allow the agent to correctly nest spans inside of an asynchronous transaction. This does not enable the agent to automatically trace all threads created (see `instrumentation.thread.tracing`). May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1647
1740
  },
1648
1741
  :'instrumentation.thread.tracing' => {
1649
1742
  :default => true,
1650
1743
  :public => true,
1651
1744
  :type => Boolean,
1652
1745
  :allowed_from_server => false,
1653
- :description => 'Controls auto-instrumentation of the Thread class at start up to automatically add tracing to all Threads created in the application.'
1746
+ :description => 'Controls auto-instrumentation of the Thread class at start-up to automatically add tracing to all Threads created in the application.'
1654
1747
  },
1655
1748
  :'thread_ids_enabled' => {
1656
1749
  :default => false,
@@ -1665,7 +1758,7 @@ module NewRelic
1665
1758
  :type => String,
1666
1759
  :dynamic_name => true,
1667
1760
  :allowed_from_server => false,
1668
- :description => 'Controls auto-instrumentation of the Tilt template rendering library at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1761
+ :description => 'Controls auto-instrumentation of the Tilt template rendering library at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1669
1762
  },
1670
1763
  :'instrumentation.typhoeus' => {
1671
1764
  :default => 'auto',
@@ -1674,7 +1767,7 @@ module NewRelic
1674
1767
  :type => String,
1675
1768
  :dynamic_name => true,
1676
1769
  :allowed_from_server => false,
1677
- :description => 'Controls auto-instrumentation of Typhoeus at start up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1770
+ :description => 'Controls auto-instrumentation of Typhoeus at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1678
1771
  },
1679
1772
  # Message tracer
1680
1773
  :'message_tracer.segment_parameters.enabled' => {
@@ -2180,7 +2273,8 @@ module NewRelic
2180
2273
  :public => false,
2181
2274
  :type => String,
2182
2275
  :allowed_from_server => true,
2183
- :description => 'JavaScript agent loader content.'
2276
+ :description => 'JavaScript agent loader content.',
2277
+ :exclude_from_reported_settings => true
2184
2278
  },
2185
2279
  :keep_alive_timeout => {
2186
2280
  :default => 60,
@@ -2307,7 +2401,7 @@ module NewRelic
2307
2401
  :public => false,
2308
2402
  :type => Boolean,
2309
2403
  :allowed_from_server => false,
2310
- :description => 'Used in tests for the agent to start up, but not connect to the collector. Formerly used `developer_mode` in test config for this purpose.'
2404
+ :description => 'Used in tests for the agent to start-up, but not connect to the collector. Formerly used `developer_mode` in test config for this purpose.'
2311
2405
  },
2312
2406
  :'thread_profiler.max_profile_overhead' => {
2313
2407
  :default => 0.05,
@@ -2356,6 +2450,7 @@ module NewRelic
2356
2450
  :description => 'This value represents the total amount of memory available to the host (not the process), in mebibytes (1024 squared or 1,048,576 bytes).'
2357
2451
  }
2358
2452
  }.freeze
2453
+ # rubocop:enable Metrics/CollectionLiteralLength
2359
2454
  end
2360
2455
  end
2361
2456
  end
@@ -19,6 +19,7 @@ module NewRelic
19
19
  :'elasticsearch.obfuscate_queries' => true,
20
20
  :'transaction_tracer.record_redis_arguments' => false,
21
21
 
22
+ :'ai_monitoring.enabled' => false,
22
23
  :'custom_insights_events.enabled' => false,
23
24
  :'strip_exception_messages.enabled' => true
24
25
  })
@@ -34,6 +34,7 @@ module NewRelic
34
34
  def initialize
35
35
  reset_to_defaults
36
36
  @callbacks = Hash.new { |hash, key| hash[key] = [] }
37
+ @lock = Mutex.new
37
38
  end
38
39
 
39
40
  def add_config_for_testing(source, level = 0)
@@ -230,7 +231,7 @@ module NewRelic
230
231
  end
231
232
 
232
233
  def to_collector_hash
233
- DottedHash.new(apply_mask(flattened)).to_hash.delete_if do |k, v|
234
+ DottedHash.new(apply_mask(flattened)).to_hash.delete_if do |k, _v|
234
235
  default = DEFAULTS[k]
235
236
  if default
236
237
  default[:exclude_from_reported_settings]
@@ -364,9 +365,11 @@ module NewRelic
364
365
  def reset_cache
365
366
  return new_cache unless defined?(@cache) && @cache
366
367
 
367
- preserved = @cache.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
368
- new_cache
369
- preserved.each { |k, v| @cache[k] = v }
368
+ @lock.synchronize do
369
+ preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
370
+ new_cache
371
+ preserved.each { |k, v| @cache[k] = v }
372
+ end
370
373
 
371
374
  @cache
372
375
  end
@@ -376,12 +379,13 @@ module NewRelic
376
379
  end
377
380
 
378
381
  def log_config(direction, source)
379
- # Just generating this log message (specifically calling
380
- # flattened.inspect) is expensive enough that we don't want to do it
381
- # unless we're actually going to be logging the message based on our
382
- # current log level.
382
+ # Just generating this log message (specifically calling `flattened`)
383
+ # is expensive enough that we don't want to do it unless we're
384
+ # actually going to be logging the message based on our current log
385
+ # level, so use a `do` block.
383
386
  ::NewRelic::Agent.logger.debug do
384
- "Updating config (#{direction}) from #{source.class}. Results: #{flattened.inspect}"
387
+ hash = flattened.delete_if { |k, _h| DEFAULTS.fetch(k, {}).fetch(:exclude_from_reported_settings, false) }
388
+ "Updating config (#{direction}) from #{source.class}. Results: #{hash.inspect}"
385
389
  end
386
390
  end
387
391
 
@@ -7,6 +7,8 @@ require 'new_relic/agent/configuration/dotted_hash'
7
7
  module NewRelic
8
8
  module Agent
9
9
  module Configuration
10
+ # The Language Security Policy Source gives customers the ability to
11
+ # configure high security mode settings.
10
12
  class SecurityPolicySource < DottedHash
11
13
  class << self
12
14
  def enabled?(option)
@@ -147,6 +149,15 @@ module NewRelic
147
149
  permitted_fn: nil
148
150
  }
149
151
  ],
152
+ 'ai_monitoring' => [
153
+ {
154
+ option: :'ai_monitoring.enabled',
155
+ supported: true,
156
+ enabled_fn: method(:enabled?),
157
+ disabled_value: false,
158
+ permitted_fn: nil
159
+ }
160
+ ],
150
161
  'allow_raw_exception_messages' => [
151
162
  {
152
163
  option: :'strip_exception_messages.enabled',
@@ -14,6 +14,9 @@ module NewRelic
14
14
  TIMESTAMP = 'timestamp'.freeze
15
15
  PRIORITY = 'priority'.freeze
16
16
  EVENT_TYPE_REGEX = /^[a-zA-Z0-9:_ ]+$/.freeze
17
+ MAX_ATTRIBUTE_COUNT = 64
18
+ MAX_ATTRIBUTE_SIZE = 4095
19
+ MAX_NAME_SIZE = 255
17
20
 
18
21
  named :CustomEventAggregator
19
22
  capacity_key :'custom_insights_events.max_samples_stored'
@@ -49,10 +52,33 @@ module NewRelic
49
52
  {TYPE => type,
50
53
  TIMESTAMP => Process.clock_gettime(Process::CLOCK_REALTIME).to_i,
51
54
  PRIORITY => priority},
52
- AttributeProcessing.flatten_and_coerce(attributes)
55
+ create_custom_event_attributes(type, attributes)
53
56
  ]
54
57
  end
55
58
 
59
+ def create_custom_event_attributes(type, attributes)
60
+ result = AttributeProcessing.flatten_and_coerce(attributes)
61
+
62
+ if result.size > MAX_ATTRIBUTE_COUNT
63
+ NewRelic::Agent.logger.warn("Custom event attributes are limited to #{MAX_ATTRIBUTE_COUNT}. Discarding #{result.size - MAX_ATTRIBUTE_COUNT} attributes")
64
+ result = result.first(MAX_ATTRIBUTE_COUNT)
65
+ end
66
+
67
+ result.each_with_object({}) do |(key, val), new_result|
68
+ # name is limited to 255
69
+ if key.is_a?(String) && key.length > MAX_NAME_SIZE
70
+ key = key[0, MAX_NAME_SIZE]
71
+ end
72
+
73
+ # value is limited to 4095 except for LLM content-related events
74
+ if val.is_a?(String) && val.length > MAX_ATTRIBUTE_SIZE
75
+ val = val[0, MAX_ATTRIBUTE_SIZE] unless NewRelic::Agent::LLM.exempt_event_attribute?(type, key)
76
+ end
77
+
78
+ new_result[key] = val
79
+ end
80
+ end
81
+
56
82
  def after_initialize
57
83
  @type_strings = Hash.new { |hash, key| hash[key] = key.to_s.freeze }
58
84
  end
@@ -128,7 +128,7 @@ module NewRelic
128
128
  end
129
129
 
130
130
  def self.drop_indexes?(name, payload)
131
- name == :deleteIndexes && payload[:selector] && payload[:selector][:index] == '*'
131
+ name == :deleteIndexes && payload[:selector] && payload[:selector][:index] == ASTERISK
132
132
  end
133
133
 
134
134
  def self.drop_index?(name, payload)
@@ -3,7 +3,7 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  require 'json'
6
- require 'base64'
6
+ require 'new_relic/base64'
7
7
 
8
8
  module NewRelic
9
9
  module Agent
@@ -78,7 +78,7 @@ module NewRelic
78
78
  end
79
79
 
80
80
  def from_http_safe(http_safe_payload)
81
- decoded_payload = Base64.strict_decode64(http_safe_payload)
81
+ decoded_payload = NewRelic::Base64.strict_decode64(http_safe_payload)
82
82
  from_json(decoded_payload)
83
83
  end
84
84
 
@@ -156,7 +156,7 @@ module NewRelic
156
156
  #
157
157
  # @api public
158
158
  def http_safe
159
- Base64.strict_encode64(text)
159
+ NewRelic::Base64.strict_encode64(text)
160
160
  end
161
161
  end
162
162
  end
@@ -216,6 +216,8 @@ module NewRelic
216
216
  def notice_segment_error(segment, exception, options = {})
217
217
  return if skip_notice_error?(exception)
218
218
 
219
+ options.merge!(segment.llm_event.error_attributes(exception)) if segment.llm_event
220
+
219
221
  segment.set_noticed_error(create_noticed_error(exception, options))
220
222
  exception
221
223
  rescue => e
@@ -156,7 +156,7 @@ module NewRelic
156
156
  end
157
157
 
158
158
  if !errors.empty?
159
- ::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in Agent Event Loop:", *errors)
159
+ ::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in agent event loop:", *errors)
160
160
  end
161
161
  end
162
162
 
@@ -14,6 +14,10 @@ module NewRelic
14
14
  #
15
15
  # @api public
16
16
  class AbstractRequest
17
+ LHOST = 'host'
18
+ UHOST = 'Host'
19
+ COLON = ':'
20
+
17
21
  %i[[] []= type host_from_header host method headers uri].each do |name|
18
22
  define_method(name) do
19
23
  not_implemented(name)