newrelic_rpm 9.7.0 → 9.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +376 -2
- data/README.md +17 -18
- data/Rakefile +1 -1
- data/lib/boot/strap.rb +101 -0
- data/lib/new_relic/agent/agent.rb +4 -1
- data/lib/new_relic/agent/agent_helpers/connect.rb +10 -8
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/startup.rb +2 -1
- data/lib/new_relic/agent/agent_logger.rb +3 -1
- data/lib/new_relic/agent/aws.rb +68 -0
- data/lib/new_relic/agent/configuration/default_source.rb +519 -23
- data/lib/new_relic/agent/configuration/environment_source.rb +14 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
- data/lib/new_relic/agent/configuration/manager.rb +51 -8
- data/lib/new_relic/agent/configuration/security_policy_source.rb +11 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +2 -0
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +27 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +11 -11
- data/lib/new_relic/agent/database/obfuscator.rb +1 -0
- data/lib/new_relic/agent/database.rb +39 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -5
- data/lib/new_relic/agent/error_collector.rb +39 -10
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +0 -13
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -8
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -0
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -12
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +7 -3
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +0 -2
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +0 -2
- data/lib/new_relic/agent/instrumentation/async_http.rb +4 -3
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/chain.rb +37 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/instrumentation.rb +67 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs.rb +23 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +14 -0
- data/lib/new_relic/agent/instrumentation/bunny.rb +3 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +1 -2
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -4
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -23
- data/lib/new_relic/agent/instrumentation/dynamodb/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +64 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/prepend.rb +19 -0
- data/lib/new_relic/agent/instrumentation/dynamodb.rb +23 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +58 -8
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +0 -2
- data/lib/new_relic/agent/instrumentation/ethon.rb +0 -4
- data/lib/new_relic/agent/instrumentation/excon.rb +0 -16
- data/lib/new_relic/agent/instrumentation/fiber.rb +0 -2
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpx.rb +0 -4
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
- data/lib/new_relic/agent/instrumentation/logstasher/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logstasher/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/logstasher/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logstasher.rb +25 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +0 -1
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +6 -0
- data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/opensearch.rb +23 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +9 -5
- data/lib/new_relic/agent/instrumentation/rake.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +72 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/instrumentation.rb +70 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +67 -0
- data/lib/new_relic/agent/instrumentation/rdkafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/redis/cluster_middleware.rb +26 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +14 -11
- data/lib/new_relic/agent/instrumentation/redis/middleware.rb +3 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +11 -5
- data/lib/new_relic/agent/instrumentation/resque.rb +0 -4
- data/lib/new_relic/agent/instrumentation/roda.rb +4 -4
- data/lib/new_relic/agent/instrumentation/ruby_kafka/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/instrumentation.rb +67 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +60 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/instrumentation.rb +196 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai.rb +35 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -14
- data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -19
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +22 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
- data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
- data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +13 -6
- data/lib/new_relic/agent/instrumentation/view_component.rb +0 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +2 -3
- data/lib/new_relic/agent/llm/chat_completion_message.rb +25 -0
- data/lib/new_relic/agent/llm/chat_completion_summary.rb +66 -0
- data/lib/new_relic/agent/llm/embedding.rb +60 -0
- data/lib/new_relic/agent/llm/llm_event.rb +95 -0
- data/lib/new_relic/agent/llm/response_headers.rb +80 -0
- data/lib/new_relic/agent/llm.rb +49 -0
- data/lib/new_relic/agent/local_log_decorator.rb +8 -1
- data/lib/new_relic/agent/log_event_aggregator.rb +120 -44
- data/lib/new_relic/agent/messaging.rb +11 -5
- data/lib/new_relic/agent/new_relic_service.rb +12 -2
- data/lib/new_relic/agent/serverless_handler.rb +400 -0
- data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
- data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
- data/lib/new_relic/agent/span_event_primitive.rb +8 -10
- data/lib/new_relic/agent/system_info.rb +14 -0
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -2
- data/lib/new_relic/agent/tracer.rb +5 -5
- data/lib/new_relic/agent/transaction/abstract_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/external_request_segment.rb +0 -10
- data/lib/new_relic/agent/transaction/request_attributes.rb +13 -1
- data/lib/new_relic/agent/transaction/trace_context.rb +1 -1
- data/lib/new_relic/agent/transaction/tracing.rb +2 -2
- data/lib/new_relic/agent/transaction.rb +2 -6
- data/lib/new_relic/agent/transaction_error_primitive.rb +23 -19
- data/lib/new_relic/agent.rb +198 -10
- data/lib/new_relic/constants.rb +2 -0
- data/lib/new_relic/control/frameworks/grape.rb +14 -0
- data/lib/new_relic/control/frameworks/padrino.rb +14 -0
- data/lib/new_relic/control/frameworks/rails4.rb +1 -3
- data/lib/new_relic/control/instance_methods.rb +8 -0
- data/lib/new_relic/control/private_instance_methods.rb +4 -0
- data/lib/new_relic/control/security_interface.rb +57 -0
- data/lib/new_relic/control.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +10 -5
- data/lib/new_relic/environment_report.rb +2 -2
- data/lib/new_relic/helper.rb +15 -0
- data/lib/new_relic/language_support.rb +3 -1
- data/lib/new_relic/local_environment.rb +14 -10
- data/lib/new_relic/rack/browser_monitoring.rb +28 -12
- data/lib/new_relic/supportability_helper.rb +2 -0
- data/lib/new_relic/thread_local_storage.rb +31 -0
- data/lib/new_relic/version.rb +2 -2
- data/lib/sequel/extensions/new_relic_instrumentation.rb +3 -2
- data/lib/tasks/config.rake +8 -3
- data/lib/tasks/gha.rake +31 -0
- data/lib/tasks/helpers/config.html.erb +3 -2
- data/lib/tasks/helpers/format.rb +1 -1
- data/lib/tasks/helpers/newrelicyml.rb +76 -13
- data/lib/tasks/instrumentation_generator/instrumentation.thor +31 -22
- data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -1
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -1
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +11 -8
- data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +1 -1
- data/newrelic.yml +387 -143
- data/newrelic_rpm.gemspec +2 -0
- data/test/agent_helper.rb +17 -2
- metadata +80 -3
@@ -20,10 +20,12 @@ module NewRelic
|
|
20
20
|
DROPPED_METRIC = 'Logging/Forwarding/Dropped'.freeze
|
21
21
|
SEEN_METRIC = 'Supportability/Logging/Forwarding/Seen'.freeze
|
22
22
|
SENT_METRIC = 'Supportability/Logging/Forwarding/Sent'.freeze
|
23
|
-
|
23
|
+
LOGGER_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Ruby/Logger/%s'.freeze
|
24
|
+
LOGSTASHER_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Ruby/LogStasher/%s'.freeze
|
24
25
|
METRICS_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Metrics/Ruby/%s'.freeze
|
25
26
|
FORWARDING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Forwarding/Ruby/%s'.freeze
|
26
27
|
DECORATING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/LocalDecorating/Ruby/%s'.freeze
|
28
|
+
LABELS_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Labels/Ruby/%s'.freeze
|
27
29
|
MAX_BYTES = 32768 # 32 * 1024 bytes (32 kibibytes)
|
28
30
|
|
29
31
|
named :LogEventAggregator
|
@@ -37,6 +39,7 @@ module NewRelic
|
|
37
39
|
METRICS_ENABLED_KEY = :'application_logging.metrics.enabled'
|
38
40
|
FORWARDING_ENABLED_KEY = :'application_logging.forwarding.enabled'
|
39
41
|
DECORATING_ENABLED_KEY = :'application_logging.local_decorating.enabled'
|
42
|
+
LABELS_ENABLED_KEY = :'application_logging.forwarding.labels.enabled'
|
40
43
|
LOG_LEVEL_KEY = :'application_logging.forwarding.log_level'
|
41
44
|
CUSTOM_ATTRIBUTES_KEY = :'application_logging.forwarding.custom_attributes'
|
42
45
|
|
@@ -50,6 +53,7 @@ module NewRelic
|
|
50
53
|
@high_security = NewRelic::Agent.config[:high_security]
|
51
54
|
@instrumentation_logger_enabled = NewRelic::Agent::Instrumentation::Logger.enabled?
|
52
55
|
@attributes = NewRelic::Agent::LogEventAttributes.new
|
56
|
+
|
53
57
|
register_for_done_configuring(events)
|
54
58
|
end
|
55
59
|
|
@@ -58,38 +62,71 @@ module NewRelic
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def record(formatted_message, severity)
|
61
|
-
return unless
|
65
|
+
return unless logger_enabled?
|
62
66
|
|
63
67
|
severity = 'UNKNOWN' if severity.nil? || severity.empty?
|
68
|
+
increment_event_counters(severity)
|
69
|
+
|
70
|
+
return if formatted_message.nil? || formatted_message.empty?
|
71
|
+
return unless monitoring_conditions_met?(severity)
|
72
|
+
|
73
|
+
txn = NewRelic::Agent::Transaction.tl_current
|
74
|
+
priority = LogPriority.priority_for(txn)
|
75
|
+
|
76
|
+
return txn.add_log_event(create_event(priority, formatted_message, severity)) if txn
|
64
77
|
|
65
|
-
|
66
|
-
@
|
67
|
-
|
68
|
-
@seen_by_severity[severity] += 1
|
78
|
+
@lock.synchronize do
|
79
|
+
@buffer.append(priority: priority) do
|
80
|
+
create_event(priority, formatted_message, severity)
|
69
81
|
end
|
70
82
|
end
|
83
|
+
rescue
|
84
|
+
nil
|
85
|
+
end
|
71
86
|
|
72
|
-
|
73
|
-
return
|
74
|
-
|
75
|
-
|
87
|
+
def record_logstasher_event(log)
|
88
|
+
return unless logstasher_enabled?
|
89
|
+
|
90
|
+
# LogStasher logs do not inherently include a message key, so most logs are recorded.
|
91
|
+
# But when the key exists, we should not record the log if the message value is nil or empty.
|
92
|
+
return if log.key?('message') && (log['message'].nil? || log['message'].empty?)
|
93
|
+
|
94
|
+
severity = determine_severity(log)
|
95
|
+
increment_event_counters(severity)
|
96
|
+
|
97
|
+
return unless monitoring_conditions_met?(severity)
|
76
98
|
|
77
99
|
txn = NewRelic::Agent::Transaction.tl_current
|
78
100
|
priority = LogPriority.priority_for(txn)
|
79
101
|
|
80
|
-
if txn
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
create_event(priority, formatted_message, severity)
|
86
|
-
end
|
102
|
+
return txn.add_log_event(create_logstasher_event(priority, severity, log)) if txn
|
103
|
+
|
104
|
+
@lock.synchronize do
|
105
|
+
@buffer.append(priority: priority) do
|
106
|
+
create_logstasher_event(priority, severity, log)
|
87
107
|
end
|
88
108
|
end
|
89
109
|
rescue
|
90
110
|
nil
|
91
111
|
end
|
92
112
|
|
113
|
+
def monitoring_conditions_met?(severity)
|
114
|
+
!severity_too_low?(severity) && NewRelic::Agent.config[FORWARDING_ENABLED_KEY] && !@high_security
|
115
|
+
end
|
116
|
+
|
117
|
+
def determine_severity(log)
|
118
|
+
log['level'] ? log['level'].to_s.upcase : 'UNKNOWN'
|
119
|
+
end
|
120
|
+
|
121
|
+
def increment_event_counters(severity)
|
122
|
+
return unless NewRelic::Agent.config[METRICS_ENABLED_KEY]
|
123
|
+
|
124
|
+
@counter_lock.synchronize do
|
125
|
+
@seen += 1
|
126
|
+
@seen_by_severity[severity] += 1
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
93
130
|
def record_batch(txn, logs)
|
94
131
|
# Ensure we have the same shared priority
|
95
132
|
priority = LogPriority.priority_for(txn)
|
@@ -104,15 +141,17 @@ module NewRelic
|
|
104
141
|
end
|
105
142
|
end
|
106
143
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
event = LinkingMetadata.append_trace_linking_metadata({
|
144
|
+
def add_event_metadata(formatted_message, severity)
|
145
|
+
metadata = {
|
111
146
|
LEVEL_KEY => severity,
|
112
|
-
MESSAGE_KEY => formatted_message,
|
113
147
|
TIMESTAMP_KEY => Process.clock_gettime(Process::CLOCK_REALTIME) * 1000
|
114
|
-
}
|
148
|
+
}
|
149
|
+
metadata[MESSAGE_KEY] = formatted_message unless formatted_message.nil?
|
150
|
+
|
151
|
+
LinkingMetadata.append_trace_linking_metadata(metadata)
|
152
|
+
end
|
115
153
|
|
154
|
+
def create_prioritized_event(priority, event)
|
116
155
|
[
|
117
156
|
{
|
118
157
|
PrioritySampledBuffer::PRIORITY_KEY => priority
|
@@ -121,10 +160,39 @@ module NewRelic
|
|
121
160
|
]
|
122
161
|
end
|
123
162
|
|
163
|
+
def create_event(priority, formatted_message, severity)
|
164
|
+
formatted_message = truncate_message(formatted_message)
|
165
|
+
event = add_event_metadata(formatted_message, severity)
|
166
|
+
|
167
|
+
create_prioritized_event(priority, event)
|
168
|
+
end
|
169
|
+
|
170
|
+
def create_logstasher_event(priority, severity, log)
|
171
|
+
formatted_message = log['message'] ? truncate_message(log['message']) : nil
|
172
|
+
event = add_event_metadata(formatted_message, severity)
|
173
|
+
add_logstasher_event_attributes(event, log)
|
174
|
+
|
175
|
+
create_prioritized_event(priority, event)
|
176
|
+
end
|
177
|
+
|
178
|
+
def add_logstasher_event_attributes(event, log)
|
179
|
+
log_copy = log.dup
|
180
|
+
# Delete previously reported attributes
|
181
|
+
log_copy.delete('message')
|
182
|
+
log_copy.delete('level')
|
183
|
+
log_copy.delete('@timestamp')
|
184
|
+
|
185
|
+
event['attributes'] = log_copy
|
186
|
+
end
|
187
|
+
|
124
188
|
def add_custom_attributes(custom_attributes)
|
125
189
|
attributes.add_custom_attributes(custom_attributes)
|
126
190
|
end
|
127
191
|
|
192
|
+
def labels
|
193
|
+
@labels ||= create_labels
|
194
|
+
end
|
195
|
+
|
128
196
|
# Because our transmission format (MELT) is different than historical
|
129
197
|
# agent payloads, extract the munging here to keep the service focused
|
130
198
|
# on the general harvest + transmit instead of the format.
|
@@ -140,8 +208,9 @@ module NewRelic
|
|
140
208
|
# To save on unnecessary data transmission, trim the entity.type
|
141
209
|
# sent by classic logs-in-context
|
142
210
|
common_attributes.delete(ENTITY_TYPE_KEY)
|
143
|
-
|
144
|
-
common_attributes.merge!(
|
211
|
+
aggregator = NewRelic::Agent.agent.log_event_aggregator
|
212
|
+
common_attributes.merge!(aggregator.attributes.custom_attributes)
|
213
|
+
common_attributes.merge!(aggregator.labels)
|
145
214
|
|
146
215
|
_, items = data
|
147
216
|
payload = [{
|
@@ -166,10 +235,14 @@ module NewRelic
|
|
166
235
|
super
|
167
236
|
end
|
168
237
|
|
169
|
-
def
|
238
|
+
def logger_enabled?
|
170
239
|
@enabled && @instrumentation_logger_enabled
|
171
240
|
end
|
172
241
|
|
242
|
+
def logstasher_enabled?
|
243
|
+
@enabled && NewRelic::Agent::Instrumentation::LogStasher.enabled?
|
244
|
+
end
|
245
|
+
|
173
246
|
private
|
174
247
|
|
175
248
|
# We record once-per-connect metrics for enabled/disabled state at the
|
@@ -177,11 +250,12 @@ module NewRelic
|
|
177
250
|
def register_for_done_configuring(events)
|
178
251
|
events.subscribe(:server_source_configuration_added) do
|
179
252
|
@high_security = NewRelic::Agent.config[:high_security]
|
180
|
-
|
181
|
-
record_configuration_metric(
|
253
|
+
record_configuration_metric(LOGGER_SUPPORTABILITY_FORMAT, OVERALL_ENABLED_KEY)
|
254
|
+
record_configuration_metric(LOGSTASHER_SUPPORTABILITY_FORMAT, OVERALL_ENABLED_KEY)
|
182
255
|
record_configuration_metric(METRICS_SUPPORTABILITY_FORMAT, METRICS_ENABLED_KEY)
|
183
256
|
record_configuration_metric(FORWARDING_SUPPORTABILITY_FORMAT, FORWARDING_ENABLED_KEY)
|
184
257
|
record_configuration_metric(DECORATING_SUPPORTABILITY_FORMAT, DECORATING_ENABLED_KEY)
|
258
|
+
record_configuration_metric(LABELS_SUPPORTABILITY_FORMAT, LABELS_ENABLED_KEY)
|
185
259
|
|
186
260
|
add_custom_attributes(NewRelic::Agent.config[CUSTOM_ATTRIBUTES_KEY])
|
187
261
|
end
|
@@ -247,21 +321,6 @@ module NewRelic
|
|
247
321
|
message.byteslice(0...MAX_BYTES)
|
248
322
|
end
|
249
323
|
|
250
|
-
def minimum_log_level
|
251
|
-
if Logger::Severity.constants.include?(configured_log_level_constant)
|
252
|
-
configured_log_level_constant
|
253
|
-
else
|
254
|
-
NewRelic::Agent.logger.log_once(
|
255
|
-
:error,
|
256
|
-
'Invalid application_logging.forwarding.log_level ' \
|
257
|
-
"'#{NewRelic::Agent.config[LOG_LEVEL_KEY]}' specified! " \
|
258
|
-
"Must be one of #{Logger::Severity.constants.join('|')}. " \
|
259
|
-
"Using default level of 'debug'"
|
260
|
-
)
|
261
|
-
:DEBUG
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
324
|
def configured_log_level_constant
|
266
325
|
format_log_level_constant(NewRelic::Agent.config[LOG_LEVEL_KEY])
|
267
326
|
end
|
@@ -275,7 +334,24 @@ module NewRelic
|
|
275
334
|
# always record custom log levels
|
276
335
|
return false unless Logger::Severity.constants.include?(severity_constant)
|
277
336
|
|
278
|
-
Logger::Severity.const_get(severity_constant) < Logger::Severity.const_get(
|
337
|
+
Logger::Severity.const_get(severity_constant) < Logger::Severity.const_get(configured_log_level_constant)
|
338
|
+
end
|
339
|
+
|
340
|
+
def create_labels
|
341
|
+
return NewRelic::EMPTY_HASH unless NewRelic::Agent.config[LABELS_ENABLED_KEY]
|
342
|
+
|
343
|
+
downcased_exclusions = NewRelic::Agent.config[:'application_logging.forwarding.labels.exclude'].map(&:downcase)
|
344
|
+
log_labels = {}
|
345
|
+
|
346
|
+
NewRelic::Agent.config.parsed_labels.each do |parsed_label|
|
347
|
+
next if downcased_exclusions.include?(parsed_label['label_type'].downcase)
|
348
|
+
|
349
|
+
# labels are referred to as tags in the UI, so prefix the
|
350
|
+
# label-related attributes with 'tags.*'
|
351
|
+
log_labels["tags.#{parsed_label['label_type']}"] = parsed_label['label_value']
|
352
|
+
end
|
353
|
+
|
354
|
+
log_labels
|
279
355
|
end
|
280
356
|
end
|
281
357
|
end
|
@@ -117,7 +117,8 @@ module NewRelic
|
|
117
117
|
queue_name: nil,
|
118
118
|
exchange_type: nil,
|
119
119
|
reply_to: nil,
|
120
|
-
correlation_id: nil
|
120
|
+
correlation_id: nil,
|
121
|
+
action: nil)
|
121
122
|
|
122
123
|
state = Tracer.state
|
123
124
|
return yield if state.current_transaction
|
@@ -125,12 +126,12 @@ module NewRelic
|
|
125
126
|
txn = nil
|
126
127
|
|
127
128
|
begin
|
128
|
-
txn_name = transaction_name(library, destination_type, destination_name)
|
129
|
+
txn_name = transaction_name(library, destination_type, destination_name, action)
|
129
130
|
|
130
131
|
txn = Tracer.start_transaction(name: txn_name, category: :message)
|
131
|
-
|
132
132
|
if headers
|
133
|
-
|
133
|
+
NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(headers, library) # to handle the new w3c headers
|
134
|
+
txn.distributed_tracer.consume_message_headers(headers, state, library) # to do the expected old things
|
134
135
|
CrossAppTracing.reject_messaging_cat_headers(headers).each do |k, v|
|
135
136
|
txn.add_agent_attribute(:"message.headers.#{k}", v, AttributeFilter::DST_NONE) unless v.nil?
|
136
137
|
end
|
@@ -327,12 +328,17 @@ module NewRelic
|
|
327
328
|
NewRelic::Agent.config[:'message_tracer.segment_parameters.enabled']
|
328
329
|
end
|
329
330
|
|
330
|
-
def transaction_name(library, destination_type, destination_name)
|
331
|
+
def transaction_name(library, destination_type, destination_name, action = nil)
|
331
332
|
transaction_name = Transaction::MESSAGE_PREFIX + library
|
332
333
|
transaction_name << NewRelic::SLASH
|
333
334
|
transaction_name << Transaction::MessageBrokerSegment::TYPES[destination_type]
|
334
335
|
transaction_name << NewRelic::SLASH
|
335
336
|
|
337
|
+
if action == :consume
|
338
|
+
transaction_name << 'Consume'
|
339
|
+
transaction_name << NewRelic::SLASH
|
340
|
+
end
|
341
|
+
|
336
342
|
case destination_type
|
337
343
|
when :queue
|
338
344
|
transaction_name << Transaction::MessageBrokerSegment::NAMED
|
@@ -143,6 +143,9 @@ module NewRelic
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def metric_data(stats_hash)
|
146
|
+
# let the serverless handler handle serialization
|
147
|
+
return NewRelic::Agent.agent.serverless_handler.metric_data(stats_hash) if NewRelic::Agent.agent.serverless?
|
148
|
+
|
146
149
|
timeslice_start = stats_hash.started_at
|
147
150
|
timeslice_end = stats_hash.harvested_at || Process.clock_gettime(Process::CLOCK_REALTIME)
|
148
151
|
metric_data_array = build_metric_data_array(stats_hash)
|
@@ -154,6 +157,9 @@ module NewRelic
|
|
154
157
|
end
|
155
158
|
|
156
159
|
def error_data(unsent_errors)
|
160
|
+
# let the serverless handler handle serialization
|
161
|
+
return NewRelic::Agent.agent.serverless_handler.error_data(unsent_errors) if NewRelic::Agent.agent.serverless?
|
162
|
+
|
157
163
|
invoke_remote(:error_data, [@agent_id, unsent_errors],
|
158
164
|
:item_count => unsent_errors.size)
|
159
165
|
end
|
@@ -554,6 +560,8 @@ module NewRelic
|
|
554
560
|
# enough to be worth compressing, and handles any errors the
|
555
561
|
# server may return
|
556
562
|
def invoke_remote(method, payload = [], options = {})
|
563
|
+
return NewRelic::Agent.agent.serverless_handler.store_payload(method, payload) if NewRelic::Agent.agent.serverless?
|
564
|
+
|
557
565
|
start_ts = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
558
566
|
request_send_ts, response_check_ts = nil
|
559
567
|
data, encoding, size, serialize_finish_ts = marshal_payload(method, payload, options)
|
@@ -561,8 +569,10 @@ module NewRelic
|
|
561
569
|
response, request_send_ts, response_check_ts = invoke_remote_send_request(method, payload, data, encoding)
|
562
570
|
@marshaller.load(decompress_response(response))
|
563
571
|
ensure
|
564
|
-
|
565
|
-
|
572
|
+
unless NewRelic::Agent.agent.serverless?
|
573
|
+
record_timing_supportability_metrics(method, start_ts, serialize_finish_ts, request_send_ts, response_check_ts)
|
574
|
+
record_size_supportability_metrics(method, size, options[:item_count]) if size
|
575
|
+
end
|
566
576
|
end
|
567
577
|
|
568
578
|
def handle_serialization_error(method, e)
|