Arrange Datadog Redis integrations more usefully (#14185)

This commit solves two problems:

1. Redis cache usage is tracked under `redis-rpush` because they use the
   same Redis URL and `redis-rpush` overrides `redis`.
2. Sidekiq jobs can enqueue an unbounded number of other Sidekiq jobs.
   The instrumentation cost alone of enqueuing hundreds of thousands of
   other Sidekiq jobs can be prohibitive, similar to DEBUG-level
   logging. This commit wraps it in a conditional so it must be enabled
   explicitly and can be turned on and off at will without a code
   change.
This commit is contained in:
Jamie Gaskins 2021-07-09 15:19:37 -04:00 committed by GitHub
parent 6f2c2eb750
commit c591ec811d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,12 +19,26 @@ module ForemStatsDrivers
c.use :httpclient, split_by_domain: false
c.use :httprb, split_by_domain: true
c.use :rails
c.use :redis, service_name: "redis", describes: { url: ENV["REDIS_URL"] }
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"] }
c.use :redis, service_name: "redis-sidekiq", describes: { url: ENV["REDIS_SIDEKIQ_URL"] }
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