Sha256: c9a0855278fc97898fb02f0c2e09f9926b9329c0547653a8c1b7fd766a469c0e
Contents?: true
Size: 1.97 KB
Versions: 16
Compression:
Stored size: 1.97 KB
Contents
# This file is distributed under New Relic's license terms. # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. # frozen_string_literal: true module NewRelic module Agent module Instrumentation module Logger def skip_instrumenting? defined?(@skip_instrumenting) && @skip_instrumenting end # 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. def self.mark_skip_instrumenting(logger) return if logger.frozen? logger.instance_variable_set(:@skip_instrumenting, true) end def self.clear_skip_instrumenting(logger) return if logger.frozen? logger.instance_variable_set(:@skip_instrumenting, false) end def mark_skip_instrumenting return if frozen? @skip_instrumenting = true end def clear_skip_instrumenting return if frozen? @skip_instrumenting = false end def self.enabled? NewRelic::Agent.config[:'instrumentation.logger'] != 'disabled' end def format_message_with_tracing(severity, datetime, progname, msg) formatted_message = yield return formatted_message 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.agent.log_event_aggregator.record(formatted_message, severity) formatted_message = LocalLogDecorator.decorate(formatted_message) end formatted_message ensure clear_skip_instrumenting end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems