lib/honeycomb/configuration.rb in honeycomb-beeline-2.8.0 vs lib/honeycomb/configuration.rb in honeycomb-beeline-2.8.1
- old
+ new
@@ -30,19 +30,19 @@
def error_backtrace_limit=(val)
@error_backtrace_limit = Integer(val)
end
def client
- options = {}.tap do |o|
- o[:writekey] = write_key
- o[:dataset] = dataset
- api_host && o[:api_host] = api_host
- end
-
- @client ||
- (debug && Libhoney::LogClient.new) ||
- Libhoney::Client.new(**options)
+ # memoized:
+ # either the user has supplied a pre-configured Libhoney client
+ @client ||=
+ # or we'll create one and return it from here on
+ if debug
+ Libhoney::LogClient.new
+ else
+ Libhoney::Client.new(**libhoney_client_options)
+ end
end
def after_initialize(client)
super(client) if defined?(super)
end
@@ -85,9 +85,22 @@
elsif @http_trace_propagation_hook
@http_trace_propagation_hook
else
# by default we send outgoing honeycomb trace headers
HoneycombPropagation::MarshalTraceContext.method(:parse_faraday_env)
+ end
+ end
+
+ private
+
+ def libhoney_client_options
+ {
+ writekey: write_key,
+ dataset: dataset,
+ user_agent_addition: Honeycomb::Beeline::USER_AGENT_SUFFIX,
+ }.tap do |options|
+ # only set the API host for the client if one has been given
+ options[:api_host] = api_host if api_host
end
end
end
end