newrelic_rpm 9.19.0 → 9.20.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/lib/new_relic/agent/configuration/default_source.rb +85 -85
  4. data/lib/new_relic/agent/configuration/manager.rb +5 -2
  5. data/lib/new_relic/agent/configuration/yaml_source.rb +2 -2
  6. data/lib/new_relic/agent/database.rb +1 -1
  7. data/lib/new_relic/agent/database_adapter.rb +1 -1
  8. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  9. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -1
  10. data/lib/new_relic/agent/distributed_tracing.rb +2 -0
  11. data/lib/new_relic/agent/external.rb +2 -0
  12. data/lib/new_relic/agent/instrumentation/action_dispatch.rb +1 -1
  13. data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +1 -1
  14. data/lib/new_relic/agent/instrumentation/action_mailbox.rb +1 -1
  15. data/lib/new_relic/agent/instrumentation/action_mailer.rb +1 -1
  16. data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
  17. data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
  18. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +2 -2
  19. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +11 -9
  20. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/async_http.rb +1 -1
  22. data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +1 -1
  24. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -0
  25. data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
  26. data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +1 -2
  27. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +1 -1
  28. data/lib/new_relic/agent/instrumentation/ethon.rb +1 -1
  29. data/lib/new_relic/agent/instrumentation/excon.rb +1 -1
  30. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -4
  33. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +1 -1
  34. data/lib/new_relic/agent/instrumentation/httpx.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/logstasher.rb +1 -1
  36. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +1 -1
  37. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +2 -2
  38. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +1 -1
  39. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -1
  40. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -1
  41. data/lib/new_relic/agent/instrumentation/net_http.rb +2 -1
  42. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  43. data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +2 -2
  44. data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +2 -2
  45. data/lib/new_relic/agent/instrumentation/redis/constants.rb +2 -2
  46. data/lib/new_relic/agent/instrumentation/resque.rb +2 -2
  47. data/lib/new_relic/agent/instrumentation/roda.rb +1 -1
  48. data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +1 -1
  49. data/lib/new_relic/agent/instrumentation/ruby_openai.rb +2 -2
  50. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  51. data/lib/new_relic/agent/instrumentation/stripe.rb +1 -1
  52. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
  53. data/lib/new_relic/agent/llm/chat_completion_summary.rb +1 -1
  54. data/lib/new_relic/agent/llm/embedding.rb +1 -1
  55. data/lib/new_relic/agent/local_log_decorator.rb +1 -1
  56. data/lib/new_relic/agent/logging.rb +1 -1
  57. data/lib/new_relic/agent/messaging.rb +5 -0
  58. data/lib/new_relic/agent/method_tracer.rb +3 -0
  59. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
  60. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +1 -1
  61. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
  62. data/lib/new_relic/agent/opentelemetry/context/propagation/trace_propagator.rb +66 -0
  63. data/lib/new_relic/agent/opentelemetry/context/propagation.rb +15 -0
  64. data/lib/new_relic/agent/opentelemetry/context.rb +13 -0
  65. data/lib/new_relic/agent/opentelemetry/trace/span.rb +15 -7
  66. data/lib/new_relic/agent/opentelemetry/trace/tracer.rb +106 -15
  67. data/lib/new_relic/agent/opentelemetry/transaction_patch.rb +69 -0
  68. data/lib/new_relic/agent/opentelemetry_bridge.rb +7 -1
  69. data/lib/new_relic/agent/parameter_filtering.rb +1 -1
  70. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  71. data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
  72. data/lib/new_relic/agent/span_event_primitive.rb +5 -0
  73. data/lib/new_relic/agent/tracer.rb +1 -1
  74. data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
  75. data/lib/new_relic/agent/transaction/distributed_tracer.rb +3 -3
  76. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -1
  77. data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
  78. data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -1
  79. data/lib/new_relic/agent/utilization/ecs.rb +22 -0
  80. data/lib/new_relic/agent/utilization/ecs_v4.rb +22 -0
  81. data/lib/new_relic/agent/utilization_data.rb +25 -0
  82. data/lib/new_relic/agent/vm/c_ruby_vm.rb +3 -3
  83. data/lib/new_relic/agent.rb +28 -0
  84. data/lib/new_relic/constants.rb +1 -0
  85. data/lib/new_relic/control/instrumentation.rb +1 -1
  86. data/lib/new_relic/dependency_detection.rb +0 -1
  87. data/lib/new_relic/helper.rb +7 -0
  88. data/lib/new_relic/version.rb +1 -1
  89. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  90. data/lib/tasks/helpers/newrelicyml.rb +2 -0
  91. data/newrelic.yml +14 -14
  92. data/newrelic_rpm.gemspec +1 -1
  93. metadata +11 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a2b588c4be509b5a02bb0516a47e9329cab3bcf79c97f614d4349291db0876f
