newrelic_rpm 9.4.2 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +138 -10
  3. data/Rakefile +1 -1
  4. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  5. data/lib/new_relic/agent/configuration/default_source.rb +153 -33
  6. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
  7. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
  8. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
  9. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -2
  10. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  11. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
  12. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  13. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
  14. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  15. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
  16. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  17. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  18. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  19. data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
  20. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +9 -0
  21. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +2 -2
  22. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
  23. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
  24. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -1
  25. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  26. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  27. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  28. data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
  29. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
  30. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -0
  31. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +4 -0
  32. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -0
  33. data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
  34. data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  36. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  37. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  38. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  39. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  40. data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
  41. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  42. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +9 -0
  43. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -3
  44. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
  45. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -0
  46. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
  47. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +6 -0
  48. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
  49. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +1 -0
  50. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
  51. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +4 -0
  52. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  53. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  54. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +16 -0
  55. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +1 -2
  56. data/lib/new_relic/agent/instrumentation/roda.rb +2 -0
  57. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  58. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  59. data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -3
  60. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
  61. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
  62. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  63. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
  64. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
  65. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -1
  66. data/lib/new_relic/agent/messaging.rb +2 -2
  67. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  68. data/lib/new_relic/agent/rules_engine.rb +1 -1
  69. data/lib/new_relic/agent/span_event_primitive.rb +16 -4
  70. data/lib/new_relic/agent/system_info.rb +26 -0
  71. data/lib/new_relic/agent/tracer.rb +1 -3
  72. data/lib/new_relic/agent/transaction/abstract_segment.rb +55 -0
  73. data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -2
  74. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -2
  75. data/lib/new_relic/agent/transaction/request_attributes.rb +1 -3
  76. data/lib/new_relic/agent/transaction.rb +25 -2
  77. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -0
  78. data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
  79. data/lib/new_relic/agent/utilization/gcp.rb +1 -3
  80. data/lib/new_relic/agent.rb +18 -2
  81. data/lib/new_relic/constants.rb +3 -0
  82. data/lib/new_relic/control/frameworks/rails.rb +14 -2
  83. data/lib/new_relic/language_support.rb +4 -0
  84. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  85. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  86. data/lib/new_relic/supportability_helper.rb +1 -0
  87. data/lib/new_relic/version.rb +2 -2
  88. data/lib/tasks/instrumentation_generator/instrumentation.thor +3 -3
  89. data/lib/tasks/tests.rake +71 -0
  90. data/newrelic.yml +93 -32
  91. data/newrelic_rpm.gemspec +4 -1
  92. metadata +39 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d061626a8cd184640b8e8bf85c54d475f66f98cadf9385043e91b42d6abff6a
4
- data.tar.gz: 29165d5746ceedf8a3cc7862420547e523c6f121a8e3d2b710cf90bb2a3a627c
3
+ metadata.gz: e08eba5efd3af57153446155d8c29ea47a55641bbf8c593105be4242325b1613
4
+ data.tar.gz: 571ec550538228168b2cafdf64f3cb55360aaac3ab33938d1200bf63ee840506
5
5
  SHA512:
6
- metadata.gz: e4c874df18c760e0a79c7fd14577b18a291449d73f781e2fb9e48fcb6ddc60bc3e0a8750a146393ac73248a7a68f84b371d9ee908b297f58323cf3095f96f806
7
- data.tar.gz: b3d1137d3eb8db15695052498e32069feb4d6f69b20847de646d0fdbd925a5de1bd15895e1f561092fc3cdc66400adc1ef25d16b19ac342fe53ec7acaf2d24c5
6
+ metadata.gz: 13fae847437ac99e08ac4bc25545074e4bf300c91abdabc2d3afcb0b3e7fb87987c1c811bdb7b7eb4a4470d3d58bc11266ee75d6d21672cdab3437418d42814c
7
+ data.tar.gz: 4eb79daba4531d41b736099e904126af44421a3ca9457fed3a0b9d89ea90973674b204d1f96d2fbe28f449b452d8b12c01b73f991bf3ceb26cfafe0bf7cf794d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,133 @@
1
1
  # New Relic Ruby Agent Release Notes
2
2
 
3
+ ## v9.6.0
4
+
5
+ Version 9.6.0 adds instrumentation for Async::HTTP, Ethon, and HTTPX, adds the ability to ignore specific routes with Roda, gleans Docker container IDs from cgroups v2-based containers, records additional synthetics attributes, fixes an issue with Rails 7.1 that could cause duplicate log records to be sent to New Relic, fixes a deprecation warning for the Sidekiq error handler, adds additional attributes for OpenTelemetry compatibility, and resolves some technical debt, thanks to the community.
6
+
7
+ - **Feature: Add instrumentation for Async::HTTP**
8
+
9
+ The agent will now record spans for Async::HTTP requests. Versions 0.59.0 and above of the async-http gem are supported. [PR#2272](https://github.com/newrelic/newrelic-ruby-agent/pull/2272)
10
+
11
+ - **Feature: Add instrumentation for Ethon**
12
+
13
+ Instrumentation has been added for the [Ethon](https://github.com/typhoeus/ethon) HTTP client gem. Versions 0.12.0 and above are supported. The agent will now record external request segments for invocations of `Ethon::Easy#perform` and `Ethon::Multi#perform`. NOTE: The [Typhoeus](https://github.com/typhoeus/typhoeus) gem is maintained by the same team that maintains Ethon and depends on Ethon for its functionality. To prevent duplicate reporting for each HTTP request, the Ethon instrumentation will be disabled when Typhoeus is detected. [PR#2260](https://github.com/newrelic/newrelic-ruby-agent/pull/2260)
14
+
15
+ - **Feature: Add instrumentation for HTTPX**
16
+
17
+ The agent now offers instrumentation for the HTTP client [HTTPX](https://honeyryderchuck.gitlab.io/httpx/), provided the gem is at version 1.0.0 or above. [PR#2278](https://github.com/newrelic/newrelic-ruby-agent/pull/2278)
18
+
19
+ - **Feature: Prevent the agent from starting in "rails" commands in Rails 7**
20
+
21
+ Previously, the agent ignored many Rails commands by default, such as `rails routes`, using Rake-specific logic. This was accomplished by setting these commands as default values for the config option `autostart.denylisted_rake_tasks`. However, Rails 7 no longer uses Rake for these commands, causing the agent to start running and attempting to record data when running these commands. The commands have now been added to the default value for the config option `autostart.denylisted_constants`, which will allow the agent to recognize these commands correctly in Rails 7 and prevent the agent from starting during ignored tasks. Note that the agent will continue to start-up when the `rails server` and `rails runner` commands are invoked. [PR#2239](https://github.com/newrelic/newrelic-ruby-agent/pull/2239)
22
+
23
+ - **Feature: Glean Docker container ID for cgroups v2-based containers**
24
+
25
+ Previously, the agent was only capable of determining a host Docker container's ID if the container was based on cgroups v1. Now, containers based on cgroups v2 will also have their container IDs reported to New Relic. [PR#2229](https://github.com/newrelic/newrelic-ruby-agent/issues/2229).
26
+
27
+ - **Feature: Update events with additional synthetics attributes when available**
28
+
29
+ The agent will now record additional synthetics attributes on synthetics events if these attributes are available. [PR#2203](https://github.com/newrelic/newrelic-ruby-agent/pull/2203)
30
+
31
+ - **Feature: Declare a gem dependency on the Ruby Base 64 gem 'base64'**
32
+
33
+ For compatibility with Ruby 3.4 and to silence compatibility warnings present in Ruby 3.3, declare a dependency on the `base64` gem. The New Relic Ruby agent uses the native Ruby `base64` gem for Base 64 encoding/decoding. The agent is joined by Ruby on Rails ([rails/rails@3e52adf](https://github.com/rails/rails/commit/3e52adf28e90af490f7e3bdc4bcc85618a4e0867)) and others in making this change in preparation for Ruby 3.3/3.4. [PR#2238](https://github.com/newrelic/newrelic-ruby-agent/pull/2238)
34
+
35
+ - **Feature: Add Roda support for the newrelic_ignore\* family of methods**
36
+
37
+ The agent can now selectively disable instrumentation for particular requests within Roda applications. Supported methods include:
38
+ - `newrelic_ignore`: ignore a given route.
39
+ - `newrelic_ignore_apdex`: exclude a given route from consideration in overall Apdex calculations.
40
+ - `newrelic_ignore_enduser`: prevent automatic injection of the page load timing JavaScript when a route is rendered.
41
+
42
+ For more information, see [Roda Instrumentation](https://docs.newrelic.com/docs/apm/agents/ruby-agent/instrumented-gems/roda-instrumentation/). [PR#2267](https://github.com/newrelic/newrelic-ruby-agent/pull/2267)
43
+
44
+ - **Feature: Add additional span attributes for OpenTelemetry compatibility**
45
+
46
+ For improved compatibility with OpenTelemetry's semantic conventions, the agent's datastore (for databases) and external request (for HTTP clients) segments have been updated with additional attributes.
47
+
48
+ Datastore segments now offer 3 additional attributes:
49
+ - `db.system`: The database system. For Ruby we use the database adapter name here.
50
+ - `server.address`: The database host.
51
+ - `server.port`: The database port.
52
+
53
+ External request segments now offer 3 additional attributes:
54
+ - `http.request.method`: The HTTP method (ex: 'GET')
55
+ - `server.address`: The target host.
56
+ - `server.port`: The target port.
57
+
58
+ For maximum backwards compatibility, no existing attributes have been renamed or removed. [PR#2283](https://github.com/newrelic/newrelic-ruby-agent/pull/2283)
59
+
60
+ - **Bugfix: Stop sending duplicate log events for Rails 7.1 users**
61
+
62
+ Rails 7.1 introduced the public API [`ActiveSupport::BroadcastLogger`](https://api.rubyonrails.org/classes/ActiveSupport/BroadcastLogger.html). This logger replaces a private API, `ActiveSupport::Logger.broadcast`. In Rails versions below 7.1, the agent uses the `broadcast` method to stop duplicate logs from being recoded by broadcasted loggers. Now, we've updated the code to provide a similar duplication fix for the `ActiveSupport::BroadcastLogger` class. [PR#2252](https://github.com/newrelic/newrelic-ruby-agent/pull/2252)
63
+
64
+ - **Bugfix: Resolve Sidekiq 8.0 error handler deprecation warning**
65
+
66
+ Sidekiq 8.0 will require procs passed to the error handler to include three arguments: error, context, and config. Users running sidekiq/main would receive a deprecation warning with this change any time an error was raised within a job. Thank you, [@fukayatsu](https://github.com/fukayatsu) for your proactive fix! [PR#2261](https://github.com/newrelic/newrelic-ruby-agent/pull/2261)
67
+
68
+ - **Community: Resolve technical debt**
69
+
70
+ We also received some great contributions from community members to resolve some outstanding technical debt issues. Thank you for your contributions!
71
+ * Add and Replace SLASH and ROOT constants: [PR#2256](https://github.com/newrelic/newrelic-ruby-agent/pull/2256) [chahmedejaz](https://github.com/chahmedejaz)
72
+ * Remove pry as a dev dependency: [PR#2665](https://github.com/newrelic/newrelic-ruby-agent/pull/2265), [PR#2273](https://github.com/newrelic/newrelic-ruby-agent/pull/2273) [AlajeBash](https://github.com/AlajeBash)
73
+ * Replace "start up" with "start-up": [PR#2249](https://github.com/newrelic/newrelic-ruby-agent/pull/2249) [chahmedejaz](https://github.com/chahmedejaz)
74
+ * Remove unused variables in test suites: [PR#2250](https://github.com/newrelic/newrelic-ruby-agent/pull/2250)
75
+
76
+
77
+ ## v9.5.0
78
+
79
+ Version 9.5.0 introduces Stripe instrumentation, allows the agent to record additional response information on a transaction when middleware instrumentation is disabled, introduces new `:'sidekiq.args.include'` and `:'sidekiq.args.exclude:` configuration options to permit capturing only certain Sidekiq job arguments, updates Elasticsearch datastore instance metrics, and fixes a bug in `NewRelic::Rack::AgentHooks.needed?`.
80
+
81
+ - **Feature: Add Stripe instrumentation**
82
+
83
+ [Stripe](https://stripe.com/) calls are now automatically instrumented. Additionally, new `:'stripe.user_data.include'` and `:'stripe.user_data.exclude'` configuration options permit capturing custom `user_data` key-value pairs that can be stored in [Stripe events](https://github.com/stripe/stripe-ruby#instrumentation). No `user_data` key-value pairs are captured by default. The agent currently supports Stripe versions 5.38.0+. [PR#2180](https://github.com/newrelic/newrelic-ruby-agent/pull/2180)
84
+
85
+ - **Feature: Report transaction HTTP status codes when middleware instrumentation is disabled**
86
+
87
+ Previously, when `disable_middleware_instrumentation` was set to `true`, the agent would not record the value of the response code or content type on the transaction. This was due to the possibility that a middleware could alter the response, which would not be captured by the agent when the middleware instrumentation was disabled. However, based on customer feedback, the agent will now report the HTTP status code and content type on a transaction when middleware instrumentation is disabled. [PR#2175](https://github.com/newrelic/newrelic-ruby-agent/pull/2175)
88
+
89
+ - **Feature: Permit capturing only certain Sidekiq job arguments**
90
+
91
+ New `:'sidekiq.args.include'` and `:'sidekiq.args.exclude'` configuration options have been introduced to permit fine grained control over which Sidekiq job arguments (args) are reported to New Relic. By default, no Sidekiq args are reported. To report any Sidekiq options, the `:'attributes.include'` array must include the string `'jobs.sidekiq.args.*'`. With that string in place, all arguments will be reported unless one or more of the new include/exclude options are used. The `:'sidekiq.args.include'` option can be set to an array of strings. Each of those strings will be passed to `Regexp.new` and collectively serve as an allowlist for desired args. For job arguments that are hashes, if a hash's key matches one of the include patterns, then both the key and its corresponding value will be included. For scalar arguments, the string representation of the scalar will need to match one of the include patterns to be captured. The `:'sidekiq.args.exclude'` option works similarly. It can be set to an array of strings that will each be passed to `Regexp.new` to create patterns. These patterns will collectively serve as a denylist for unwanted job args. Any hash key, hash value, or scalar that matches an exclude pattern will be excluded (not sent to New Relic). [PR#2177](https://github.com/newrelic/newrelic-ruby-agent/pull/2177)
92
+
93
+ `newrelic.yml` examples:
94
+
95
+ Any string in the `:'sidekiq.args.include'` or `:'sidekiq.args.exclude'` arrays will be turned into a regular expression. Knowledge of [Ruby regular expression support](https://ruby-doc.org/3.2.2/Regexp.html) can be leveraged but is not required. If regular expression syntax is not used, inexact matches will be performed and the string "Fortune" will match both "Fortune 500" and "Fortune and Glory". For exact matches, use [regular expression anchors](https://ruby-doc.org/3.2.2/Regexp.html#class-Regexp-label-Anchors).
96
+
97
+ ```yaml
98
+ # Include any argument whose string representation matches either "apple" or "banana"
99
+ # The "apple" pattern will match both "green apple" and "red apple"
100
+ sidekiq.args.include:
101
+ - apple
102
+ - banana
103
+
104
+ # Exclude any arguments that match either "grape", "orange", or "pear"
105
+ sidekiq.args.exclude:
106
+ - grape
107
+ - orange
108
+ - pear
109
+
110
+ # Exclude any argument that is a 9 digit number
111
+ sidekiq.args.exclude:
112
+ - '\d{9}'
113
+
114
+ # Include anything that starts with "blue" but exclude anything that ends in "green"
115
+ sidekiq.args.include
116
+ - '^blue'
117
+
118
+ sidekiq.args.exclude
119
+ - 'green$'
120
+ ```
121
+
122
+ - **Bugfix: Update Elasticsearch datastore instance metric to use port instead of path**
123
+
124
+ Previously, the Elasticsearch datastore instance metric (`Datastore/instance/Elasticsearch/<host>/*`) used the path as the final value. This caused a [metrics grouping issue](https://docs.newrelic.com/docs/new-relic-solutions/solve-common-issues/troubleshooting/metric-grouping-issues) for some users, as every document ID created a unique metric. Now, the datastore instance metric has been updated to use the port as the final value. This also has the benefit of being more accurate for datastore instance metrics, as this port is directly associated with the already listed host.
125
+
126
+ - **Bugfix: Resolve inverted logic of NewRelic::Rack::AgentHooks.needed?**
127
+
128
+ Previously, `NewRelic::Rack::AgentHooks.needed?` incorrectly used inverted logic. This has now been resolved, allowing AgentHooks to be installed when `disable_middleware_instrumentation` is set to true. [PR#2175](https://github.com/newrelic/newrelic-ruby-agent/pull/2175)
129
+
130
+
3
131
  ## v9.4.2
4
132
 
5
133
  Version 9.4.2 of the agent re-addresses the 9.4.0 issue of `NoMethodError` seen when using the `uppy-s3_multipart` gem.
@@ -27,19 +155,19 @@ Version 9.4.0 of the agent adds [Roda](https://roda.jeremyevans.net/) instrument
27
155
  - **Feature: New allow_all_headers configuration option**
28
156
 
29
157
  A new `allow_all_headers` configuration option brings parity with the [Node.js agent](https://docs.newrelic.com/docs/release-notes/agent-release-notes/nodejs-release-notes/node-agent-270/) to capture all HTTP request headers.
30
-
158
+
31
159
  This configuration option:
32
160
  * Defaults to `false`
33
161
  * Is not compatible with high security mode
34
- * Requires Rack version 2 or higher (as does Ruby on Rails version 5 and above)
162
+ * Requires Rack version 2 or higher (as does Ruby on Rails version 5 and above)
35
163
  * Respects all existing behavior for the `attributes.include` and `attributes.exclude` [configuration options](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#attributes)
36
164
  * Captures the additional headers as attributes prefixed with `request.headers.`
37
-
165
+
38
166
  This work was done in response to a feature request submitted by community member [@jamesarosen](https://github.com/jamesarosen). Thank you very much, @jamesarosen! [Issue#1029](https://github.com/newrelic/newrelic-ruby-agent/issues/1029)
39
167
 
40
168
  - **Feature: Improved error tracking transaction linking**
41
169
 
42
- Errors tracked and sent to the New Relic errors inbox will now be associated with a transaction id to enable improved UI/UX associations between transactions and errors. [PR#2035](https://github.com/newrelic/newrelic-ruby-agent/pull/2035)
170
+ Errors tracked and sent to the New Relic errors inbox will now be associated with a transaction id to enable improved UI/UX associations between transactions and errors. [PR#2035](https://github.com/newrelic/newrelic-ruby-agent/pull/2035)
43
171
 
44
172
  - **Feature: Use Net::HTTP native timeout logic**
45
173
 
@@ -381,7 +509,7 @@ Version 8.15.0 of the agent confirms compatibility with Ruby 3.2.0, adds instrum
381
509
 
382
510
  | Configuration name | Default | Behavior |
383
511
  | --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
384
- | `instrumentation.concurrent_ruby` | auto | Controls auto-instrumentation of the concurrent-ruby library at start up. May be one of `auto`, `prepend`, `chain`, `disabled`. |
512
+ | `instrumentation.concurrent_ruby` | auto | Controls auto-instrumentation of the concurrent-ruby library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`. |
385
513
 
386
514
  - **Infinite Tracing: Use batching and compression**
387
515
 
@@ -480,7 +608,7 @@ Version 8.12.0 of the agent delivers new Elasticsearch instrumentation, increase
480
608
 
481
609
  | Configuration name | Default | Behavior |
482
610
  | --------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
483
- | `instrumentation.elasticsearch` | auto | Controls auto-instrumentation of the elasticsearch library at start up. May be one of `auto`, `prepend`, `chain`, `disabled`. |
611
+ | `instrumentation.elasticsearch` | auto | Controls auto-instrumentation of the elasticsearch library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`. |
484
612
  | `elasticsearch.capture_queries` | true | If `true`, the agent captures Elasticsearch queries in transaction traces. |
485
613
  | `elasticsearch.obfuscate_queries` | true | If `true`, the agent obfuscates Elasticsearch queries in transaction traces. |
486
614
 
@@ -1095,7 +1223,7 @@ The multiverse collection of test suites requires a variety of data handling sof
1095
1223
  - **Bugfix: Prevent browser monitoring middleware from installing to middleware multiple times**
1096
1224
 
1097
1225
  In rare cases on jRuby, the BrowserMonitoring middleware could attempt to install itself
1098
- multiple times at start up. This bug fix addresses that by using a mutex to introduce
1226
+ multiple times at start-up. This bug fix addresses that by using a mutex to introduce
1099
1227
  thread safety to the operation. Sintra in particular can have this race condition because
1100
1228
  its middleware stack is not installed until the first request is received.
1101
1229
 
@@ -1106,7 +1234,7 @@ The multiverse collection of test suites requires a variety of data handling sof
1106
1234
  - **Bugfix: nil Middlewares injection now prevented and gracefully handled in Sinatra**
1107
1235
 
1108
1236
  Previously, the agent could potentially inject multiples of an instrumented middleware if Sinatra received many
1109
- requests at once during start up and initialization due to Sinatra's ability to delay full start up as long as possible.
1237
+ requests at once during start-up and initialization due to Sinatra's ability to delay full start-up as long as possible.
1110
1238
  This has now been fixed and the Ruby agent correctly instruments only once as well as gracefully handles nil middleware
1111
1239
  classes in general.
1112
1240
 
@@ -3323,7 +3451,7 @@ For more details on our Resque support, see https://docs.newrelic.com/docs/agent
3323
3451
  - Support agent when starting Resque Pool from Rake task
3324
3452
 
3325
3453
  When running resque-pool with its provided rake tasks, the agent would not
3326
- start up properly. Thanks Tiago Sousa for the fix!
3454
+ start-up properly. Thanks Tiago Sousa for the fix!
3327
3455
 
3328
3456
  - Fix for DelayedJob + Rails 4.x queue depth metrics
3329
3457
 
@@ -5267,7 +5395,7 @@ Agent improvements to support future RPM enhancements
5267
5395
  - fix incompatibility in the developer mode with the safe_erb plugin
5268
5396
  - fix module namespace issue causing an error accessing
5269
5397
  NewRelic::Instrumentation modules
5270
- - fix issue where the agent sometimes failed to start up if there was a
5398
+ - fix issue where the agent sometimes failed to start-up if there was a
5271
5399
  transient network problem
5272
5400
  - fix IgnoreSilentlyException message
5273
5401
 
data/Rakefile CHANGED
@@ -131,7 +131,7 @@ end
131
131
 
132
132
  desc 'Start an interactive console session'
133
133
  task :console do
134
- require 'pry'
134
+ require 'pry' if ENV['ENABLE_PRY']
135
135
  require 'newrelic_rpm'
136
136
  ARGV.clear
137
137
  Pry.start
@@ -0,0 +1,109 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic
6
+ module Agent
7
+ module AttributePreFiltering
8
+ module_function
9
+
10
+ PRE_FILTER_KEYS = %i[include exclude].freeze
11
+ DISCARDED = :nr_discarded
12
+
13
+ def formulate_regexp_union(option)
14
+ return if NewRelic::Agent.config[option].empty?
15
+
16
+ Regexp.union(NewRelic::Agent.config[option].map { |p| string_to_regexp(p) }.uniq.compact).freeze
17
+ rescue StandardError => e
18
+ NewRelic::Agent.logger.warn("Failed to formulate a Regexp union from the '#{option}' configuration option " +
19
+ "- #{e.class}: #{e.message}")
20
+ end
21
+
22
+ def string_to_regexp(str)
23
+ Regexp.new(str)
24
+ rescue StandardError => e
25
+ NewRelic::Agent.logger.warn("Failed to initialize Regexp from string '#{str}' - #{e.class}: #{e.message}")
26
+ end
27
+
28
+ # attribute filtering suppresses data that has already been flattened
29
+ # and coerced (serialized as text) via #flatten_and_coerce, and is
30
+ # restricted to basic text matching with a single optional wildcard.
31
+ # pre filtering operates on raw Ruby objects beforehand and uses full
32
+ # Ruby regex syntax
33
+ def pre_filter(values = [], options = {})
34
+ return values unless !options.empty? && PRE_FILTER_KEYS.any? { |k| options.key?(k) }
35
+
36
+ # if there's a prefix in play for (non-pre) attribute filtration and
37
+ # attribute filtration won't allow that prefix, then don't even bother
38
+ # with pre filtration that could only result in values that would be
39
+ # blocked
40
+ if options.key?(:attribute_namespace) &&
41
+ !NewRelic::Agent.instance.attribute_filter.might_allow_prefix?(options[:attribute_namespace])
42
+ return values
43
+ end
44
+
45
+ values.each_with_object([]) do |element, filtered|
46
+ object = pre_filter_object(element, options)
47
+ filtered << object unless discarded?(object)
48
+ end
49
+ end
50
+
51
+ def pre_filter_object(object, options)
52
+ if object.is_a?(Hash)
53
+ pre_filter_hash(object, options)
54
+ elsif object.is_a?(Array)
55
+ pre_filter_array(object, options)
56
+ else
57
+ pre_filter_scalar(object, options)
58
+ end
59
+ end
60
+
61
+ def pre_filter_hash(hash, options)
62
+ filtered_hash = hash.each_with_object({}) do |(key, value), filtered|
63
+ filtered_key = pre_filter_object(key, options)
64
+ next if discarded?(filtered_key)
65
+
66
+ # If the key is permitted, skip include filtration for the value
67
+ # but still apply exclude filtration
68
+ if options.key?(:exclude)
69
+ exclude_only = options.dup
70
+ exclude_only.delete(:include)
71
+ filtered_value = pre_filter_object(value, exclude_only)
72
+ next if discarded?(filtered_value)
73
+ else
74
+ filtered_value = value
75
+ end
76
+
77
+ filtered[filtered_key] = filtered_value
78
+ end
79
+
80
+ filtered_hash.empty? && !hash.empty? ? DISCARDED : filtered_hash
81
+ end
82
+
83
+ def pre_filter_array(array, options)
84
+ filtered_array = array.each_with_object([]) do |element, filtered|
85
+ filtered_element = pre_filter_object(element, options)
86
+ next if discarded?(filtered_element)
87
+
88
+ filtered.push(filtered_element)
89
+ end
90
+
91
+ filtered_array.empty? && !array.empty? ? DISCARDED : filtered_array
92
+ end
93
+
94
+ def pre_filter_scalar(scalar, options)
95
+ return DISCARDED if options.key?(:include) && !scalar.to_s.match?(options[:include])
96
+ return DISCARDED if options.key?(:exclude) && scalar.to_s.match?(options[:exclude])
97
+
98
+ scalar
99
+ end
100
+
101
+ # `nil`, empty enumerable objects, and `false` are all valid in their
102
+ # own right as application data, so pre-filtering uses a special value
103
+ # to indicate that filtered out data has been discarded
104
+ def discarded?(object)
105
+ object == DISCARDED
106
+ end
107
+ end
108
+ end
109
+ end