Method: Honeycomb::Client#initialize

Defined in:
lib/honeycomb/client.rb

#initialize(configuration:) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/honeycomb/client.rb', line 17

def initialize(configuration:)
  @libhoney = configuration.client
  # attempt to set the user_agent_addition, this will only work if the
  # client has not sent an event prior to being passed in here. This should
  # be most cases
  @libhoney.instance_variable_set(:@user_agent_addition,
                                  Honeycomb::Beeline::USER_AGENT_SUFFIX)
  @libhoney.add_field "meta.beeline_version", Honeycomb::Beeline::VERSION
  @libhoney.add_field "meta.local_hostname", configuration.host_name

  integrations = Honeycomb.integrations_to_load
  @libhoney.add_field "meta.instrumentations_count", integrations.count
  @libhoney.add_field "meta.instrumentations", integrations.map(&:to_s).to_s

  # maybe make `service_name` a required parameter
  @libhoney.add_field "service_name", configuration.service_name
  @libhoney.add_field "service.name", configuration.service_name
  @context = Context.new

  @context.classic = configuration.classic?

  @additional_trace_options = {
    presend_hook: configuration.presend_hook,
    sample_hook: configuration.sample_hook,
    parser_hook: configuration.http_trace_parser_hook,
    propagation_hook: configuration.http_trace_propagation_hook,
  }
  @error_backtrace_limit = configuration.error_backtrace_limit.to_i

  configuration.after_initialize(self)

  at_exit do
    libhoney.close
  end
end