Closed
Description
openedon Nov 20, 2019
👋 As of today, our project is configured as follows:
# config/initializers/datadog_tracer.rb
Datadog.configure do |c|
service_name = 'my-app'
c.tracer(
# ... some configuration
)
c.use :redis, service_name: "#{service_name}-redis", analytics_enabled: true
# some other services
end
Our service is interacting with three redis instances:
- one for external dependencies caching
- one for sessions
- one for sidekiq
(1) is quite volatile and can be flushed periodically
(2)(3) needs to be more persistent
Today all the metrics are reported to the same my-app-redis
APM.
I have tried to tweak the apm tags as follows
# Begin Redis APM patch
# https://github.com/DataDog/dd-trace-rb/blob/master/lib/ddtrace/contrib/redis/tags.rb#L10-L19
# https://github.com/DataDog/dd-trace-rb/blob/dfe97dbea117c987e53c22bf2a9cffc4707c9dfc/lib/ddtrace/contrib/redis/patcher.rb#L45-L52
module Datadog::Contrib::Redis::Tags
SERVICE_NAME_MAP = {
ENV['REDIS_CACHE_HOST'] => 'my-app-cache-redis',
ENV['REDIS_SESSIONS_HOST'] => 'my-app-sessions-redis',
ENV['REDIS_SIDEKIQ_HOST'] => 'my-app-sidekiq-redis'
}.freeze
class << self
def set_common_tags(client, span)
super(client, span)
span.service = SERVICE_NAME_MAP[client.host] || 'my-app-redis'
end
end
end
# End Redis APM patch
Unfortunately this approach did not work.
I was assuming that the client.host
was preserving the host passed to my application.
https://github.com/redis/redis-rb/blob/0559b503f9303e9716957bdbea2f731006d549b2/lib/redis/client.rb#L13
Do you have any native support for this feature? May you need help to develop it?
The expected outcome would be to set the configuration to:
# config/initializers/datadog_tracer.rb
Datadog.configure do |c|
c.use :redis, service_name: 'my-app-cache-redis', host: ENV['REDIS_CACHE_HOST']
c.use :redis, service_name: 'my-app-sessions-redis', host: ENV['REDIS_SESSIONS_HOST']
c.use :redis, service_name: 'my-app-sidekiq-redis', host: ENV['REDIS_SIDEKIQ_HOST']
end
Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment