docbrown/config/initializers/honeycomb.rb
Michael Kohl 33195929aa
Bump to Rails 7.0.2.2 MVP (#15908)
* Update gems

* Update more gems

* Update @rails/ujs package

* Explicitly add sprockets-rails

* Gemfile update

* Run bin/rails app:setup

* Update redis-actionpack

* Update stats initializer autoloading

* Update acts-as-taggable-on

* Disable signed: true option in session store

* Switch back to released version of redis-actionpack

* Update Gemfile.lock

* WIP

* Update Rails and gems

* Move hair_trigger back to released gem

* Add explicit requires to initializers

* Update Rails version

* Add more explicit require_relative calls

* Re-enable ForemStatsDriver

* Update schema

* Temp spec changes

* Bullet started raising errors?

* Fix broken spec

* Temporarily disable hair_trigger_spec

* Refactor

* Fix spec

* Enable use_rfc4122_namespaced_uuids

* Revert "Enable use_rfc4122_namespaced_uuids"

This reverts commit 5dac3722284bb08049586bfa943405f8a01289df.

* Temporarily deploy to canary

* Revert "Temporarily deploy to canary"

This reverts commit 04f8469501fab2a3177450baf051ff6259c41827.

* Update Containerfile

* Add comments to specs

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-03-30 15:00:33 -04:00

56 lines
1.8 KiB
Ruby

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