newrelic_rpm 8.11.0 → 8.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/Brewfile +1 -0
- data/CHANGELOG.md +45 -16
- data/bin/nrdebug +2 -0
- data/docker-compose.yml +22 -0
- data/lib/new_relic/agent/agent/shutdown.rb +1 -0
- data/lib/new_relic/agent/agent/special_startup.rb +2 -0
- data/lib/new_relic/agent/agent/startup.rb +1 -0
- data/lib/new_relic/agent/attributes.rb +1 -0
- data/lib/new_relic/agent/audit_logger.rb +1 -0
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -0
- data/lib/new_relic/agent/configuration/default_source.rb +26 -4
- data/lib/new_relic/agent/configuration/dotted_hash.rb +1 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
- data/lib/new_relic/agent/configuration/manager.rb +3 -0
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -0
- data/lib/new_relic/agent/connect/request_builder.rb +1 -0
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +1 -0
- data/lib/new_relic/agent/database.rb +7 -0
- data/lib/new_relic/agent/database_adapter.rb +2 -0
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +3 -2
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
- data/lib/new_relic/agent/datastores/nosql_obfuscator.rb +41 -0
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +3 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +3 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +1 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +1 -0
- data/lib/new_relic/agent/encoding_normalizer.rb +2 -0
- data/lib/new_relic/agent/error_collector.rb +3 -0
- data/lib/new_relic/agent/error_filter.rb +1 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -0
- data/lib/new_relic/agent/event_aggregator.rb +1 -0
- data/lib/new_relic/agent/event_loop.rb +2 -0
- data/lib/new_relic/agent/http_clients/abstract.rb +2 -0
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +29 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -0
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +1 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +1 -0
- data/lib/new_relic/agent/local_log_decorator.rb +1 -0
- data/lib/new_relic/agent/log_event_aggregator.rb +1 -0
- data/lib/new_relic/agent/messaging.rb +1 -0
- data/lib/new_relic/agent/method_tracer.rb +4 -0
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +2 -0
- data/lib/new_relic/agent/rules_engine.rb +1 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +5 -0
- data/lib/new_relic/agent/span_event_primitive.rb +1 -0
- data/lib/new_relic/agent/stats.rb +1 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -0
- data/lib/new_relic/agent/system_info.rb +3 -0
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -0
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -0
- data/lib/new_relic/agent/threading/thread_profile.rb +3 -0
- data/lib/new_relic/agent/tracer.rb +4 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/datastore_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +4 -0
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +1 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +1 -0
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -0
- data/lib/new_relic/agent/transaction/segment.rb +1 -0
- data/lib/new_relic/agent/transaction/trace.rb +4 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +1 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +2 -0
- data/lib/new_relic/agent/transaction.rb +10 -0
- data/lib/new_relic/agent/transaction_event_aggregator.rb +1 -0
- data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -0
- data/lib/new_relic/agent/utilization/pcf.rb +1 -0
- data/lib/new_relic/agent/utilization/vendor.rb +2 -0
- data/lib/new_relic/agent/utilization_data.rb +3 -0
- data/lib/new_relic/agent.rb +4 -2
- data/lib/new_relic/cli/commands/install.rb +1 -0
- data/lib/new_relic/coerce.rb +6 -0
- data/lib/new_relic/collection_helper.rb +1 -0
- data/lib/new_relic/control/frameworks/rails.rb +5 -0
- data/lib/new_relic/control/instrumentation.rb +2 -0
- data/lib/new_relic/dependency_detection.rb +2 -0
- data/lib/new_relic/helper.rb +1 -0
- data/lib/new_relic/language_support.rb +1 -0
- data/lib/new_relic/latest_changes.rb +1 -0
- data/lib/new_relic/local_environment.rb +6 -0
- data/lib/new_relic/metric_spec.rb +2 -0
- data/lib/new_relic/rack/agent_middleware.rb +2 -0
- data/lib/new_relic/traced_thread.rb +1 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/helpers/format.rb +3 -0
- data/lib/tasks/instrumentation_generator/instrumentation.thor +27 -5
- data/lib/tasks/instrumentation_generator/templates/chain.tt +2 -1
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +3 -2
- data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +2 -1
- data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/prepend.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/test.tt +1 -1
- data/newrelic.yml +13 -3
- data/newrelic_rpm.gemspec +6 -6
- data/test/agent_helper.rb +6 -0
- metadata +11 -77
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +0 -43
@@ -54,6 +54,7 @@ module NewRelic
|
|
54
54
|
|
55
55
|
def unique_thread_count
|
56
56
|
return 0 if @unique_threads.nil?
|
57
|
+
|
57
58
|
@unique_threads.length
|
58
59
|
end
|
59
60
|
|
@@ -84,10 +85,12 @@ module NewRelic
|
|
84
85
|
|
85
86
|
all_nodes.each_with_index do |n, i|
|
86
87
|
break if i >= count_to_keep
|
88
|
+
|
87
89
|
n.mark_for_array_conversion
|
88
90
|
end
|
89
91
|
all_nodes.each_with_index do |n, i|
|
90
92
|
break if i >= count_to_keep
|
93
|
+
|
91
94
|
n.complete_array_conversion
|
92
95
|
end
|
93
96
|
end
|
@@ -187,11 +187,13 @@ module NewRelic
|
|
187
187
|
|
188
188
|
def create_distributed_trace_payload
|
189
189
|
return unless txn = current_transaction
|
190
|
+
|
190
191
|
txn.distributed_tracer.create_distributed_trace_payload
|
191
192
|
end
|
192
193
|
|
193
194
|
def accept_distributed_trace_payload(payload)
|
194
195
|
return unless txn = current_transaction
|
196
|
+
|
195
197
|
txn.distributed_tracer.accept_distributed_trace_payload(payload)
|
196
198
|
end
|
197
199
|
|
@@ -202,6 +204,7 @@ module NewRelic
|
|
202
204
|
# @api public
|
203
205
|
def current_segment
|
204
206
|
return unless txn = current_transaction
|
207
|
+
|
205
208
|
txn.current_segment
|
206
209
|
end
|
207
210
|
|
@@ -348,6 +351,7 @@ module NewRelic
|
|
348
351
|
# is effectively just a yield to the given &block
|
349
352
|
def capture_segment_error(segment)
|
350
353
|
return unless block_given?
|
354
|
+
|
351
355
|
yield
|
352
356
|
rescue => exception
|
353
357
|
if segment && segment.is_a?(Transaction::AbstractSegment)
|
@@ -55,6 +55,7 @@ module NewRelic
|
|
55
55
|
def start
|
56
56
|
@start_time ||= Process.clock_gettime(Process::CLOCK_REALTIME)
|
57
57
|
return unless transaction
|
58
|
+
|
58
59
|
parent.child_start(self) if parent
|
59
60
|
end
|
60
61
|
|
@@ -63,6 +64,7 @@ module NewRelic
|
|
63
64
|
@duration = end_time - start_time
|
64
65
|
|
65
66
|
return unless transaction
|
67
|
+
|
66
68
|
run_complete_callbacks
|
67
69
|
finalize if record_on_finish?
|
68
70
|
rescue => e
|
@@ -201,6 +203,7 @@ module NewRelic
|
|
201
203
|
|
202
204
|
def noticed_error_attributes
|
203
205
|
return unless @noticed_error
|
206
|
+
|
204
207
|
@noticed_error.attributes_from_notice_error
|
205
208
|
end
|
206
209
|
|
@@ -63,6 +63,7 @@ module NewRelic
|
|
63
63
|
# @api private
|
64
64
|
def _notice_sql(sql, config = nil, explainer = nil, binds = nil, name = nil)
|
65
65
|
return unless record_sql?
|
66
|
+
|
66
67
|
@sql_statement = Database::Statement.new(sql, config, explainer, binds, name, host, port_path_or_id, database_name)
|
67
68
|
end
|
68
69
|
|
@@ -85,6 +86,7 @@ module NewRelic
|
|
85
86
|
|
86
87
|
def notice_nosql_statement(nosql_statement)
|
87
88
|
return unless record_sql?
|
89
|
+
|
88
90
|
@nosql_statement = Database.truncate_query(nosql_statement)
|
89
91
|
nil
|
90
92
|
end
|
@@ -119,6 +121,7 @@ module NewRelic
|
|
119
121
|
|
120
122
|
def add_backtrace_parameter
|
121
123
|
return unless duration >= Agent.config[:'transaction_tracer.stack_trace_threshold']
|
124
|
+
|
122
125
|
params[:backtrace] = caller.join(NEWLINE)
|
123
126
|
end
|
124
127
|
|
@@ -74,6 +74,7 @@ module NewRelic
|
|
74
74
|
|
75
75
|
def insert_headers(headers)
|
76
76
|
return unless NewRelic::Agent.agent.connected?
|
77
|
+
|
77
78
|
insert_trace_context_header(headers)
|
78
79
|
insert_distributed_trace_header(headers)
|
79
80
|
insert_cross_app_header(headers)
|
@@ -100,12 +101,14 @@ module NewRelic
|
|
100
101
|
def insert_distributed_trace_header(headers)
|
101
102
|
return unless dt_enabled?
|
102
103
|
return if Agent.config[:'exclude_newrelic_header']
|
104
|
+
|
103
105
|
payload = create_distributed_trace_payload
|
104
106
|
headers[NewRelic::NEWRELIC_KEY] = payload.http_safe if payload
|
105
107
|
end
|
106
108
|
|
107
109
|
def insert_cat_headers(headers)
|
108
110
|
return unless CrossAppTracing.cross_app_enabled?
|
111
|
+
|
109
112
|
@is_cross_app_caller = true
|
110
113
|
insert_message_headers(headers,
|
111
114
|
transaction.guid,
|
@@ -161,6 +164,7 @@ module NewRelic
|
|
161
164
|
decoded_id = encoded_id.nil? ? EMPTY_STRING : deobfuscate(encoded_id)
|
162
165
|
|
163
166
|
return unless CrossAppTracing.trusted_valid_cross_app_id?(decoded_id)
|
167
|
+
|
164
168
|
txn_header = headers[CrossAppTracing::NR_MESSAGE_BROKER_TXN_HEADER]
|
165
169
|
txn_info = ::JSON.load(deobfuscate(txn_header))
|
166
170
|
payload = CrossAppPayload.new(decoded_id, transaction, txn_info)
|
@@ -156,6 +156,7 @@ module NewRelic
|
|
156
156
|
def assign_payload_and_sampling_params(payload)
|
157
157
|
@distributed_trace_payload = payload
|
158
158
|
return if transaction.distributed_tracer.trace_context_header_data
|
159
|
+
|
159
160
|
transaction.trace_id = payload.trace_id
|
160
161
|
transaction.distributed_tracer.parent_transaction_id = payload.transaction_id
|
161
162
|
transaction.parent_span_id = payload.id
|
@@ -82,6 +82,7 @@ module NewRelic
|
|
82
82
|
def read_response_headers(response)
|
83
83
|
return unless record_metrics? && CrossAppTracing.cross_app_enabled?
|
84
84
|
return unless CrossAppTracing.response_has_crossapp_header?(response)
|
85
|
+
|
85
86
|
unless data = CrossAppTracing.extract_appdata(response)
|
86
87
|
NewRelic::Agent.logger.debug("Couldn't extract_appdata from external segment response")
|
87
88
|
return
|
@@ -31,6 +31,7 @@ module NewRelic
|
|
31
31
|
node_count = 0
|
32
32
|
each_node do |node|
|
33
33
|
next if node == root_node
|
34
|
+
|
34
35
|
node_count += 1
|
35
36
|
end
|
36
37
|
node_count
|
@@ -51,6 +52,7 @@ module NewRelic
|
|
51
52
|
|
52
53
|
def create_node(time_since_start, metric_name = nil)
|
53
54
|
raise FinishedTraceError.new("Can't create additional node for finished trace.") if self.finished
|
55
|
+
|
54
56
|
self.node_count += 1
|
55
57
|
NewRelic::Agent::Transaction::TraceNode.new(metric_name, time_since_start)
|
56
58
|
end
|
@@ -75,6 +77,7 @@ module NewRelic
|
|
75
77
|
|
76
78
|
def collect_explain_plans!
|
77
79
|
return unless NewRelic::Agent::Database.should_collect_explain_plans?
|
80
|
+
|
78
81
|
threshold = NewRelic::Agent.config[:'transaction_tracer.explain_threshold']
|
79
82
|
|
80
83
|
each_node do |node|
|
@@ -87,6 +90,7 @@ module NewRelic
|
|
87
90
|
def prepare_sql_for_transmission!
|
88
91
|
each_node do |node|
|
89
92
|
next unless node[:sql]
|
93
|
+
|
90
94
|
node[:sql] = node[:sql].safe_sql
|
91
95
|
end
|
92
96
|
end
|
@@ -34,6 +34,7 @@ module NewRelic
|
|
34
34
|
|
35
35
|
def store(sample)
|
36
36
|
return unless enabled?
|
37
|
+
|
37
38
|
if allow_sample?(sample)
|
38
39
|
add_sample(sample)
|
39
40
|
truncate_samples_if_needed
|
@@ -42,6 +43,7 @@ module NewRelic
|
|
42
43
|
|
43
44
|
def store_previous(previous_samples)
|
44
45
|
return unless enabled?
|
46
|
+
|
45
47
|
previous_samples.each do |sample|
|
46
48
|
add_sample(sample) if allow_sample?(sample)
|
47
49
|
end
|
@@ -268,6 +268,7 @@ module NewRelic
|
|
268
268
|
current_thread_id = ::Thread.current.object_id
|
269
269
|
return current_segment_by_thread[current_thread_id] if current_segment_by_thread[current_thread_id]
|
270
270
|
return current_segment_by_thread[parent_thread_id] if current_segment_by_thread[parent_thread_id]
|
271
|
+
|
271
272
|
current_segment_by_thread[@starting_thread_id]
|
272
273
|
end
|
273
274
|
|
@@ -285,6 +286,7 @@ module NewRelic
|
|
285
286
|
|
286
287
|
def sampled?
|
287
288
|
return unless Agent.config[:'distributed_tracing.enabled']
|
289
|
+
|
288
290
|
if @sampled.nil?
|
289
291
|
@sampled = NewRelic::Agent.instance.adaptive_sampler.sampled?
|
290
292
|
end
|
@@ -347,6 +349,7 @@ module NewRelic
|
|
347
349
|
|
348
350
|
def set_default_transaction_name(name, category)
|
349
351
|
return log_frozen_name(name) if name_frozen?
|
352
|
+
|
350
353
|
if influences_transaction_name?(category)
|
351
354
|
self.default_name = name
|
352
355
|
@category = category if category
|
@@ -355,6 +358,7 @@ module NewRelic
|
|
355
358
|
|
356
359
|
def set_overriding_transaction_name(name, category)
|
357
360
|
return log_frozen_name(name) if name_frozen?
|
361
|
+
|
358
362
|
if influences_transaction_name?(category)
|
359
363
|
self.overridden_name = name
|
360
364
|
@category = category if category
|
@@ -510,6 +514,7 @@ module NewRelic
|
|
510
514
|
|
511
515
|
def finish
|
512
516
|
return unless state.is_execution_traced?
|
517
|
+
|
513
518
|
@end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
514
519
|
@duration = @end_time - @start_time
|
515
520
|
freeze_name_and_execute_if_not_ignored
|
@@ -879,11 +884,13 @@ module NewRelic
|
|
879
884
|
|
880
885
|
def normal_cpu_burn
|
881
886
|
return unless @process_cpu_start
|
887
|
+
|
882
888
|
process_cpu - @process_cpu_start
|
883
889
|
end
|
884
890
|
|
885
891
|
def jruby_cpu_burn
|
886
892
|
return unless @jruby_cpu_start
|
893
|
+
|
887
894
|
jruby_cpu_time - @jruby_cpu_start
|
888
895
|
end
|
889
896
|
|
@@ -919,15 +926,18 @@ module NewRelic
|
|
919
926
|
|
920
927
|
def process_cpu
|
921
928
|
return nil if defined? JRuby
|
929
|
+
|
922
930
|
p = Process.times
|
923
931
|
p.stime + p.utime
|
924
932
|
end
|
925
933
|
|
926
934
|
def jruby_cpu_time
|
927
935
|
return nil unless @@java_classes_loaded
|
936
|
+
|
928
937
|
threadMBean = Java::JavaLangManagement::ManagementFactory.getThreadMXBean()
|
929
938
|
|
930
939
|
return nil unless threadMBean.isCurrentThreadCpuTimeSupported
|
940
|
+
|
931
941
|
java_utime = threadMBean.getCurrentThreadUserTime() # ns
|
932
942
|
|
933
943
|
-1 == java_utime ? 0.0 : java_utime / 1e9
|
@@ -127,6 +127,7 @@ module NewRelic
|
|
127
127
|
|
128
128
|
def split_transaction_at_harvest(timestamp, thread_id = nil)
|
129
129
|
raise ArgumentError, 'thread_id required' unless thread_id
|
130
|
+
|
130
131
|
@stats[thread_id].transaction_started_at = timestamp
|
131
132
|
@stats[thread_id].elapsed_transaction_time = 0.0
|
132
133
|
end
|
@@ -134,6 +134,7 @@ module NewRelic
|
|
134
134
|
def valid_chars?(value)
|
135
135
|
value.each_char do |ch|
|
136
136
|
next if ch =~ VALID_CHARS
|
137
|
+
|
137
138
|
code_point = ch[0].ord # this works in Ruby 1.8.7 - 2.1.2
|
138
139
|
next if code_point >= 0x80
|
139
140
|
|
@@ -145,6 +146,7 @@ module NewRelic
|
|
145
146
|
|
146
147
|
def transform_key(key)
|
147
148
|
return key unless key_transforms
|
149
|
+
|
148
150
|
key_transforms.inject(key) { |memo, transform| memo.send(transform) }
|
149
151
|
end
|
150
152
|
|
@@ -87,6 +87,7 @@ module NewRelic
|
|
87
87
|
def append_vendor_info(collector_hash)
|
88
88
|
VENDORS.each_pair do |klass, config_option|
|
89
89
|
next unless Agent.config[config_option]
|
90
|
+
|
90
91
|
vendor = klass.new
|
91
92
|
|
92
93
|
if vendor.detect
|
@@ -125,6 +126,7 @@ module NewRelic
|
|
125
126
|
|
126
127
|
def append_kubernetes_info(collector_hash)
|
127
128
|
return unless Agent.config[:'utilization.detect_kubernetes']
|
129
|
+
|
128
130
|
if host = ENV[KUBERNETES_SERVICE_HOST]
|
129
131
|
collector_hash[:vendors] ||= {}
|
130
132
|
collector_hash[:vendors][:kubernetes] = {
|
@@ -136,6 +138,7 @@ module NewRelic
|
|
136
138
|
def append_full_hostname(collector_hash)
|
137
139
|
full_hostname = fqdn
|
138
140
|
return if full_hostname.nil? || full_hostname.empty?
|
141
|
+
|
139
142
|
collector_hash[:full_hostname] = full_hostname
|
140
143
|
end
|
141
144
|
|
data/lib/new_relic/agent.rb
CHANGED
@@ -102,8 +102,6 @@ module NewRelic
|
|
102
102
|
# An error while serializing data for the collector
|
103
103
|
class SerializationError < StandardError; end
|
104
104
|
|
105
|
-
class BackgroundLoadingError < StandardError; end
|
106
|
-
|
107
105
|
# placeholder name used when we cannot determine a transaction's name
|
108
106
|
UNKNOWN_METRIC = '(unknown)'.freeze
|
109
107
|
|
@@ -115,6 +113,7 @@ module NewRelic
|
|
115
113
|
# The singleton Agent instance. Used internally.
|
116
114
|
def agent # :nodoc:
|
117
115
|
return @agent if @agent
|
116
|
+
|
118
117
|
NewRelic::Agent.logger.warn("Agent unavailable as it hasn't been started.")
|
119
118
|
NewRelic::Agent.logger.warn(caller.join("\n"))
|
120
119
|
nil
|
@@ -217,6 +216,7 @@ module NewRelic
|
|
217
216
|
|
218
217
|
def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS
|
219
218
|
return unless agent
|
219
|
+
|
220
220
|
if amount == 1
|
221
221
|
metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]
|
222
222
|
agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }
|
@@ -347,6 +347,7 @@ module NewRelic
|
|
347
347
|
#
|
348
348
|
def manual_start(options = {})
|
349
349
|
raise "Options must be a hash" unless Hash === options
|
350
|
+
|
350
351
|
NewRelic::Control.instance.init_plugin({:agent_enabled => true, :sync_startup => true}.merge(options))
|
351
352
|
record_api_supportability_metric(:manual_start)
|
352
353
|
end
|
@@ -757,6 +758,7 @@ module NewRelic
|
|
757
758
|
record_api_supportability_metric(:browser_timing_header)
|
758
759
|
|
759
760
|
return EMPTY_STR unless agent
|
761
|
+
|
760
762
|
agent.javascript_instrumentor.browser_timing_header(nonce)
|
761
763
|
end
|
762
764
|
|
@@ -42,6 +42,7 @@ class NewRelic::Cli::Install < NewRelic::Cli::Command
|
|
42
42
|
if File.exist?(dest_file) && !@force
|
43
43
|
raise NewRelic::Cli::Command::CommandFailure, "newrelic.yml file already exists. Use --force flag to overwrite."
|
44
44
|
end
|
45
|
+
|
45
46
|
File.open(dest_file, 'w') { |out| out.puts(content) }
|
46
47
|
|
47
48
|
puts <<-EOF unless quiet
|
data/lib/new_relic/coerce.rb
CHANGED
@@ -22,6 +22,7 @@ module NewRelic
|
|
22
22
|
|
23
23
|
def int_or_nil(value, context = nil)
|
24
24
|
return nil if value.nil?
|
25
|
+
|
25
26
|
Integer(value)
|
26
27
|
rescue => error
|
27
28
|
log_failure(value, Integer, context, error)
|
@@ -31,6 +32,7 @@ module NewRelic
|
|
31
32
|
def float(value, context = nil)
|
32
33
|
result = Float(value)
|
33
34
|
raise "Value #{result.inspect} is not finite." unless result.finite?
|
35
|
+
|
34
36
|
result
|
35
37
|
rescue => error
|
36
38
|
log_failure(value, Float, context, error)
|
@@ -39,6 +41,7 @@ module NewRelic
|
|
39
41
|
|
40
42
|
def string(value, context = nil)
|
41
43
|
return value if value.nil?
|
44
|
+
|
42
45
|
String(value)
|
43
46
|
rescue => error
|
44
47
|
log_failure(value.class, String, context, error)
|
@@ -62,6 +65,7 @@ module NewRelic
|
|
62
65
|
|
63
66
|
def int!(value)
|
64
67
|
return nil unless value_or_nil(value)
|
68
|
+
|
65
69
|
Integer(value)
|
66
70
|
end
|
67
71
|
|
@@ -74,11 +78,13 @@ module NewRelic
|
|
74
78
|
|
75
79
|
def float!(value, precision = NewRelic::PRIORITY_PRECISION)
|
76
80
|
return nil unless value_or_nil(value)
|
81
|
+
|
77
82
|
value.to_f.round(precision)
|
78
83
|
end
|
79
84
|
|
80
85
|
def value_or_nil(value)
|
81
86
|
return nil if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
87
|
+
|
82
88
|
value
|
83
89
|
end
|
84
90
|
|
@@ -13,6 +13,7 @@ module NewRelic
|
|
13
13
|
when Hash
|
14
14
|
# Optimize for empty hash since that is often what this is called with.
|
15
15
|
return params if params.empty?
|
16
|
+
|
16
17
|
new_params = {}
|
17
18
|
params.each do |key, value|
|
18
19
|
new_params[truncate(normalize_params(key), 64)] = normalize_params(value)
|
@@ -68,11 +68,14 @@ module NewRelic
|
|
68
68
|
|
69
69
|
def install_agent_hooks(config)
|
70
70
|
return if defined?(@agent_hooks_installed) && @agent_hooks_installed
|
71
|
+
|
71
72
|
@agent_hooks_installed = true
|
72
73
|
return if config.nil? || !config.respond_to?(:middleware)
|
74
|
+
|
73
75
|
begin
|
74
76
|
require 'new_relic/rack/agent_hooks'
|
75
77
|
return unless NewRelic::Rack::AgentHooks.needed?
|
78
|
+
|
76
79
|
config.middleware.use(NewRelic::Rack::AgentHooks)
|
77
80
|
::NewRelic::Agent.logger.debug("Installed New Relic Agent Hooks middleware")
|
78
81
|
rescue => e
|
@@ -83,8 +86,10 @@ module NewRelic
|
|
83
86
|
def install_browser_monitoring(config)
|
84
87
|
@install_lock.synchronize do
|
85
88
|
return if defined?(@browser_monitoring_installed) && @browser_monitoring_installed
|
89
|
+
|
86
90
|
@browser_monitoring_installed = true
|
87
91
|
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
92
|
+
|
88
93
|
begin
|
89
94
|
require 'new_relic/rack/browser_monitoring'
|
90
95
|
config.middleware.use(NewRelic::Rack::BrowserMonitoring)
|
@@ -70,6 +70,7 @@ module NewRelic
|
|
70
70
|
|
71
71
|
def rails_32_deprecation
|
72
72
|
return unless defined?(Rails::VERSION) && Gem::Version.new(Rails::VERSION::STRING) <= Gem::Version.new('3.2')
|
73
|
+
|
73
74
|
deprecation_msg = 'The Ruby Agent is dropping support for Rails 3.2 ' \
|
74
75
|
'in a future major release. Please upgrade your Rails version to continue receiving support. ' \
|
75
76
|
|
@@ -84,6 +85,7 @@ module NewRelic
|
|
84
85
|
|
85
86
|
def ruby_22_deprecation
|
86
87
|
return unless RUBY_VERSION <= '2.2.0'
|
88
|
+
|
87
89
|
deprecation_msg = 'The Ruby Agent is dropping support for Ruby 2.2 ' \
|
88
90
|
'in version 9.0.0. Please upgrade your Ruby version to continue receiving support. ' \
|
89
91
|
|
@@ -165,6 +165,7 @@ module DependencyDetection
|
|
165
165
|
|
166
166
|
def config_key
|
167
167
|
return nil if self.config_name.nil?
|
168
|
+
|
168
169
|
@config_key ||= "instrumentation.#{self.config_name}".to_sym
|
169
170
|
end
|
170
171
|
|
@@ -193,6 +194,7 @@ module DependencyDetection
|
|
193
194
|
|
194
195
|
def config_value
|
195
196
|
return AUTO_CONFIG_VALUE unless config_key
|
197
|
+
|
196
198
|
fetch_config_value(config_key)
|
197
199
|
end
|
198
200
|
|
data/lib/new_relic/helper.rb
CHANGED
@@ -17,6 +17,7 @@ module NewRelic
|
|
17
17
|
# If not force the encoding to ASCII-8BIT (binary)
|
18
18
|
def correctly_encoded(string)
|
19
19
|
return string unless string.is_a?(String)
|
20
|
+
|
20
21
|
# The .dup here is intentional, since force_encoding mutates the target,
|
21
22
|
# and we don't know who is going to use this string downstream of us.
|
22
23
|
string.valid_encoding? ? string : string.dup.force_encoding(Encoding::ASCII_8BIT)
|
@@ -85,6 +85,7 @@ module NewRelic
|
|
85
85
|
def check_for_torquebox
|
86
86
|
return unless defined?(::JRuby) &&
|
87
87
|
(org.torquebox::TorqueBox rescue nil)
|
88
|
+
|
88
89
|
@discovered_dispatcher = :torquebox
|
89
90
|
end
|
90
91
|
|
@@ -93,11 +94,13 @@ module NewRelic
|
|
93
94
|
(((com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory rescue nil) &&
|
94
95
|
defined?(com::sun::grizzly::jruby::rack::DefaultRackApplicationFactory)) ||
|
95
96
|
(jruby_rack? && defined?(::GlassFish::Server)))
|
97
|
+
|
96
98
|
@discovered_dispatcher = :glassfish
|
97
99
|
end
|
98
100
|
|
99
101
|
def check_for_trinidad
|
100
102
|
return unless defined?(::JRuby) && jruby_rack? && defined?(::Trinidad::Server)
|
103
|
+
|
101
104
|
@discovered_dispatcher = :trinidad
|
102
105
|
end
|
103
106
|
|
@@ -107,17 +110,20 @@ module NewRelic
|
|
107
110
|
|
108
111
|
def check_for_webrick
|
109
112
|
return unless defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
113
|
+
|
110
114
|
@discovered_dispatcher = :webrick
|
111
115
|
end
|
112
116
|
|
113
117
|
def check_for_fastcgi
|
114
118
|
return unless defined?(::FCGI)
|
119
|
+
|
115
120
|
@discovered_dispatcher = :fastcgi
|
116
121
|
end
|
117
122
|
|
118
123
|
# this case covers starting by mongrel_rails
|
119
124
|
def check_for_mongrel
|
120
125
|
return unless defined?(::Mongrel) && defined?(::Mongrel::HttpServer)
|
126
|
+
|
121
127
|
@discovered_dispatcher = :mongrel
|
122
128
|
end
|
123
129
|
|
@@ -44,6 +44,7 @@ class NewRelic::MetricSpec
|
|
44
44
|
|
45
45
|
def to_s
|
46
46
|
return name if scope.empty?
|
47
|
+
|
47
48
|
"#{name}:#{scope}"
|
48
49
|
end
|
49
50
|
|
@@ -59,6 +60,7 @@ class NewRelic::MetricSpec
|
|
59
60
|
def <=>(o)
|
60
61
|
namecmp = self.name <=> o.name
|
61
62
|
return namecmp if namecmp != 0
|
63
|
+
|
62
64
|
return (self.scope || '') <=> (o.scope || '')
|
63
65
|
end
|
64
66
|
end
|
@@ -33,11 +33,13 @@ module NewRelic
|
|
33
33
|
# response code before it goes back to the client.
|
34
34
|
def capture_http_response_code(state, result)
|
35
35
|
return if NewRelic::Agent.config[:disable_middleware_instrumentation]
|
36
|
+
|
36
37
|
super
|
37
38
|
end
|
38
39
|
|
39
40
|
def capture_response_content_type(state, result)
|
40
41
|
return if NewRelic::Agent.config[:disable_middleware_instrumentation]
|
42
|
+
|
41
43
|
super
|
42
44
|
end
|
43
45
|
end
|
@@ -28,6 +28,7 @@ module NewRelic
|
|
28
28
|
|
29
29
|
def create_traced_block(*args, &block)
|
30
30
|
return block if NewRelic::Agent.config[:'instrumentation.thread.tracing'] # if this is on, don't double trace
|
31
|
+
|
31
32
|
NewRelic::Agent::Tracer.thread_block_with_current_transaction(*args, &block)
|
32
33
|
end
|
33
34
|
end
|