You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: error_trace_aggregator.rb
    path of file: ./repos/newrelic-ruby-agent/lib/new_relic/agent
    
    the code of the file until where you have to start completion: # -*- ruby -*-
# 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
    class ErrorTraceAggregator
   
    
      def notice_agent_error(exception)
        return unless exception.class < NewRelic::Agent::InternalAgentError

        # Log 'em all!
        NewRelic::Agent.logger.info(exception)

        @lock.synchronize do
          # Already seen this class once? Bail!
          return if @errors.any? { |err| err.exception_class_name == exception.class.name }

          noticed_error = NewRelic::Agent.instance.error_collector.create_noticed_error(exception,
            {metric: 'NewRelic/AgentError'})
          noticed_error.stack_trace = caller.dup unless exception.backtrace

          @errors << noticed_error
        end
      rescue => e
        NewRelic::Agent.logger.info('Unable to capture internal agent error due to an exception:', e)
      end