newrelic_rpm 3.9.8.273 → 3.9.9.275

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,48 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v3.9.9 ##
4
+
5
+ * Support for Ruby 2.2
6
+
7
+ A new version of Ruby is available, and the Ruby agent is ready to run on
8
+ it. We've been testing things out since the early previews so you can
9
+ upgrade to the latest and greatest and use New Relic right away to see how
10
+ the new Ruby's performing for you.
11
+
12
+ * Support for Rails 4.2 and ActiveJob
13
+
14
+ Not only is a new Ruby available, but a new Rails is out too! The Ruby agent
15
+ provides all the usual support for Rails that you'd expect, and we
16
+ instrument the newly released ActiveJob framework that's part of 4.2.
17
+
18
+ * Security fix for handling of error responses from New Relic servers
19
+
20
+ This release fixes a potential security issue wherein an attacker who was able
21
+ to impersonate New Relic's servers could have triggered arbitrary code
22
+ execution in agent's host processes by sending a specially-crafted error
23
+ response to a data submission request.
24
+
25
+ This issue is mitigated by the fact that the agent uses SSL certificate
26
+ checking in order to verify the identity of the New Relic servers to which it
27
+ connects. SSL is enabled by default by the agent, and can be enforced
28
+ account-wide by enabling High Security Mode for your account:
29
+
30
+ https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security
31
+
32
+ * Fix for transactions with invalid URIs
33
+
34
+ If an application used the agent's `ignore_url_regexes` config setting to
35
+ ignore certain transactions, but received an invalid URI, the agent would
36
+ fail to record the transaction. This has been fixed.
37
+
38
+ * Fixed incompatibility with newrelic-grape
39
+
40
+ The 3.9.8 release of the Ruby agent included disabled prototyped
41
+ instrumentation for the Grape API framework. This introduced an
42
+ incompatibility with the existing third party extension newrelic-grape. This
43
+ has been fixed. Newrelic-grape continues to be the right solution until
44
+ full agent support for Grape is available.
45
+
3
46
  ## v3.9.8 ##
4
47
 
5
48
  * Custom Insights events API
data/README.md CHANGED
@@ -21,7 +21,7 @@ automatically in Rails applications.
21
21
 
22
22
  ## Supported Environments
23
23
 
24
- * Ruby 1.8.7, REE, 1.9.x, 2.0.x, 2.1.x
24
+ * Ruby 1.8.7, REE, 1.9.x, 2.0.x, 2.1.x, 2.2.x
25
25
  * JRuby 1.6 and 1.7
26
26
  * Rubinius 2.x (Experimental support only)
27
27
  * Rails 2.1 or later for Production Mode
@@ -7,6 +7,14 @@ require 'forwardable'
7
7
  module NewRelic
8
8
  module Agent
9
9
  module Configuration
10
+
11
+ # Helper since default Procs are evaluated in the context of this module
12
+ def self.value_of(key)
13
+ Proc.new do
14
+ NewRelic::Agent.config[key]
15
+ end
16
+ end
17
+
10
18
  class Boolean; end
11
19
 
12
20
  class DefaultSource
@@ -128,10 +136,6 @@ module NewRelic
128
136
  Proc.new { NewRelic::Agent::Threading::BacktraceService.is_supported? }
129
137
  end
130
138
 
131
- def self.browser_monitoring_auto_instrument
132
- Proc.new { NewRelic::Agent.config[:'rum.enabled'] }
133
- end
134
-
135
139
  # This check supports the js_errors_beta key we've asked clients to
136
140
  # set. Once JS errors are GA, browser_monitoring.loader can stop
137
141
  # being dynamic.
@@ -139,46 +143,14 @@ module NewRelic
139
143
  Proc.new { NewRelic::Agent.config[:js_errors_beta] ? "full" : "rum"}
140
144
  end
141
145
 
142
- def self.slow_sql_record_sql
143
- Proc.new { NewRelic::Agent.config[:'transaction_tracer.record_sql'] }
144
- end
145
-
146
- def self.slow_sql_explain_enabled
147
- Proc.new { NewRelic::Agent.config[:'transaction_tracer.explain_enabled'] }
148
- end
149
-
150
- def self.slow_sql_explain_threshold
151
- Proc.new { NewRelic::Agent.config[:'transaction_tracer.explain_threshold'] }
152
- end
153
-
154
- def self.slow_sql_enabled
155
- Proc.new { NewRelic::Agent.config[:'transaction_tracer.enabled'] }
156
- end
157
-
158
146
  def self.transaction_tracer_transaction_threshold
159
147
  Proc.new { NewRelic::Agent.config[:apdex_t] * 4 }
160
148
  end
161
149
 
162
- def self.disable_activerecord_instrumentation
163
- Proc.new { NewRelic::Agent.config[:skip_ar_instrumentation] }
164
- end
165
-
166
- def self.api_port
167
- Proc.new { NewRelic::Agent.config[:port] }
168
- end
169
-
170
150
  def self.port
171
151
  Proc.new { NewRelic::Agent.config[:ssl] ? 443 : 80 }
172
152
  end
173
153
 
174
- def self.strip_exception_messages_enabled
175
- Proc.new { NewRelic::Agent.config[:high_security] }
176
- end
177
-
178
- def self.developer_mode
179
- Proc.new { NewRelic::Agent.config[:developer] }
180
- end
181
-
182
154
  def self.profiling_available
183
155
  Proc.new {
184
156
  begin
@@ -190,10 +162,6 @@ module NewRelic
190
162
  }
191
163
  end
192
164
 
193
- def self.monitor_mode
194
- Proc.new { NewRelic::Agent.config[:enabled] }
195
- end
196
-
197
165
  def self.rules_ignore
198
166
  Proc.new do |rules|
199
167
  rules = convert_to_list(rules)
@@ -214,7 +182,6 @@ module NewRelic
214
182
  raise ArgumentError.new("Config value '#{value}' couldn't be turned into a list.")
215
183
  end
216
184
  end
217
-
218
185
  end
219
186
 
220
187
  AUTOSTART_BLACKLISTED_RAKE_TASKS = [
@@ -295,13 +262,13 @@ module NewRelic
295
262
  :description => 'Semicolon-delimited list of <a href="/docs/apm/new-relic-apm/installation-and-configuration/naming-your-application">application names</a> to which the agent will report metrics (e.g. \'MyApplication\' or \'MyAppStaging;Instance1\'). For more information, see <a href="/docs/apm/new-relic-apm/installation-and-configuration/naming-your-application">Naming your application</a>.'
296
263
  },
297
264
  :monitor_mode => {
298
- :default => DefaultSource.monitor_mode,
265
+ :default => value_of(:enabled),
299
266
  :public => true,
300
267
  :type => Boolean,
301
268
  :description => 'Enable or disable the transmission of data to the New Relic <a href="/docs/apm/new-relic-apm/getting-started/glossary#collector">collector</a>).'
302
269
  },
303
270
  :developer_mode => {
304
- :default => DefaultSource.developer_mode,
271
+ :default => value_of(:developer),
305
272
  :public => true,
306
273
  :type => Boolean,
307
274
  :description => 'Enable or disable developer mode, a local analytics package built into the agent for rack applications. Access developer mode analytics by visiting <b>/newrelic</b> in your application.'
@@ -429,7 +396,7 @@ module NewRelic
429
396
  :description => 'Enables or disables the agent for background processes. No longer necessary as the agent now automatically instruments background processes.'
430
397
  },
431
398
  :'strip_exception_messages.enabled' => {
432
- :default => DefaultSource.strip_exception_messages_enabled,
399
+ :default => value_of(:high_security),
433
400
  :public => true,
434
401
  :type => Boolean,
435
402
  :description => 'Defines whether the agent should strip messages from all exceptions that are not specified in the whitelist. Enabled automatically in <a href="/docs/accounts-partnerships/accounts/security/high-security">high security mode</a>.'
@@ -459,7 +426,7 @@ module NewRelic
459
426
  :description => 'Port for the New Relic data collection service.'
460
427
  },
461
428
  :api_port => {
462
- :default => DefaultSource.api_port,
429
+ :default => value_of(:port),
463
430
  :public => false,
464
431
  :type => Fixnum,
465
432
  :description => 'Port for the New Relic API host.'
@@ -623,7 +590,7 @@ module NewRelic
623
590
  :description => 'Enable or disable active record instrumentation.'
624
591
  },
625
592
  :disable_activerecord_instrumentation => {
626
- :default => DefaultSource.disable_activerecord_instrumentation,
593
+ :default => value_of(:skip_ar_instrumentation),
627
594
  :public => true,
628
595
  :type => Boolean,
629
596
  :description => 'Enable or disable active record instrumentation.'
@@ -734,25 +701,25 @@ module NewRelic
734
701
  :description => 'Defines whether the agent will install <a href="/docs/agents/ruby-agent/frameworks/mongo-instrumentation">instrumentation for the Mongo gem</a>.'
735
702
  },
736
703
  :'slow_sql.enabled' => {
737
- :default => DefaultSource.slow_sql_enabled,
704
+ :default => value_of(:'transaction_tracer.enabled'),
738
705
  :public => true,
739
706
  :type => Boolean,
740
707
  :description => 'Enable or disable collection of slow SQL queries.'
741
708
  },
742
709
  :'slow_sql.explain_threshold' => {
743
- :default => DefaultSource.slow_sql_explain_threshold,
710
+ :default => value_of(:'transaction_tracer.explain_threshold'),
744
711
  :public => true,
745
712
  :type => Float,
746
713
  :description => 'Defines a duration threshold, over which the agent will collect explain plans in slow SQL queries.'
747
714
  },