4
- data.tar.gz: 30f1dcd2997242e38836aa3325badb71656aaa3aa074857a2edad75f6e21972b
3
+ metadata.gz: 7534628f5d1c53ceff110ad76f2c63a3773d32f7f13d7146ff4c7da72ecef143
4
+ data.tar.gz: aeacda7d6851268da1e67d61376088902e9fa6080d184d91ea1bdbda632af889
5
5
  SHA512:
6
- metadata.gz: 6915cfd19ea57029473609dd02b4e9bd110aaa3766f13af648705a0132d4608f33051ad0e44f6c03f72b037eb99c64f1992c92408d1caedd3381538e906c4b0d
7
- data.tar.gz: 87c1d548bd4a78eb26706eae9f1932c9fb394c05f16e8d4603ce8b690e4df255fdd8748f7f2b09501a7e73770961ec20f6df07435255db293bb4e7395400094c
6
+ metadata.gz: fa3dfb1d4971a14c83e57b2de5fc20298f95e7e75dbba07631ec7e70c962e263f8c10f046ed5f067d3b38ec629ebc57e5cad502679468f8a0245b0bddc1d7061
7
+ data.tar.gz: 95f05672fffa1af08da58e1d470cf40d9d0587aa2d2fa1a2db162a46b0bd11abd290e5150ef98de29dd43517ebeb2df1aaa836ae13a33f7835ef76534f14807c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # New Relic Ruby Agent Release Notes
2
2
 
3
+ ## v9.20.0
4
+
5
+ - **Feature: Add ECS Docker ID for Fargate**
6
+
7
+ Previously, the Ruby agent did not record the Docker ID when running in an AWS ECS Fargate environment. The Docker ID will now be recorded correctly. [PR#3172](https://github.com/newrelic/newrelic-ruby-agent/pull/3172)
8
+
9
+ - **Feature: Add NewRelic::Helper.version_satisfied?**
10
+
11
+ The agent has a new helper method to simplify version comparison. `NewRelic::Helper.version_satisfied?` accepts three arguments: a left-side version number, the comparison operator as a string, and a right-side version number. Our thanks go to [@kekke-n](https://github.com/kekke-n) for this contribution. [PR#3182](https://github.com/newrelic/newrelic-ruby-agent/pull/3182)
12
+
13
+ - **Feature: Add code.stacktrace attribute on datastore spans when duration exceeds configured threshold**
14
+
15
+ The agent will now add the `code.stacktrace` attribute to datastore spans when the duration exceeds the configured threshold. The threshold is configured using the `transaction_tracer.stack_trace_threshold` configuration option. [PR#3220](https://github.com/newrelic/newrelic-ruby-agent/pull/3220)
16
+
17
+ - **Feature: Consolidate "Unknown" constant values**
18
+
19
+ All references to the various capitalization styles for "Unknown" have been consolidated into two constants: `NewRelic::UNKNOWN` and `NewRelic::UNKNOWN_LOWER`. Thank you, [@tsubasa1122](https://github.com/@tsubasa1122), for your contribution! [PR#3185](https://github.com/newrelic/newrelic-ruby-agent/pull/3185)
20
+
21
+ - **Bugfix: Fix Brewfile source links**
22
+
23
+ Previously, the multiverse README's links to the Brewfile were broken. Our thanks go to [@emmanuel-ferdman](https://github.com/emmanuel-ferdman) for submitting a PR to fix them! [PR#3191](https://github.com/newrelic/newrelic-ruby-agent/pull/3191)
24
+
25
+ - **Bugfix: Fix error when using HTTPX 1.5.0**
26
+
27
+ The agent previously encountered an error when using the new HTTPX version 1.5.0. This was due to a change in the way HTTPX stores the response. The agent has been updated to handle this change correctly, and no longer encounters an error when using HTTPX 1.5.0. [PR#3203](https://github.com/newrelic/newrelic-ruby-agent/pull/3203)
28
+
29
+ - **Bugfix: Bugfixes and improvements to debug level agent logs**
30
+
31
+ Improves the information logged at the debug level by the agent when the agent reads in a configuration source. [PR#3221](https://github.com/newrelic/newrelic-ruby-agent/pull/3221)
32
+
33
+ - **Bugfix: Fix risk of server-side forgery for Slack workflow script**
34
+
35
+ Internally, we keep track of gems that are released using a GitHub actions workflow that posts updates on Slack. [@odaysec] identified a way we could reduce the risk of server-side forgery for this workflow. Thank you! [PR#3184](https://github.com/newrelic/newrelic-ruby-agent/pull/3184)
36
+
37
+ - **Bugfix: Replace JSON.load calls with JSON.parse**
38
+
39
+ Generally, JSON.parse is seen as safer than JSON.load. Thank you, [@odaysec](https://github.com/odaysec), for bringing this to our attention! [PR#3183](https://github.com/newrelic/newrelic-ruby-agent/pull/3183) [PR#3230](https://github.com/newrelic/newrelic-ruby-agent/pull/3230)
40
+
3
41
  ## v9.19.0
4
42
 
5
43
  - **Feature: Add Thread ID as attribute to all spans**
@@ -387,9 +387,9 @@ module NewRelic
387
387
  :allowed_from_server => false,
388
388
  :description => <<~DESCRIPTION
389
389
  An array of ActiveSupport custom event names to subscribe to and instrument. For example,
390
- - one.custom.event
391
- - another.event
392
- - a.third.event
390
+ \t\t- one.custom.event
391
+ \t\t- another.event
392
+ \t\t- a.third.event
393
393
  DESCRIPTION
394
394
  },
395
395
  :'ai_monitoring.enabled' => {
@@ -407,11 +407,11 @@ module NewRelic
407
407
  :description => <<~DESCRIPTION
408
408
  If `false`, LLM instrumentation (OpenAI only for now) will not capture input and output content on specific LLM events.
409
409
 
410
- The excluded attributes include:
411
- - `content` from LlmChatCompletionMessage events
412
- - `input` from LlmEmbedding events
410
+ \tThe excluded attributes include:
411
+ \t- `content` from LlmChatCompletionMessage events
412
+ \t- `input` from LlmEmbedding events
413
413
 
414
- This is an optional security setting to prevent recording sensitive data sent to and received from your LLMs.
414
+ \tThis is an optional security setting to prevent recording sensitive data sent to and received from your LLMs.
415
415
  DESCRIPTION
416
416
  },
417
417
  # this is only set via server side config
@@ -461,7 +461,7 @@ module NewRelic
461
461
  When `true`, the agent captures HTTP request parameters and attaches them to transaction traces, traced errors, and [`TransactionError` events](/attribute-dictionary?attribute_name=&events_tids%5B%5D=8241).
462
462
 
463
463
  <Callout variant="caution">
464
- When using the `capture_params` setting, the Ruby agent will not attempt to filter secret information. `Recommendation:` To filter secret information from request parameters, use the [`attributes.include` setting](/docs/agents/ruby-agent/attributes/enable-disable-attributes-ruby) instead. For more information, see the <a href="/docs/agents/ruby-agent/attributes/ruby-attribute-examples#ex_req_params">Ruby attribute examples</a>.
464
+ \tWhen using the `capture_params` setting, the Ruby agent will not attempt to filter secret information. `Recommendation:` To filter secret information from request parameters, use the [`attributes.include` setting](/docs/agents/ruby-agent/attributes/enable-disable-attributes-ruby) instead. For more information, see the <a href="/docs/agents/ruby-agent/attributes/ruby-attribute-examples#ex_req_params">Ruby attribute examples</a>.
465
465
  </Callout>
466
466
  DESCRIPTION
467
467
  },
@@ -487,10 +487,10 @@ module NewRelic
487
487
  :allowed_from_server => false,
488
488
  :description => <<~DESC
489
489
  Path to `newrelic.yml`. If undefined, the agent checks the following directories (in order):
490
- - `config/newrelic.yml`
491
- - `newrelic.yml`
492
- - `$HOME/.newrelic/newrelic.yml`
493
- - `$HOME/newrelic.yml`
490
+ \t- `config/newrelic.yml`
491
+ \t- `newrelic.yml`
492
+ \t- `$HOME/.newrelic/newrelic.yml`
493
+ \t- `$HOME/newrelic.yml`
494
494
  DESC
495
495
  },
496
496
  :'exclude_newrelic_header' => {
@@ -676,10 +676,10 @@ module NewRelic
676
676
  :allowed_from_server => true,
677
677
  :description => <<~DESC
678
678
  Obfuscation level for SQL queries reported in transaction trace nodes.
679
- By default, this is set to `obfuscated`, which strips out the numeric and string literals.
680
- - If you do not want the agent to capture query information, set this to `none`.
681
- - If you want the agent to capture all query information in its original form, set this to `raw`.
682
- - When you enable [high security mode](/docs/agents/manage-apm-agents/configuration/high-security-mode), this is automatically set to `obfuscated`.
679
+ \tBy default, this is set to `obfuscated`, which strips out the numeric and string literals.
680
+ \t- If you do not want the agent to capture query information, set this to `none`.
681
+ \t- If you want the agent to capture all query information in its original form, set this to `raw`.
682
+ \t- When you enable [high security mode](/docs/agents/manage-apm-agents/configuration/high-security-mode), this is automatically set to `obfuscated`.
683
683
  DESC
684
684
  },
685
685
 
@@ -722,9 +722,9 @@ module NewRelic
722
722
  :dynamic_name => true,
723
723
  :description => <<~DESCRIPTION
724
724
  A list of error classes that the agent should treat as expected.
725
- <Callout variant="caution">
726
- This option can't be set via environment variable.
727
- </Callout>
725
+ \t<Callout variant="caution">
726
+ \t\tThis option can't be set via environment variable.
727
+ \t</Callout>
728
728
  DESCRIPTION
729
729
  },
730
730
  :'error_collector.expected_messages' => {
@@ -735,9 +735,9 @@ module NewRelic
735
735
  :dynamic_name => true,
736
736
  :description => <<~DESCRIPTION
737
737
  A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be treated as expected.
738
- <Callout variant="caution">
739
- This option can't be set via environment variable.
740
- </Callout>
738
+ \t<Callout variant="caution">
739
+ \t\tThis option can't be set via environment variable.
740
+ \t</Callout>
741
741
  DESCRIPTION
742
742
  },
743
743
  :'error_collector.expected_status_codes' => {
@@ -756,9 +756,9 @@ module NewRelic
756
756
  :dynamic_name => true,
757
757
  :description => <<~DESCRIPTION
758
758
  A list of error classes that the agent should ignore.
759
- <Callout variant="caution">
760
- This option can't be set via environment variable.
761
- </Callout>
759
+ \t<Callout variant="caution">
760
+ \t\tThis option can't be set via environment variable.
761
+ \t</Callout>
762
762
  DESCRIPTION
763
763
  },
764
764
  :'error_collector.ignore_messages' => {
@@ -774,9 +774,9 @@ module NewRelic
774
774
  :dynamic_name => true,
775
775
  :description => <<~DESCRIPTION
776
776
  A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be ignored.
777
- <Callout variant="caution">
778
- This option can't be set via environment variable.
779
- </Callout>
777
+ \t<Callout variant="caution">
778
+ \t\tThis option can't be set via environment variable.
779
+ \t</Callout>
780
780
  DESCRIPTION
781
781
  },
782
782
  :'error_collector.ignore_status_codes' => {
@@ -858,19 +858,19 @@ module NewRelic
858
858
  :description => <<~DESCRIPTION
859
859
  Sets the minimum level a log event must have to be forwarded to New Relic.
860
860
 
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).
861
+ \tThis is based on the integer values of [Ruby's `Logger::Severity` constants](https://github.com/ruby/logger/blob/113b82a06b3076b93a71cd467e1605b23afb3088/lib/logger/severity.rb).
862
862
 
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.
863
+ \tThe intention is to forward logs with the level given to the configuration, as well as any logs with a higher level of severity.
864
864
 
865
- For example, setting this value to "debug" will forward all log events to New Relic. Setting this value to "error" will only forward log events with the levels "error", "fatal", and "unknown".
865
+ \tFor example, setting this value to "debug" will forward all log events to New Relic. Setting this value to "error" will only forward log events with the levels "error", "fatal", and "unknown".
866
866
 
867
- Valid values (ordered lowest to highest):
868
- - "debug"
869
- - "info"
870
- - "warn"
871
- - "error"
872
- - "fatal"
873
- - "unknown"
867
+ \tValid values (ordered lowest to highest):
868
+ \t- "debug"
869
+ \t- "info"
870
+ \t- "warn"
871
+ \t- "error"
872
+ \t- "fatal"
873
+ \t- "unknown"
874
874
  DESCRIPTION
875
875
  },
876
876
  :'application_logging.forwarding.custom_attributes' => {
@@ -1153,7 +1153,7 @@ module NewRelic
1153
1153
  :public => true,
1154
1154
  :type => Boolean,
1155
1155
  :allowed_from_server => true,
1156
- :description => "If `true`, the agent will report source code level metrics for traced methods.\nSee: " \
1156
+ :description => "If `true`, the agent will report source code level metrics for traced methods.\n\tSee: " \
1157
1157
  'https://docs.newrelic.com/docs/apm/agents/ruby-agent/features/ruby-codestream-integration/'
1158
1158
  },
1159
1159
  # Cross application tracer
@@ -1165,7 +1165,7 @@ module NewRelic
1165
1165
  :deprecated => true,
1166
1166
  :description => deprecated_description(
1167
1167
  :'distributed_tracing.enabled',
1168
- 'If `true`, enables [cross-application tracing](/docs/agents/ruby-agent/features/cross-application-tracing-ruby/) when `distributed_tracing.enabled` is set to `false`.'
1168
+ ' If `true`, enables [cross-application tracing](/docs/agents/ruby-agent/features/cross-application-tracing-ruby/) when `distributed_tracing.enabled` is set to `false`.'
1169
1169
  )
1170
1170
  },
1171
1171
  # Custom attributes
@@ -1185,45 +1185,45 @@ module NewRelic
1185
1185
  :description => <<~DESCRIPTION
1186
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
1187
 
1188
- Use fully qualified class names (using the `::` delimiter) that include any module or class namespacing.
1188
+ \tUse fully qualified class names (using the `::` delimiter) that include any module or class namespacing.
1189
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:
1190
+ \tHere 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
1191
 
1192
- ```rb
1193
- module MyCompany
1194
- class Image
1195
- def render_png
1196
- # code to render a PNG
1197
- end
1198
- end
1192
+ \t```rb
1193
+ \t\tmodule MyCompany
1194
+ \t\t\tclass Image
1195
+ \t\t\t\tdef render_png
1196
+ \t\t\t\t\t# code to render a PNG
1197
+ \t\t\t\tend
1198
+ \t\t\tend
1199
1199
 
1200
- class User
1201
- def self.notify
1202
- # code to notify users
1203
- end
1204
- end
1205
- end
1206
- ```
1200
+ \t\t\tclass User
1201
+ \t\t\t\tdef self.notify
1202
+ \t\t\t\t\t# code to notify users
1203
+ \t\t\t\tend
1204
+ \t\t\tend
1205
+ \t\tend
1206
+ \t```
1207
1207
 
1208
- Given that source code, the `newrelic.yml` config file might request instrumentation for both of these methods like so:
1208
+ \tGiven that source code, the `newrelic.yml` config file might request instrumentation for both of these methods like so:
1209
1209
 
1210
- ```yaml
1211
- automatic_custom_instrumentation_method_list:
1212
- - MyCompany::Image#render_png
1213
- - MyCompany::User.notify
1214
- ```
1210
+ \t```yaml
1211
+ \t\tautomatic_custom_instrumentation_method_list:
1212
+ \t\t\t- MyCompany::Image#render_png
1213
+ \t\t\t- MyCompany::User.notify
1214
+ \t```
1215
1215
 
1216
- That configuration example uses YAML array syntax to specify both methods. Alternatively, you can use a comma-delimited string:
1216
+ \tThat configuration example uses YAML array syntax to specify both methods. Alternatively, you can use a comma-delimited string:
1217
1217
 
1218
- ```yaml
1219
- automatic_custom_instrumentation_method_list: 'MyCompany::Image#render_png, MyCompany::User.notify'
1220
- ```
1218
+ \t```yaml
1219
+ \t\tautomatic_custom_instrumentation_method_list: 'MyCompany::Image#render_png, MyCompany::User.notify'
1220
+ \t```
1221
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:
1222
+ \tWhitespace 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
1223
 
1224
- ```sh
1225
- export NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST='MyCompany::Image#render_png, MyCompany::User.notify'
1226
- ```
1224
+ \t```sh
1225
+ \t\texport NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST='MyCompany::Image#render_png, MyCompany::User.notify'
1226
+ \t```
1227
1227
  DESCRIPTION
1228
1228
  },
1229
1229
  # Custom events
@@ -1426,18 +1426,18 @@ module NewRelic
1426
1426
  :description => <<~DESCRIPTION
1427
1427
  If `true`, disables agent middleware for Sinatra. This middleware is responsible for advanced feature support such as [cross application tracing](/docs/apm/transactions/cross-application-traces/cross-application-tracing), [page load timing](/docs/browser/new-relic-browser/getting-started/new-relic-browser), and [error collection](/docs/apm/applications-menu/events/view-apm-error-analytics).
1428
1428
 
1429
- <Callout variant="important">
1430
- Cross application tracing is deprecated in favor of [distributed tracing](/docs/apm/distributed-tracing/getting-started/introduction-distributed-tracing). Distributed tracing is on by default for Ruby agent versions 8.0.0 and above. Middlewares are not required to support distributed tracing.
1429
+ \t<Callout variant="important">
1430
+ \t\tCross application tracing is deprecated in favor of [distributed tracing](/docs/apm/distributed-tracing/getting-started/introduction-distributed-tracing). Distributed tracing is on by default for Ruby agent versions 8.0.0 and above. Middlewares are not required to support distributed tracing.
1431
1431
 
1432
- To continue using cross application tracing, update the following options in your `newrelic.yml` configuration file:
1432
+ \t\tTo continue using cross application tracing, update the following options in your `newrelic.yml` configuration file:
1433
1433
 
1434
- ```yaml
1435
- cross_application_tracer:
1436
- enabled: true
1437
- distributed_tracing:
1438
- enabled: false
1439
- ```
1440
- </Callout>
1434
+ \t\t```yaml
1435
+ \t\t\tcross_application_tracer:
1436
+ \t\t\t\tenabled: true
1437
+ \t\t\tdistributed_tracing:
1438
+ \t\t\t\tenabled: false
1439
+ \t\t```
1440
+ \t</Callout>
1441
1441
  DESCRIPTION
1442
1442
  },
1443
1443
  :disable_view_instrumentation => {
@@ -1961,10 +1961,10 @@ module NewRelic
1961
1961
  :transform => DefaultSource.method(:convert_to_list),
1962
1962
  :description => <<~DESCRIPTION
1963
1963
  An array of strings to specify which keys and/or values inside a Stripe event's `user_data` hash should
1964
- not be reported to New Relic. Each string in this array will be turned into a regular expression via
1965
- `Regexp.new` to permit advanced matching. For each hash pair, if either the key or value is matched the pair
1966
- isn't reported. By default, no `user_data` is reported. Use this option only if the
1967
- `stripe.user_data.include` option is also used.
1964
+ \tnot be reported to New Relic. Each string in this array will be turned into a regular expression via
1965
+ \t`Regexp.new` to permit advanced matching. For each hash pair, if either the key or value is matched the pair
1966
+ \tisn't reported. By default, no `user_data` is reported. Use this option only if the
1967
+ \t`stripe.user_data.include` option is also used.
1968
1968
  DESCRIPTION
1969
1969
  },
1970
1970
  :'instrumentation.thread' => {
@@ -2065,7 +2065,7 @@ module NewRelic
2065
2065
  If `true`, when the agent is in an application using Ruby on Rails, it will start after `config/initializers` run.
2066
2066
 
2067
2067
  <Callout variant="caution">
2068
- This option may only be set by environment variable.
2068
+ \tThis option may only be set by environment variable.
2069
2069
  </Callout>
2070
2070
  DESCRIPTION
2071
2071
  },
@@ -382,6 +382,7 @@ module NewRelic
382
382
  @security_policy_source = nil
383
383
  @high_security_source = nil
384
384
  @environment_source = EnvironmentSource.new
385
+ log_config(:add, @environment_source) # this is the only place the EnvironmentSource is ever created, so we should log it
385
386
  @server_source = nil
386
387
  @manual_source = nil
387
388
  @yaml_source = nil
@@ -424,8 +425,10 @@ module NewRelic
424
425
  # actually going to be logging the message based on our current log
425
426
  # level, so use a `do` block.
426
427
  NewRelic::Agent.logger.debug do
427
- hash = flattened.delete_if { |k, _h| DEFAULTS.fetch(k, {}).fetch(:exclude_from_reported_settings, false) }
428
- "Updating config (#{direction}) from #{source.class}. Results: #{hash.inspect}"
428
+ source_hash = source.dup.to_h.delete_if { |k, _v| DEFAULTS.fetch(k, {}).fetch(:exclude_from_reported_settings, false) }
429
+ final_hash = flattened.delete_if { |k, _h| DEFAULTS.fetch(k, {}).fetch(:exclude_from_reported_settings, false) }
430
+
431
+ "Updating config (#{direction}) from #{source.class} with values: #{source_hash}. \nConfig Stack Results: #{final_hash.inspect}"
429
432
  end
430
433
  end
431
434
 
@@ -67,7 +67,7 @@ module NewRelic
67
67
  end
68
68
 
69
69
  def warn_missing_config_file(path)
70
- based_on = 'unknown'
70
+ based_on = NewRelic::UNKNOWN_LOWER
71
71
  source = ::NewRelic::Agent.config.source(:config_path)
72
72
  candidate_paths = [path]
73
73
 
@@ -103,7 +103,7 @@ module NewRelic
103
103
  NewRelic::Agent.agent&.health_check&.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_PARSE_CONFIG)
