Class: Honeycomb::Configuration
Overview
Used to configure the Honeycomb client
Instance Attribute Summary collapse
#notification_events
Instance Method Summary
collapse
#active_support_handlers, #default_handler, #handle_notification_event, #on_notification_event
Constructor Details
Returns a new instance of Configuration.
17
18
19
20
21
22
23
24
|
# File 'lib/honeycomb/configuration.rb', line 17
def initialize
@write_key = ENV["HONEYCOMB_WRITEKEY"]
@dataset = ENV["HONEYCOMB_DATASET"]
@service_name = ENV["HONEYCOMB_SERVICE"]
@debug = ENV.key?("HONEYCOMB_DEBUG")
@error_backtrace_limit = 0
@client = nil
end
|
Instance Attribute Details
#api_host ⇒ Object
Returns the value of attribute api_host.
10
11
12
|
# File 'lib/honeycomb/configuration.rb', line 10
def api_host
@api_host
end
|
#client ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/honeycomb/configuration.rb', line 57
def client
@client ||=
if debug
Libhoney::LogClient.new
else
validate_options
Libhoney::Client.new(**libhoney_client_options)
end
end
|
#dataset ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/honeycomb/configuration.rb', line 37
def dataset
return @dataset if classic?
return "unknown_service" if service_name.nil?
stripped_service_name = service_name.strip
warn("found extra whitespace in service name") if stripped_service_name != service_name
if stripped_service_name.empty? || stripped_service_name.start_with?("unknown_service")
"unknown_service"
else
stripped_service_name
end
end
|
#debug ⇒ Object
Returns the value of attribute debug.
10
11
12
|
# File 'lib/honeycomb/configuration.rb', line 10
def debug
@debug
end
|
#error_backtrace_limit ⇒ Object
Returns the value of attribute error_backtrace_limit.
15
16
17
|
# File 'lib/honeycomb/configuration.rb', line 15
def error_backtrace_limit
@error_backtrace_limit
end
|
#host_name ⇒ Object
74
75
76
77
|
# File 'lib/honeycomb/configuration.rb', line 74
def host_name
@host_name || ENV["DYNO"] || Socket.gethostname
end
|
#service_name ⇒ Object
30
31
32
33
34
35
|
# File 'lib/honeycomb/configuration.rb', line 30
def service_name
return @service_name if service_name_given?
return @dataset if classic?
"unknown_service:" + $PROGRAM_NAME.split("/").last
end
|
#write_key ⇒ Object
Returns the value of attribute write_key.
10
11
12
|
# File 'lib/honeycomb/configuration.rb', line 10
def write_key
@write_key
end
|
Instance Method Details
#after_initialize(client) ⇒ Object
70
71
72
|
# File 'lib/honeycomb/configuration.rb', line 70
def after_initialize(client)
super(client) if defined?(super)
end
|
#classic? ⇒ Boolean
26
27
28
|
# File 'lib/honeycomb/configuration.rb', line 26
def classic?
Libhoney.classic_api_key?(@write_key)
end
|
#http_trace_parser_hook(&hook) ⇒ Object
#http_trace_propagation_hook(&hook) ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/honeycomb/configuration.rb', line 108
def http_trace_propagation_hook(&hook)
if block_given?
@http_trace_propagation_hook = hook
elsif @http_trace_propagation_hook
@http_trace_propagation_hook
elsif classic?
HoneycombPropagation::MarshalTraceContext.method(:parse_faraday_env)
else
HoneycombModernPropagation::MarshalTraceContext.method(:parse_faraday_env)
end
end
|
#presend_hook(&hook) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/honeycomb/configuration.rb', line 79
def presend_hook(&hook)
if block_given?
@presend_hook = hook
else
@presend_hook
end
end
|
#sample_hook(&hook) ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/honeycomb/configuration.rb', line 87
def sample_hook(&hook)
if block_given?
@sample_hook = hook
else
@sample_hook
end
end
|