748
715
  :'slow_sql.explain_enabled' => {
749
- :default => DefaultSource.slow_sql_explain_enabled,
716
+ :default => value_of(:'transaction_tracer.explain_enabled'),
750
717
  :public => true,
751
718
  :type => Boolean,
752
719
  :description => 'Enable or disable the collection of explain plans in slow SQL queries. If this setting is omitted, the transaction_tracer.explain_enabled setting will be applied as the default setting for explain plans in Slow SQL as well.'
753
720
  },
754
721
  :'slow_sql.record_sql' => {
755
- :default => DefaultSource.slow_sql_record_sql,
722
+ :default => value_of(:'transaction_tracer.record_sql'),
756
723
  :public => true,
757
724
  :type => String,
758
725
  :description => 'Defines an obfuscation level for slow SQL queries. Valid options are <code>obfuscated</code>, <code>raw</code>, <code>none</code>).'
@@ -824,7 +791,7 @@ module NewRelic
824
791
  :description => 'Javascript agent file for real user monitoring.'
825
792
  },
826
793
  :'browser_monitoring.auto_instrument' => {
827
- :default => DefaultSource.browser_monitoring_auto_instrument,
794
+ :default => value_of(:'rum.enabled'),
828
795
  :public => true,
829
796
  :type => Boolean,
830
797
  :description => 'Enable or disable automatic insertion of the JavaScript header into outgoing responses for page load timing (sometimes referred to as real user monitoring or RUM).'
@@ -1154,6 +1121,12 @@ module NewRelic
1154
1121
  :description => 'Maximum number of custom Insights events buffered in memory at a time.',
1155
1122
  :dynamic_name => true
1156
1123
  },
1124
+ :disable_grape_instrumentation => {
1125
+ :default => false,
1126
+ :public => true,
1127
+ :type => Boolean,
1128
+ :description => 'Disables installation of Grape instrumentation.'
1129
+ },
1157
1130
  :disable_grape => {
1158
1131
  :default => false,
1159
1132
  :public => true,
@@ -1161,7 +1134,6 @@ module NewRelic
1161
1134
  :description => 'Disables installation of Grape instrumentation.'
1162
1135
  }
1163
1136
  }.freeze
1164
-
1165
1137
  end
1166
1138
  end
1167
1139
  end
@@ -31,10 +31,11 @@ module NewRelic
31
31
  # do the real enforcement there.
32
32
  def apply_feature_gates(server_config, existing_config)
33
33
  gated_features = {
34
- :'transaction_tracer.enabled' => 'collect_traces',
35
- :'slow_sql.enabled' => 'collect_traces',
36
- :'error_collector.enabled' => 'collect_errors',
37
- :'analytics_events.enabled' => 'collect_analytics_events'
34
+ :'transaction_tracer.enabled' => 'collect_traces',
35
+ :'slow_sql.enabled' => 'collect_traces',
36
+ :'error_collector.enabled' => 'collect_errors',
37
+ :'analytics_events.enabled' => 'collect_analytics_events',
38
+ :'custom_insights_events.enabled' => 'collect_custom_events'
38
39
  }
39
40
  gated_features.each do |feature, gate_key|
40
41
  if server_config.has_key?(gate_key)
@@ -14,7 +14,13 @@ module NewRelic
14
14
  end
15
15
 
16
16
  DependencyDetection.defer do
17
- named :grape
17
+ # Why not just :grape? newrelic-grape used that name already, and while we're
18
+ # not shipping yet, overloading the name interferes with the plugin.
19
+ named :grape_instrumentation
20
+
21
+ depends_on do
22
+ ::NewRelic::Agent.config[:disable_grape] == false
23
+ end
18
24
 
19
25
  depends_on do
20
26
  defined?(::Grape::VERSION) &&
@@ -7,11 +7,21 @@ module NewRelic
7
7
  class NewRelicService
8
8
  class Marshaller
9
9
  def parsed_error(error)
10
- error_class = error['error_type'].split('::') \
11
- .inject(Module) {|mod,const| mod.const_get(const) }
12
- error_class.new(error['message'])
13
- rescue NameError
14
- CollectorError.new("#{error['error_type']}: #{error['message']}")
10
+ error_type = error['error_type']
11
+ error_message = error['message']
12
+
13
+ exception = case error_type
14
+ when 'NewRelic::Agent::LicenseException'
15
+ LicenseException.new(error_message)
16
+ when 'NewRelic::Agent::ForceRestartException'
17
+ ForceRestartException.new(error_message)
18
+ when 'NewRelic::Agent::ForceDisconnectException'
19
+ ForceDisconnectException.new(error_message)
20
+ else
21
+ CollectorError.new("#{error['error_type']}: #{error['message']}")
22
+ end
23
+
24
+ exception
15
25
  end
16
26
 
17
27
  def prepare(data, options={})
