-
Notifications
You must be signed in to change notification settings - Fork 140
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
Consider a PR for .current
similar to Redis
#25
Comments
Thank @harlow Could you give us more details about the use cases please ? I am not sure to understand how it would help you. -- Yann |
hi @yannmh we use # config/initializers/statsd.rb
tags: {
# env, service name, revision, etc
}
Statsd.current = Statsd.new(url, port, tags) # app/models/foo.rb
class Foo
def bar
if some_success_case?
statsd.increment('xyz')
end
end
private
def statsd
Statsd.current
end
end This was we have access to the configured |
Seems like a nice feature, thanks for the further explanations @harlow ! |
@harlow the easiest way we've found to do this is set a global variable for use across your application: # config/initializers/statsd.rb
$statsd = Datadog::Statsd.new(...) # app/models/foo.rb
class Foo
def bar
if some_success_case?
$statsd.increment('xyz')
end
end
end |
Is using a global variable compatible with the v5 requirement of needing to call I'm trying to upgrade an app that used a similar pattern, but I want to use buffer_flush_interval and not send stats live for each invocation of Thoughts? |
You could perhaps use |
Yep, that's more or less what I figured out over here (then ran into a different issue): #265 (comment) |
Ah, I totally missed the other ticket 😰 |
…-update feat(epic.md): Soften people plan to convey section purpose
We have a number of tags that we instantiate Statsd with. With
Redis.current
we do something similar:https://github.com/redis/redis-rb/blob/b9ac235fa03de173d1d382878757850afae94bc3/lib/redis.rb#L19-L25
Would DataDog team consider a PR that does same for Statsd?
The text was updated successfully, but these errors were encountered: