-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APM redis reporting by host #861
Comments
We actually do have support for instrumentation per Redis instance as described in our documentation. redis_cache = Redis.new
redis_sessions = Redis.new
redis_sidekiq = Redis.new
Datadog.configure(redis_cache, service_name: 'my-app-cache-redis')
Datadog.configure(redis_sessions, service_name: 'my-app-sessions-redis')
Datadog.configure(redis_sidekiq, service_name: 'my-app-sidekiq-redis')
# Traced call will belong to `'my-app-cache-redis` service
redis_cache.get(...)
# Traced call will belong to `my-app-sessions-redis` service
redis_sessions.get(...) So if you can get a handle on those instances of Redis, you should be able to configure settings per Redis service. Let me know if that works for you. |
@delner thank you very much! I've missed this section of the documentation 🤦♂️ |
@delner thank you again! I had some edge cases:
# config/environments/production.rb
Rails.application.configure do
# some config
config.cache_store = :redis_cache_store, { url: "redis://#{ENV.fetch('REDIS_CACHE_HOST')}:6379" }
if Datadog.tracer.enabled
Datadog.configure(Rails.cache.redis, service_name: 'my-app-cache-redis')
end
end
Which returns a
Would you suggest to patch the method |
Hmmmm gotcha. I remember seeing this with Sidekiq before and its a bit tricky. I think you could patch this pool explicitly, and it would likely serve the function you're looking for. Eventually this could become a function of the Sidekiq integration, where it auto-instruments this Sidekiq Redis connection pool with our Redis integration, and exposes a configuration option via e.g. Datadog.configure do |c|
c.use :redis, service_name: 'my-app-cache-redis' # Acts as catch-all
c.use :sidekiq do |sidekiq|
sidekiq.redis service_name: "my-app-sidekiq-redis" # Acts as override
end
end Alternatively, we could introduce "multiplexing" as we did for ActiveRecord, where you could configure Redis tracing by URL, which might be a bit simpler to implement given you won't have to locate and configure every instance of For the end user, configuring this could look like: Datadog.configure do |c|
c.use :redis, describes: "redis://#{ENV.fetch('REDIS_CACHE_HOST')}:6379", service_name: 'my-app-cache-redis'
c.use :redis, describes: "redis://#{ENV.fetch('REDIS_SIDEKIQ_HOST')}:6379", service_name: 'my-app-sidekiq-redis'
end I think the latter might be a bit simpler to implement and use. |
Hey @delner I am having a look at the gem code base and I am wondering if the
I did not find any explicit reference into the different libraries. When I tested however on our repo (0.32.0) it did not work.. Do you have any hint on how to implement the solutions you suggested in the previous comment ? I would be happy to contribute and make the pr by myself. |
Could it be related to the fact that the hostname provided in the |
Ah, yeah, the The short explanation is each integration has a In the All integrations use a resolver to store configuration, but only some (e.g. ActiveRecord, Dalli) actually try to resolve a key from trace data like hostname or URLs to access configuration settings other than the default; the rest always use the default configuration. In this case for Sidekiq, it's using the default resolver, so when you provide Hopefully that makes sense... maybe we could add this kind of instrumentation to our developer documentation for the benefit of future contributors. |
Done in #937 |
👋 As of today, our project is configured as follows:
Our service is interacting with three redis instances:
(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
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:
Thanks!
The text was updated successfully, but these errors were encountered: