-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathhoneycomb.rb
56 lines (49 loc) · 1.83 KB
/
honeycomb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
52
53
54
55
56
require_relative "../../app/lib/honeycomb/noise_cancelling_sampler"
if Rails.env.test?
Honeycomb.configure do |config|
config.client = Libhoney::TestClient.new
end
else
honeycomb_api_key = ApplicationConfig["HONEYCOMB_API_KEY"]
release_footprint = ApplicationConfig["RELEASE_FOOTPRINT"]
# Honeycomb automatic Rails integration
notification_events = %w[
cache_read.active_support
cache_read_multi.active_support
sql.active_record
render_template.action_view
render_partial.action_view
render_collection.action_view
process_action.action_controller
send_file.action_controller
send_data.action_controller
deliver.action_mailer
].freeze
Honeycomb.configure do |config|
config.write_key = honeycomb_api_key.presence
# libhoney client will automatically fall back to using a null transmission
# when no write key is provided, but it will log a warning (visible in a few places)
# explicitly override the client to disable the warning
config.client = Libhoney::NullClient.new unless config.write_key
if ENV["HONEYCOMB_DISABLE_AUTOCONFIGURE"]
config.dataset = "background-work"
else
config.dataset = "rails"
config.notification_events = notification_events
# Scrub unused data to save space in Honeycomb
config.presend_hook do |fields|
fields["global.build_id"] = release_footprint
if fields.key?("redis.command")
fields["redis.command"] = fields["redis.command"].slice(0, 300)
elsif fields.key?("sql.active_record.binds")
fields.delete("sql.active_record.binds")
fields.delete("sql.active_record.datadog_span")
end
end
# Sample away highly redundant events
config.sample_hook do |fields|
Honeycomb::NoiseCancellingSampler.sample(fields)
end
end
end
end