@@ -11,7 +11,7 @@ module NewRelic
11
11
  {
12
12
  :type => :ruby,
13
13
  :name => "MRI",
14
- :supported => ["1.8.7", "1.9.2", "1.9.3", "2.0.0", "~> 2.1.0"],
14
+ :supported => ["1.8.7", "1.9.2", "1.9.3", "2.0.0", "~> 2.1.0", "~> 2.2.0" ],
15
15
  :deprecated => ["1.8.6"],
16
16
  :url => "https://www.ruby-lang.org",
17
17
  :feed => "https://www.ruby-lang.org/en/feeds/news.rss",
@@ -85,7 +85,7 @@ module NewRelic
85
85
  :rails =>
86
86
  {
87
87
  :type => :web,
88
- :supported => ["~>2.1.0", "~>2.2.0", "~>2.3.0", "~3.0.0", "~>3.1.0", "~>3.2.0", "~>4.0.0", "~>4.1.0"],
88
+ :supported => ["~>2.1.0", "~>2.2.0", "~>2.3.0", "~3.0.0", "~>3.1.0", "~>3.2.0", "~>4.0.0", "~>4.1.0", "~>4.2.0"],
89
89
  :deprecated => ["~>2.0.0"],
90
90
  :url => "https://rubygems.org/gems/rails",
91
91
  :feed => "https://rubygems.org/gems/rails/versions.atom",
@@ -182,6 +182,7 @@ module NewRelic
182
182
 
183
183
  :transaction_stopped
184
184
  rescue => e
185
+ state.reset
185
186
  NewRelic::Agent.logger.error("Exception during Transaction.stop", e)
186
187
  nil
187
188
  end
@@ -429,6 +430,9 @@ module NewRelic
429
430
  rules.any? do |rule|
430
431
  filtered_uri.match(rule)
431
432
  end
433
+ rescue URI::InvalidURIError => e
434
+ NewRelic::Agent.logger.debug("Error parsing URI: #{uri}", e)
435
+ false
432
436
  end
433
437
 
434
438
  def commit!(state, end_time, outermost_segment_name)
@@ -12,7 +12,7 @@ module NewRelic
12
12
 
13
13
  MAJOR = 3
14
14
  MINOR = 9
15
- TINY = 8
15
+ TINY = 9
16
16
 
17
17
  begin
18
18
  require File.join(File.dirname(__FILE__), 'build')
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
5
- gem 'rails', '~>4.2.0.rc1'
5
+ gem 'rails', '~>4.2.0'
6
6
 
7
7
  gem 'minitest', '5.2.3'
8
8
  gem 'mocha', :require => false
@@ -0,0 +1,65 @@
1
+ # Synthetics Tests
2
+
3
+ The Synthetics tests are designed to verify that the agent handles valid and invalid Synthetics requests.
4
+
5
+ Each test should run a simulated web transaction. A Synthetics HTTP request header is added to the incoming request at the beginning of a web transaction. During the course of the web transaction, an external request is made. And, at the completion of the web transaction, both a Transaction Trace and Transaction Event are recorded.
6
+
7
+ Each test then verifies that the correct attributes are added to the Transaction Trace and Transaction Event, and the proper request header is added to the external request when required. Or, in the case of an invalid Synthetics request, that the attributes and request header are **not** added.
8
+
9
+ ## Name
10
+
11
+ | Name | Meaning |
12
+ | ---- | ------- |
13
+ | `name` | A human-meaningful name for the test case. |
14
+
15
+ ## Settings
16
+
17
+ The `settings` hash contains a number of key-value pairs that the agent will need to use for configuration for the test.
18
+
19
+ | Name | Meaning |
20
+ | ---- | ------- |
21
+ | `agentEncodingKey`| The encoding key used by the agent for deobfuscation of the Synthetics request header. |
22
+ | `syntheticsEncodingKey` | The encoding key used by Synthetics to obfuscate the Synthetics request header. In most tests, `encodingKey` and `syntheticsEncodingKey` are the same. |
23
+ | `transactionGuid` | The GUID of the simulated transaction. In a non-simulated transaction, this will be randomly generated. But, for testing purposes, you should assign this value as the GUID, since the tests will check for this value to be set in the `nr.guid` attribute of the Transaction Event. |
24
+ | `trustedAccountIds` | A list of accounts ids that the agent trusts. If the Synthetics request contains a non-trusted account id, it is an invalid request.|
25
+
26
+ ## Inputs
27
+
28
+ The input for each test is a Synthetics request header. The test fixture file shows both the de-obfuscated version of the payload, as well as the resulting obfuscated version.
29
+
30
+ | Name | Meaning |
31
+ | ---- | ------- |
32
+ | `inputHeaderPayload` | A decoded form of the contents of the `X-NewRelic-Synthetics` request header. |
33
+ | `inputObfuscatedHeader` | An obfuscated form of the `X-NewRelic-Synthetics` request header. If you obfuscate `syntheticsHeaderPayload` using the CAT obfuscation algorithm, this should be the output. |
34
+
35
+ ## Outputs
36
+
37
+ There are three different outputs that are tested for: Transaction Trace, Transaction Event, and External Request Header.
38
+
39
+ ### outputTransactionTrace
40
+
41
+ The `outputTransactionTrace` hash contains three objects:
42
+
43
+ | Name | Meaning |
44
+ | ---- | ------- |
45
+ | `header` | The last field of the transaction sample array should be set to the Synthetics Resource ID for a Synthetics request, and should be set to `null` if it isn't. (The last field in the array is the 10th element in the header array, but is `header[9]` in zero-based array notation, so the key name is `field_9`.) |
46
+ | `expectedIntrinsics` | A set of key-value pairs that represent the attributes that should be set in the intrinsics section of the Transaction Trace. **Note**: If the agent has not implemented the Agent Attributes spec, then the agent should save the attributes in the `Custom` section, and the attribute names should have 'nr.' prepended to them. Read the spec for details. For agents in this situation, they will need to adjust the expected output of the tests accordingly. |
47
+ | `nonExpectedIntrinsics` | An array of names that represent the attributes that should **not** be set in the intrinsics section of the Transaction Trace.|
48
+
49
+ ### outputTransactionEvent
50
+
51
+ The `outputTransactionEvent` hash contains two objects:
52
+
53
+ | Name | Meaning |
54
+ | ---- | ------- |
55
+ | `expectedAttributes` | A set of key-value pairs that represent the attributes that should be set in the `Intrinsic` hash of the Transaction Event. |
56
+ | `nonExpectedAttributes` | An array of names that represent the attributes that should **not** be set in the `Intrinsic` hash of the Transaction Event. |
57
+
58
+ ### outputExternalRequestHeader
59
+
60
+ The `outputExternalRequestHeader` hash contains two objects:
61
+
62
+ | Name | Meaning |
63
+ | ---- | ------- |
64
+ | `expectedHeader` | The outbound header that should be added to external requests (similar to the CAT header), when the original request was made from a valid Synthetics request. |
65
+ | `nonExpectedHeader` | The outbound header that should **not** be added to external requests, when the original request was made from a non-Synthetics request. |
@@ -45,6 +45,22 @@ class CustomAnalyticsEventsTest < Minitest::Test
45
45
  assert_equal(good_event_type, events.first[0]['type'])
46
46
  end
47
47
 
48
+ def test_events_are_not_recorded_when_disabled_by_feature_gate
49
+ connect_response = {
50
+ 'agent_run_id' => 1,
51
+ 'collect_custom_events' => false
52
+ }
53
+
54
+ $collector.stub('connect', connect_response)
55
+
56
+ trigger_agent_reconnect
57
+
58
+ NewRelic::Agent.record_custom_event('whatever', :foo => :bar)
59
+
60
+ NewRelic::Agent.agent.send(:harvest_and_send_analytic_event_data)
61
+ assert_equal(0, $collector.calls_for(:custom_event_data).size)
62
+ end
63
+
48
64
  def last_custom_event_submission
49
65
  submissions = $collector.calls_for('custom_event_data')
50
66
  assert_equal(1, submissions.size)
@@ -1,6 +1,6 @@
1
1
  if RUBY_VERSION >= '1.9.3'
2
2
  gemfile <<-RB
3
- gem 'rails', '~>4.2.0.rc1'
3
+ gem 'rails', '~>4.2.0'
4
4
  gem 'haml', :require => false
5
5
  gem 'minitest', '5.2.3'
6
6
  RB
@@ -97,8 +97,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
97
97
  end
98
98
  end
99
99
 
100
- # https://github.com/rails/rails/pull/17862 for 4.2.0.rc1 _generate_paths_by_default
101
- (ViewsController.action_methods - ['raise_render', '_generate_paths_by_default']).each do |method|
100
+ (ViewsController.action_methods - ['raise_render']).each do |method|
102
101
 
103
102
  # proc rendering doesn't work on Rails 2
104
103
  next if method == 'proc_render' && Rails::VERSION::MAJOR <= 2
@@ -1,10 +1,12 @@
1
1
  gemfile <<-RB
2
2
  gem 'sinatra', '~> 1.4.5'
3
+ gem 'rack', '~> 1.5.0'
3
4
  gem 'rack-test', :require => 'rack/test'
4
5
  RB
5
6
 
6
7
  gemfile <<-RB
7
8
  gem 'sinatra', '~> 1.3.6'
9
+ gem 'rack', '~> 1.5.0'
8
10
  gem 'rack-test', :require => 'rack/test'
9
11
  RB
10
12
 
@@ -396,6 +396,20 @@ module NewRelic::Agent::Configuration
396
396
  end
397
397
  end
398
398
 
399
+ def test_default_to_value_of
400
+ with_config(:port => 8888) do
401
+ result = @manager.fetch(:api_port)
402
+ assert_equal 8888, result
403
+ end
404
+ end
405
+
406
+ def test_default_to_value_of_only_happens_at_defaults
407
+ with_config(:port => 8888, :api_port => 3000) do
408
+ result = @manager.fetch(:api_port)
409
+ assert_equal 3000, result
410
+ end
411
+ end
412
+
399
413
  def test_evaluate_procs_returns_evaluated_value_if_it_responds_to_call
400
414
  callable = Proc.new { 'test' }
401
415
  assert_equal 'test', @manager.evaluate_procs(callable)
@@ -30,6 +30,7 @@ class OrphanedConfigTest < Minitest::Test
30
30
  end
31
31
 
32
32
  AGENT_CONFIG_PATTERN = /Agent\.config\[:['"]?([a-z\._]+)['"]?\s*\]/
33
+ DEFAULT_VALUE_OF_PATTERN = /:default\s*=>\s*value_of\(:['"]?([a-z\._]+)['"]?\)\s*/
33
34
  REGISTER_CALLBACK_PATTERN = /register_callback\(:['"]?([a-z\._]+)['"]?\)/
34
35
  NAMED_DEPENDENCY_PATTERN = /^\s*named[ (]+\:?([a-z0-9\._]+).*$/
35
36
 
@@ -38,6 +39,7 @@ class OrphanedConfigTest < Minitest::Test
38
39
  lines_in(file).each do |line|
39
40
  captures = []
40
41
  captures << line.scan(AGENT_CONFIG_PATTERN)
42
+ captures << line.scan(DEFAULT_VALUE_OF_PATTERN)
41
43
  captures << line.scan(REGISTER_CALLBACK_PATTERN)
42
44
  captures << line.scan(NAMED_DEPENDENCY_PATTERN).map(&method(:disable_name))
43
45
 
@@ -55,37 +55,44 @@ module NewRelic::Agent::Configuration
55
55
  rsp = {
56
56
  'collect_errors' => false,
57
57
  'collect_traces' => false,
58
- 'collect_analytics_events' => false
58
+ 'collect_analytics_events' => false,
59
+ 'collect_custom_events' => false
59
60
  }
60
61
  existing_config = {
61
- :'error_collector.enabled' => true,
62
- :'slow_sql.enabled' => true,
63
- :'transaction_tracer.enabled' => true,
64
- :'analytics_events.enabled' => true
62
+ :'error_collector.enabled' => true,
63
+ :'slow_sql.enabled' => true,
64
+ :'transaction_tracer.enabled' => true,
65
+ :'analytics_events.enabled' => true,
66
+ :'custom_insights_events.enabled' => true
65
67
  }
66
68
  @source = ServerSource.new(rsp, existing_config)
67
- assert !@source[:'error_collector.enabled']
68
- assert !@source[:'slow_sql.enabled']
69
- assert !@source[:'transaction_tracer.enabled']
69
+ refute @source[:'error_collector.enabled']
70
+ refute @source[:'slow_sql.enabled']
71
+ refute @source[:'transaction_tracer.enabled']
72
+ refute @source[:'analytics_events.enabled']
73
+ refute @source[:'custom_insights_events.enabled']
70
74
  end
71
75
 
72
76
  def test_should_enable_gated_features_when_server_says_to
73
77
  rsp = {
74
78
  'collect_errors' => true,
75
79
  'collect_traces' => true,
76
- 'collect_analytics_events' => true
80
+ 'collect_analytics_events' => true,
81
+ 'collect_custom_events' => true
77
82
  }
78
83
  existing_config = {
79
- :'error_collector.enabled' => true,
80
- :'slow_sql.enabled' => true,
81
- :'transaction_tracer.enabled' => true,
82
- :'analytics_events.enabled' => true
84
+ :'error_collector.enabled' => true,
85
+ :'slow_sql.enabled' => true,
86
+ :'transaction_tracer.enabled' => true,
87
+ :'analytics_events.enabled' => true,
88
+ :'custom_insights_events.enabled' => true
83
89
  }
84
90
  @source = ServerSource.new(rsp, existing_config)
85
91
  assert @source[:'error_collector.enabled']
86
92
  assert @source[:'slow_sql.enabled']
87
93
  assert @source[:'transaction_tracer.enabled']
88
94
  assert @source[:'analytics_events.enabled']
95
+ assert @source[:'custom_insights_events.enabled']
89
96
  end
90
97
 
91
98
  def test_should_allow_manual_disable_of_gated_features
@@ -112,18 +119,21 @@ module NewRelic::Agent::Configuration
112
119
  'collect_errors' => true,
113
120
  'collect_traces' => true,
114
121
  'collect_analytics_events' => true,
122
+ 'collect_custom_events' => true,
115
123
  'agent_config' => {
116
- 'transaction_tracer.enabled' => true,
117
- 'slow_sql.enabled' => true,
118
- 'error_collector.enabled' => true,
119
- 'analytics_events.enabled' => true
124
+ 'transaction_tracer.enabled' => true,
125
+ 'slow_sql.enabled' => true,
126
+ 'error_collector.enabled' => true,
127
+ 'analytics_events.enabled' => true,
128
+ 'custom_insights_events.enabled' => true
120
129
  }
121
130
  }
122
131
  existing_config = {
123
- :'error_collector.enabled' => false,
124
- :'slow_sql.enabled' => false,
125
- :'transaction_tracer.enabled' => false,
126
- :'analytics_events.enabled' => false
132
+ :'error_collector.enabled' => false,
133
+ :'slow_sql.enabled' => false,
134
+ :'transaction_tracer.enabled' => false,
135
+ :'analytics_events.enabled' => false,
136
+ :'custom_insights_events.enabled' => false
127
137
  }
128
138
  @source = ServerSource.new(rsp, existing_config)
129
139
  assert @source[:'error_collector.enabled']
@@ -135,10 +145,11 @@ module NewRelic::Agent::Configuration
135
145
  def test_should_not_gate_when_gating_keys_absent
136
146
  rsp = {
137
147
  'agent_config' => {
138
- 'transaction_tracer.enabled' => true,
139
- 'slow_sql.enabled' => true,
140
- 'error_collector.enabled' => true,
141
- 'analytics_events.enabled' => true
148
+ 'transaction_tracer.enabled' => true,
149
+ 'slow_sql.enabled' => true,
150
+ 'error_collector.enabled' => true,
151
+ 'analytics_events.enabled' => true,
152
+ 'custom_insights_events.enabled' => true
142
153
  }
143
154
  }
144
155
  @source = ServerSource.new(rsp, {})
@@ -146,6 +157,7 @@ module NewRelic::Agent::Configuration
146
157
  assert @source[:'slow_sql.enabled']
147
158
  assert @source[:'transaction_tracer.enabled']
148
159
  assert @source[:'analytics_events.enabled']
160
+ assert @source[:'custom_insights_events.enabled']
149
161
  end
150
162
  end
151
163
  end
@@ -647,7 +647,7 @@ class NewRelicServiceTest < Minitest::Test
647
647
  assert_equal([[['dcba']]], prepared)
648
648
  end
649
649
 
650
- def test_marshaller_handles_known_errors
650
+ def test_marshaller_handles_force_restart_exception
651
651
  error_data = {
652
652
  'error_type' => 'NewRelic::Agent::ForceRestartException',
653
653
  'message' => 'test'
@@ -657,6 +657,26 @@ class NewRelicServiceTest < Minitest::Test
657
657
  assert_equal 'test', error.message
658
658
  end
659
659
 
660
+ def test_marshaller_handles_force_disconnect_exception
661
+ error_data = {
662
+ 'error_type' => 'NewRelic::Agent::ForceDisconnectException',
663
+ 'message' => 'test'
664
+ }
665
+ error = @service.marshaller.parsed_error(error_data)
666
+ assert_equal NewRelic::Agent::ForceDisconnectException, error.class
667
+ assert_equal 'test', error.message
668
+ end
669
+
670
+ def test_marshaller_handles_license_exception
671
+ error_data = {
672
+ 'error_type' => 'NewRelic::Agent::LicenseException',
673
+ 'message' => 'test'
674
+ }
675
+ error = @service.marshaller.parsed_error(error_data)
676
+ assert_equal NewRelic::Agent::LicenseException, error.class
677
+ assert_equal 'test', error.message
678
+ end
679
+
660
680
  def test_marshaller_handles_unknown_errors
661
681
  error = @service.marshaller.parsed_error('error_type' => 'OogBooga',
662
682
  'message' => 'test')
@@ -1012,6 +1012,35 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
1012
1012
  end
1013
1013
  end
1014
1014
 
1015
+ def test_user_defined_rules_ignore_logs_uri_parsing_failures
1016
+ with_config(:rules => { :ignore_url_regexes => ['notempty'] }) do
1017
+ in_transaction do |txn|
1018
+ txn.stubs(:uri).returns('http://foo bar.com')
1019
+ NewRelic::Agent.logger.expects(:debug)
1020
+ NewRelic::Agent.logger.expects(:debug).with(regexp_matches(/foo bar.com/), anything).at_least_once
1021
+ end
1022
+ end
1023
+ end
1024
+
1025
+ def test_user_defined_rules_ignore_returns_false_if_cannot_parse_uri
1026
+ with_config(:rules => { :ignore_url_regexes => ['notempty'] }) do
1027
+ in_transaction do |txn|
1028
+ txn.stubs(:uri).returns('http://foo bar.com')
1029
+ refute txn.user_defined_rules_ignore?
1030
+ end
1031
+ end
1032
+ end
1033
+
1034
+ def test_stop_resets_the_transaction_state_if_there_is_an_error
1035
+ in_transaction do |txn|
1036
+ state = mock
1037
+ state.stubs(:current_transaction).raises(StandardError, 'StandardError')
1038
+
1039
+ state.expects(:reset)
1040
+ NewRelic::Agent::Transaction.stop(state)
1041
+ end
1042
+ end
1043
+
1015
1044
  def test_doesnt_record_queue_time_if_it_is_zero
1016
1045
  in_transaction('boo') do
1017
1046
  # nothing
@@ -47,7 +47,6 @@ class RackMiddleware < Performance::TestCase
47
47
 
48
48
  @config = {
49
49
  :beacon => 'beacon',
50
- :disable_mobile_headers => false,
51
50
  :browser_key => 'browserKey',
52
51
  :js_agent_loader => 'loader',
53
52
  :encoding_key => 'lolz',
@@ -14,11 +14,9 @@ class RumAutoInsertion < Performance::TestCase
14
14
  NewRelic::Agent.manual_start
15
15
  @config = {
16
16
  :beacon => 'beacon',
17
- :disable_mobile_headers => false,
18
17
  :browser_key => 'browserKey',
19
18
  :application_id => '5, 6', # collector can return app multiple ids
20
19
  :'rum.enabled' => true,
21
- :episodes_file => 'this_is_my_file',
22
20
  :license_key => 'a' * 40,
23
21
  :js_agent_loader => 'loader'
24
22
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.8.273
4
+ version: 3.9.9.275
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -41,7 +41,7 @@ cert_chain:
41
41
  K0ZZTXduQWIrVm1OT2h2MVMrc0poYmpaMzBQS2d6NnZMaFQ2dW5pZUNqTGs5
42
42
  d0dHbWxTSwpZamJudkE5cXJhTExhalNqCi0tLS0tRU5EIENFUlRJRklDQVRF
43
43
  LS0tLS0K
44
- date: 2014-12-02 00:00:00.000000000 Z
44
+ date: 2014-12-29 00:00:00.000000000 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
@@ -703,7 +703,6 @@ files:
703
703
  - test/fixtures/cross_agent_tests/proc_meminfo/meminfo_4096MB.txt
704
704
  - test/fixtures/cross_agent_tests/rules.json
705
705
  - test/fixtures/cross_agent_tests/rum_client_config.json
706
- - test/fixtures/cross_agent_tests/rum_cookie.json
707
706
  - test/fixtures/cross_agent_tests/rum_footer_insertion_location/close-body-in-comment.html
708
707
  - test/fixtures/cross_agent_tests/rum_footer_insertion_location/dynamic-iframe.html
709
708
  - test/fixtures/cross_agent_tests/rum_loader_insertion_location/basic.html
@@ -798,6 +797,7 @@ files:
798
797
  - test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated
799
798
  - test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql
800
799
  - test/fixtures/cross_agent_tests/sql_parsing.json
800
+ - test/fixtures/cross_agent_tests/synthetics/README.md
801
801
  - test/fixtures/cross_agent_tests/synthetics/synthetics.json
802
802
  - test/fixtures/cross_agent_tests/transaction_segment_terms.json
803
803
  - test/fixtures/cross_agent_tests/url_clean.json
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- `�E�.|��:scj��l��G�)J�̡}b�M>�@U2Q�L�6�:AE�ۂ���rc�ؓ�t��kgM�R\a��۟u) ����3S#��+�7Tmz���XX�+�A󷆅ŚÏ?03�Y(���t�=�� 9�+�]2�flO#��4�k/_^}�C�Ɩ;������^�1!�wg">)��Ā ˶���f�^�璯Ða��LM�`EcI���a�1o~�R�q)C���#�!R$>����/�22-/�ltŐ��ǒ�C
1
+ e'K�I?+ϩ�@ �����2K�M; -�Y‡�KNB5H�^b��k��ot�@�2�;�����\909���Ί���������F�,�Y���*����z��z���Vh2��hP��;��l2WRK���Y����R?���@���t��tç�O�K
@@ -1,17 +0,0 @@
1
- [
2
- {"testname":"empty cookie", "input":"", "expected":""},
3
- {"testname":"long cookie", "input":"tk=0123456789ABCDEFAA", "expected":""},
4
- {"testname":"short cookie", "input":"tk=0123456789ABC", "expected":""},
5
- {"testname":"improper cookie", "input":"t==0123456789ABCDEF", "expected":""},
6
- {"testname":"improper cookie", "input":"tk-0123456789ABCDEF", "expected":""},
7
- {"testname":"invalid character", "input":"tk=0123456789ABCDE\"", "expected":""},
8
- {"testname":"invalid character", "input":"tk=0123456789ABCDE<", "expected":""},
9
- {"testname":"invalid character", "input":"tk=0123456789ABCDE'", "expected":""},
10
- {"testname":"invalid character", "input":"tk=0123456789ABCDE>", "expected":""},
11
- {"testname":"invalid character", "input":"tk=0123456789ABCDE]", "expected":""},
12
- {"testname":"invalid character", "input":"tk=0123456789ABCDE+", "expected":""},
13
- {"testname":"good cookie", "input":"tk=0123456789ABCDEF", "expected":"0123456789ABCDEF"},
14
- {"testname":"good cookie a-z", "input":"tk=aaaaaaznnzzazzzz", "expected":"aaaaaaznnzzazzzz"},
15
- {"testname":"good cookie A-Z", "input":"tk=AAAAAAZNNZZAZZZZ", "expected":"AAAAAAZNNZZAZZZZ"},
16
- {"testname":"good cookie numbers", "input":"tk=0123456789567891", "expected":"0123456789567891"}
17
- ]