Module: NewRelic::Agent::Instrumentation::Logger
- Included in:
- Prepend
- Defined in:
- lib/new_relic/agent/instrumentation/logger/chain.rb,
lib/new_relic/agent/instrumentation/logger/instrumentation.rb more...
Defined Under Namespace
Modules: Prepend
Constant Summary collapse
- INSTRUMENTATION_NAME =
'Logger'
Class Method Summary collapse
- .clear_skip_instrumenting(logger) ⇒ Object
- .enabled? ⇒ Boolean
- .instrument! ⇒ Object
-
.mark_skip_instrumenting(logger) ⇒ Object
We support setting this on loggers which might not have instrumentation installed yet.
Instance Method Summary collapse
- #clear_skip_instrumenting ⇒ Object
- #format_message_with_tracing(severity, datetime, progname, msg) ⇒ Object
- #mark_skip_instrumenting ⇒ Object
- #skip_instrumenting? ⇒ Boolean
Class Method Details
permalink .clear_skip_instrumenting(logger) ⇒ Object
[View source]
24 25 26 27 28 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 24 def self.clear_skip_instrumenting(logger) return if logger.frozen? logger.instance_variable_set(:@skip_instrumenting, false) end |
permalink .enabled? ⇒ Boolean
42 43 44 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 42 def self.enabled? NewRelic::Agent.config[:'instrumentation.logger'] != 'disabled' end |
permalink .instrument! ⇒ Object
[View source]
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/new_relic/agent/instrumentation/logger/chain.rb', line 7 def self.instrument! ::Logger.class_eval do include NewRelic::Agent::Instrumentation::Logger alias_method(:format_message_without_new_relic, :format_message) def (severity, datetime, progname, msg) (severity, datetime, progname, msg) do (severity, datetime, progname, msg) end end end end |
permalink .mark_skip_instrumenting(logger) ⇒ Object
We support setting this on loggers which might not have instrumentation installed yet. This lets us disable in AgentLogger and AuditLogger without them having to know the inner details.
18 19 20 21 22 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 18 def self.mark_skip_instrumenting(logger) return if logger.frozen? logger.instance_variable_set(:@skip_instrumenting, true) end |
Instance Method Details
permalink #clear_skip_instrumenting ⇒ Object
[View source]
36 37 38 39 40 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 36 def clear_skip_instrumenting return if frozen? @skip_instrumenting = false end |
permalink #format_message_with_tracing(severity, datetime, progname, msg) ⇒ Object
[View source]
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 46 def (severity, datetime, progname, msg) = yield return if skip_instrumenting? begin # It's critical we don't instrument logging from metric recording # methods within NewRelic::Agent, or we'll stack overflow!! mark_skip_instrumenting unless ::NewRelic::Agent.agent.nil? ::NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME) ::NewRelic::Agent.agent.log_event_aggregator.record(, severity) = LocalLogDecorator.decorate() end ensure clear_skip_instrumenting end end |
permalink #mark_skip_instrumenting ⇒ Object
[View source]
30 31 32 33 34 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 30 def mark_skip_instrumenting return if frozen? @skip_instrumenting = true end |
permalink #skip_instrumenting? ⇒ Boolean
11 12 13 |
# File 'lib/new_relic/agent/instrumentation/logger/instrumentation.rb', line 11 def skip_instrumenting? defined?(@skip_instrumenting) && @skip_instrumenting end |