Remove ForemStatsDriver abstraction (#16835)
* Remove ForemStatsDriver abstraction * Remove stats.rb
This commit is contained in:
parent
db57c4ad68
commit
63b5c9102d
5 changed files with 36 additions and 79 deletions
|
|
@ -1,15 +0,0 @@
|
|||
module ActsAsForemStatsDriver
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def setup_driver
|
||||
define_method(:initialize) do
|
||||
@driver = yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
delegate :count, :increment, :time, :gauge, to: :@driver
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
class ForemStatsDriver
|
||||
def initialize(*_args)
|
||||
@driver = select_driver.new
|
||||
end
|
||||
|
||||
delegate(:count, :increment, :time, :gauge, to: :@driver)
|
||||
|
||||
private
|
||||
|
||||
def select_driver
|
||||
# Currently, this only supports the default Datadog driver.
|
||||
# Logic will be added here for selecting the correct driver based on
|
||||
# the existence of configuration files for the desired stats recipient.
|
||||
ForemStatsDrivers::DatadogDriver
|
||||
end
|
||||
end
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
require "httpclient"
|
||||
require "rest-client"
|
||||
|
||||
module ForemStatsDrivers
|
||||
class DatadogDriver
|
||||
include ActsAsForemStatsDriver
|
||||
|
||||
setup_driver do
|
||||
Datadog.configure do |c|
|
||||
c.tracer env: Rails.env
|
||||
c.tracer enabled: ENV["DD_API_KEY"].present?
|
||||
c.tracer partial_flush: true
|
||||
c.tracer priority_sampling: true
|
||||
|
||||
c.use :concurrent_ruby
|
||||
c.use :excon, split_by_domain: true
|
||||
c.use :faraday, split_by_domain: true
|
||||
c.use :http, split_by_domain: false
|
||||
c.use :httpclient, split_by_domain: false
|
||||
c.use :httprb, split_by_domain: true
|
||||
c.use :rails
|
||||
|
||||
c.use :rest_client
|
||||
c.use :sidekiq
|
||||
|
||||
# Multiple Redis integrations to split Redis usage per-instance to
|
||||
# accommodate having a different Redis instance for each use case.
|
||||
|
||||
c.use :redis, service_name: "redis-rpush", describes: { url: ENV["REDIS_RPUSH_URL"] }
|
||||
c.use :redis, service_name: "redis-sessions", describes: { url: ENV["REDIS_SESSIONS_URL"] }
|
||||
|
||||
# Sidekiq jobs that spin up thousands of other jobs end up consuming a
|
||||
# *lot* of memory on instrumentation alone. This env var allows us to
|
||||
# enable it only when needed.
|
||||
if ENV["DD_ENABLE_REDIS_SIDEKIQ"] == "true"
|
||||
c.use :redis, service_name: "redis-sidekiq", describes: { url: ENV["REDIS_SIDEKIQ_URL"] }
|
||||
end
|
||||
|
||||
# Generic REDIS_URL comes last, allowing it to overwrite any of the
|
||||
# above when multiple Redis use cases are backed by the same Redis URL.
|
||||
c.use :redis, service_name: "redis", describes: { url: ENV["REDIS_URL"] }
|
||||
end
|
||||
|
||||
Datadog::Statsd.new
|
||||
end
|
||||
end
|
||||
end
|
||||
36
config/initializers/datadog.rb
Normal file
36
config/initializers/datadog.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Datadog.configure do |c|
|
||||
c.tracer env: Rails.env
|
||||
c.tracer enabled: ENV["DD_API_KEY"].present?
|
||||
c.tracer partial_flush: true
|
||||
c.tracer priority_sampling: true
|
||||
|
||||
c.use :concurrent_ruby
|
||||
c.use :excon, split_by_domain: true
|
||||
c.use :faraday, split_by_domain: true
|
||||
c.use :http, split_by_domain: false
|
||||
c.use :httpclient, split_by_domain: false
|
||||
c.use :httprb, split_by_domain: true
|
||||
c.use :rails
|
||||
|
||||
c.use :rest_client
|
||||
c.use :sidekiq
|
||||
|
||||
# Multiple Redis integrations to split Redis usage per-instance to
|
||||
# accommodate having a different Redis instance for each use case.
|
||||
|
||||
c.use :redis, service_name: "redis-rpush", describes: { url: ENV["REDIS_RPUSH_URL"] }
|
||||
c.use :redis, service_name: "redis-sessions", describes: { url: ENV["REDIS_SESSIONS_URL"] }
|
||||
|
||||
# Sidekiq jobs that spin up thousands of other jobs end up consuming a
|
||||
# *lot* of memory on instrumentation alone. This env var allows us to
|
||||
# enable it only when needed.
|
||||
if ENV["DD_ENABLE_REDIS_SIDEKIQ"] == "true"
|
||||
c.use :redis, service_name: "redis-sidekiq", describes: { url: ENV["REDIS_SIDEKIQ_URL"] }
|
||||
end
|
||||
|
||||
# Generic REDIS_URL comes last, allowing it to overwrite any of the
|
||||
# above when multiple Redis use cases are backed by the same Redis URL.
|
||||
c.use :redis, service_name: "redis", describes: { url: ENV["REDIS_URL"] }
|
||||
end
|
||||
|
||||
ForemStatsClient = Datadog::Statsd.new
|
||||
|
|
@ -1 +0,0 @@
|
|||
ForemStatsClient = ForemStatsDriver.new
|
||||
Loading…
Add table
Reference in a new issue