lib/elastic_apm/agent.rb in elastic-apm-2.9.1 vs lib/elastic_apm/agent.rb in elastic-apm-2.10.0
- old
+ new
@@ -1,15 +1,19 @@
# frozen_string_literal: true
+require 'elastic_apm/error'
+
require 'elastic_apm/context_builder'
require 'elastic_apm/error_builder'
require 'elastic_apm/stacktrace_builder'
-require 'elastic_apm/error'
+
+require 'elastic_apm/central_config'
require 'elastic_apm/transport/base'
-require 'elastic_apm/spies'
require 'elastic_apm/metrics'
+require 'elastic_apm/spies'
+
module ElasticAPM
# rubocop:disable Metrics/ClassLength
# @api private
class Agent
include Logging
@@ -55,24 +59,27 @@
def self.running?
!!@instance
end
+ # rubocop:disable Metrics/MethodLength
def initialize(config)
@config = config
@stacktrace_builder = StacktraceBuilder.new(config)
@context_builder = ContextBuilder.new(config)
@error_builder = ErrorBuilder.new(self)
+ @central_config = CentralConfig.new(config)
@transport = Transport::Base.new(config)
@instrumenter = Instrumenter.new(
config,
stacktrace_builder: stacktrace_builder
) { |event| enqueue event }
@metrics = Metrics.new(config) { |event| enqueue event }
end
+ # rubocop:enable Metrics/MethodLength
attr_reader :config, :transport, :instrumenter,
:stacktrace_builder, :context_builder, :error_builder, :metrics
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@@ -187,19 +194,21 @@
exception,
context: context,
handled: handled
)
enqueue error
+ error.id
end
def report_message(message, context: nil, backtrace: nil, **attrs)
error = @error_builder.build_log(
message,
context: context,
backtrace: backtrace,
**attrs
)
enqueue error
+ error.id
end
# filters
def add_filter(key, callback)