104
104
  message = 'Failed ERB processing configuration file. This is typically caused by a Ruby error in <% %> templating blocks in your newrelic.yml file.'
105
105
  failure_array = [message, e]
106
- failure_array << e.backtrace[0] if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0')
106
+ failure_array << e.backtrace[0] if NewRelic::Helper.version_satisfied?(RUBY_VERSION, '>=', '3.4.0')
107
107
  log_failure(*failure_array)
108
108
  nil
109
109
  end
@@ -123,7 +123,7 @@ module NewRelic
123
123
  return @supports_with_connection if defined?(@supports_with_connection)
124
124
 
125
125
  @supports_with_connection = defined?(::ActiveRecord::VERSION::STRING) &&
126
- Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.2.0')
126
+ NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::STRING, '>=', '7.2.0')
127
127
  end
128
128
 
129
129
  def close_connections
@@ -25,7 +25,7 @@ module NewRelic
25
25
  end
26
26
 
27
27
  def value
28
- match = VERSIONS.keys.find { |key| version >= Gem::Version.new(key) }
28
+ match = VERSIONS.keys.find { |key| NewRelic::Helper.version_satisfied?(version, '>=', key) }
29
29
  return unless match
30
30
 
31
31
  VERSIONS[match].call(env)
@@ -83,7 +83,7 @@ module NewRelic
83
83
  end
84
84
 
85
85
  def self.is_supported_version?
86
- Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('3.0.0')
86
+ NewRelic::Helper.version_satisfied?(::Redis::VERSION, '>=', '3.0.0')
87
87
  end
88
88
 
89
89
  def self.ellipsize(result, string)
@@ -207,7 +207,7 @@ module NewRelic
207
207
  decoded_appdata.set_encoding(::Encoding::UTF_8) if
208
208
  decoded_appdata.respond_to?(:set_encoding)
209
209
 
210
- ::JSON.load(decoded_appdata)
210
+ ::JSON.parse(decoded_appdata)
211
211
  end
212
212
 
213
213
  def valid_cross_app_id?(xp_id)
@@ -39,6 +39,7 @@ module NewRelic
39
39
  # @return {Transaction} The transaction the headers were inserted from,
40
40
  # or +nil+ if headers were not inserted.
41
41
  #
42
+ # @!scope class
42
43
  # @api public
43
44
  #
44
45
  def insert_distributed_trace_headers(headers = {})
@@ -93,6 +94,7 @@ module NewRelic
93
94
  #
94
95
  # @return {Transaction} if successful, +nil+ otherwise
95
96
  #
97
+ # @!scope class
96
98
  # @api public
97
99
  #
98
100
  def accept_distributed_trace_headers(headers, transport_type = NewRelic::HTTP)
@@ -29,6 +29,7 @@ module NewRelic
29
29
  #
30
30
  # @param request_metadata [String] received obfuscated request metadata
31
31
  #
32
+ # @!scope class
32
33
  # @api public
33
34
  #
34
35
  def process_request_metadata(request_metadata)
@@ -74,6 +75,7 @@ module NewRelic
74
75
  #
75
76
  # @return [String] obfuscated response metadata to send
76
77
  #
78
+ # @!scope class
77
79
  # @api public
78
80
  #
79
81
  def get_response_metadata
@@ -16,7 +16,7 @@ DependencyDetection.defer do
16
16
  defined?(ActionDispatch) &&
17
17
  defined?(ActionPack) &&
18
18
  ActionPack.respond_to?(:gem_version) &&
19
- ActionPack.gem_version >= Gem::Version.new('6.0.0') && # notifications for dispatch added in Rails 6
19
+ NewRelic::Helper.version_satisfied?(ActionPack.gem_version, '>=', '6.0.0') && # notifications for dispatch added in Rails 6
20
20
  !NewRelic::Agent::Instrumentation::ActionDispatchSubscriber.subscribed?
21
21
  end
22
22
 
@@ -45,7 +45,7 @@ module NewRelic
45
45
  end
46
46
 
47
47
  PATTERN = /\A([^\.]+)\.action_dispatch\z/
48
- UNKNOWN = 'unknown'.freeze
48
+ UNKNOWN = NewRelic::UNKNOWN_LOWER
49
49
 
50
50
  METHOD_NAME_MAPPING = Hash.new do |h, k|
51
51
  if PATTERN =~ k
@@ -15,7 +15,7 @@ DependencyDetection.defer do
15
15
  defined?(ActiveSupport) &&
16
16
  defined?(ActionMailbox) &&
17
17
  ActionMailbox.respond_to?(:gem_version) && # 'require "action_mailbox"' doesn't require version...
18
- ActionMailbox.gem_version >= Gem::Version.new('7.1.0.alpha') && # notifications added in Rails 7.1
18
+ NewRelic::Helper.version_satisfied?(ActionMailbox.gem_version, '>=', '7.1.0.alpha') && # notifications added in Rails 7.1
19
19
  !NewRelic::Agent::Instrumentation::ActionMailboxSubscriber.subscribed?
20
20
  end
21
21
 
@@ -15,7 +15,7 @@ DependencyDetection.defer do
15
15
  defined?(ActiveSupport) &&
16
16
  defined?(ActionMailer) &&
17
17
  ActionMailer.respond_to?(:gem_version) &&
18
- ActionMailer.gem_version >= Gem::Version.new('5.0') &&
18
+ NewRelic::Helper.version_satisfied?(ActionMailer.gem_version, '>=', '5.0') &&
19
19
  !NewRelic::Agent::Instrumentation::ActionMailerSubscriber.subscribed?
20
20
  end
21
21
 
@@ -30,7 +30,7 @@ DependencyDetection.defer do
30
30
  executes do
31
31
  if defined?(ActiveSupport) &&
32
32
  ActiveJob.respond_to?(:gem_version) &&
33
- ActiveJob.gem_version >= Gem::Version.new('6.0.0') &&
33
+ NewRelic::Helper.version_satisfied?(ActiveJob.gem_version, '>=', '6.0.0') &&
34
34
  !NewRelic::Agent.config[:disable_activejob] &&
35
35
  !NewRelic::Agent::Instrumentation::ActiveJobSubscriber.subscribed?
36
36
  NewRelic::Agent.logger.info('Installing notifications based ActiveJob instrumentation')
@@ -13,7 +13,8 @@ module NewRelic
13
13
  end
14
14
 
15
15
  def self.insert_instrumentation
16
- if defined?(::ActiveRecord::VERSION::MAJOR) && ::ActiveRecord::VERSION::MAJOR.to_i >= 3
16
+ if defined?(::ActiveRecord::VERSION::MAJOR) &&
17
+ NewRelic::Helper.version_satisfied?(::ActiveRecord::VERSION::MAJOR, '>=', 3)
17
18
  if ::NewRelic::Agent.config[:prepend_active_record_instrumentation]
18
19
  ::ActiveRecord::Base.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
19
20
  ::ActiveRecord::Relation.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
@@ -37,7 +38,7 @@ module NewRelic
37
38
  end
38
39
  end
39
40
 
40
- if RUBY_VERSION < '2.7.0'
41
+ if NewRelic::Helper.version_satisfied?(RUBY_VERSION, '<', '2.7.0')
41
42
  def log_with_newrelic_instrumentation(*args, &block)
42
43
  state = NewRelic::Agent::Tracer.state
43
44
 
@@ -137,7 +138,7 @@ DependencyDetection.defer do
137
138
  depends_on do
138
139
  defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
139
140
  (!defined?(ActiveRecord::VERSION) ||
140
- ActiveRecord::VERSION::MAJOR.to_i <= 3)
141
+ NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::MAJOR, '<=', 3))
141
142
  end
142
143
 
143
144
  depends_on do
@@ -151,7 +152,8 @@ DependencyDetection.defer do
151
152
  executes do
152
153
  require 'new_relic/agent/instrumentation/active_record_helper'
153
154
 
154
- if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR.to_i == 3
155
+ if defined?(Rails::VERSION::MAJOR) &&
156
+ NewRelic::Helper.version_satisfied?(Rails::VERSION::MAJOR, '==', 3)
155
157
  ActiveSupport.on_load(:active_record) do
156
158
  NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
157
159
  end
@@ -49,7 +49,7 @@ module NewRelic
49
49
 
50
50
  alias_method(:delete_all_without_newrelic, :delete_all)
51
51
 
52
- if RUBY_VERSION < '2.7.0'
52
+ if NewRelic::Helper.version_satisfied?(RUBY_VERSION, '<', '2.7.0')
53
53
  def delete_all(*args, &blk)
54
54
  ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
55
55
  delete_all_without_newrelic(*args, &blk)
@@ -235,7 +235,7 @@ module NewRelic
235
235
  }.freeze
236
236
 
237
237
  DEFAULT = 'default'.freeze
238
- UNKNOWN = 'unknown'.freeze
238
+ UNKNOWN = NewRelic::UNKNOWN_LOWER
239
239
  LOCALHOST = 'localhost'.freeze
240
240
 
241
241
  def adapter_from_config(config)
@@ -28,7 +28,7 @@ module NewRelic
28
28
  ) { yield }
29
29
  rescue => e
30
30
  # The translate_exception_class method got introduced in 4.1
31
- if ::ActiveRecord::VERSION::MINOR == 0
31
+ if NewRelic::Helper.version_satisfied?(::ActiveRecord::VERSION::MINOR, '==', 0)
32
32
  raise translate_exception(e, sql)
33
33
  else
34
34
  raise translate_exception_class(e, sql)
@@ -86,7 +86,7 @@ DependencyDetection.defer do
86
86
  depends_on do
87
87
  defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
88
88
  defined?(ActiveRecord::VERSION) &&
89
- ActiveRecord::VERSION::MAJOR.to_i >= 4
89
+ NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::MAJOR, '>=', 4)
90
90
  end
91
91
 
92
92
  depends_on do
@@ -113,7 +113,7 @@ DependencyDetection.defer do
113
113
 
114
114
  # Default to .prepending, unless the ActiveRecord version is <=4
115
115
  # **AND** the :prepend_active_record_instrumentation config is false
116
- if ActiveRecord::VERSION::MAJOR > 4 \
116
+ if NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::MAJOR, '>', 4) \
117
117
  || NewRelic::Agent.config[:prepend_active_record_instrumentation]
118
118
 
119
119
  ActiveRecord::Base.send(:prepend,
@@ -131,11 +131,13 @@ DependencyDetection.defer do
131
131
  major_version = ActiveRecord::VERSION::MAJOR.to_i
132
132
  minor_version = ActiveRecord::VERSION::MINOR.to_i
133
133
 
134
- activerecord_extension = if major_version == 4
134
+ activerecord_extension = if NewRelic::Helper.version_satisfied?(major_version, '==', 4)
135
135
  NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x
136
- elsif major_version == 5 && minor_version == 0
136
+ elsif NewRelic::Helper.version_satisfied?(major_version, '==', 5) &&
137
+ NewRelic::Helper.version_satisfied?(minor_version, '==', 0)
137
138
  NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions50
138
- elsif major_version == 5 && minor_version == 1
139
+ elsif NewRelic::Helper.version_satisfied?(major_version, '==', 5) &&
140
+ NewRelic::Helper.version_satisfied?(minor_version, '==', 1)
139
141
  NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions51
140
142
  end
141
143
 
@@ -146,9 +148,9 @@ DependencyDetection.defer do
146
148
  end
147
149
 
148
150
  executes do
149
- if ActiveRecord::VERSION::MAJOR == 5 \
150
- && ActiveRecord::VERSION::MINOR.to_i == 1 \
151
- && ActiveRecord::VERSION::TINY.to_i >= 6
151
+ if NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::MAJOR, '==', 5) \
152
+ && NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::MINOR, '==', 1) \
153
+ && NewRelic::Helper.version_satisfied?(ActiveRecord::VERSION::TINY, '>=', 6)
152
154
 
153
155
  ActiveRecord::Base.prepend(NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516)
154
156
  end