-
Notifications
You must be signed in to change notification settings - Fork 116
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
Rework StatsD usage to use separate client #594
Conversation
2eef167
to
0dfcd49
Compare
Updated this PR. The client that gets instantiated should now reflect the legacy client we would instantiate before. One change is that I changed |
d248eac
to
fa94478
Compare
lib/kubernetes-deploy/deploy_task.rb
Outdated
"Successfully deployed all #{@namespace} resources to #{@context}", | ||
alert_type: "success", tags: statsd_tags << "status:success") | ||
StatsD.distribution('all_resources.duration', StatsD.duration(start), tags: statsd_tags << "status:success") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was a (minor) bug. <<
modifies the array, and then returns it. This means that every time it is called, the array grows by one element. In this case, we add the same tag twice, which doesn't really cause any issues in practice, but I figured I should fix this while I am at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm the best person to review this but looks reasonable. Can you please add an entry in the change log as well.
8b01444
to
f37e8d5
Compare
I added a changelog entry, but I still have to fix a compatibility issue in the test helpers in statsd-instrument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Edit: sorry just saw the failing tests. Will rereview once those are fixed
lib/kubernetes-deploy/statsd.rb
Outdated
self.backend = ::StatsD::Instrument::Backends::NullBackend.new | ||
def self.client | ||
@client ||= begin | ||
sink = if ::StatsD::Instrument::Environment.current.env.fetch('STATSD_ENV', nil) == 'development' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems as though the ::StatsD::Instrument::Environment.current.env
is just a basic wrapper around ENV
, in this case. The other fallbacks appear to be geared more towards Rails applications, of which krane isn't one. With that in mind, it might be cleaner just to do if ENV.fetch(X, nil) == Y
, instead.
Shopify/statsd-instrument#234 fixes the issue that causes us not being able to parse and assert stuff on the |
author Willem van Bergen <willem@vanbergen.org> 1571413339 -0400 committer Daniel Turner <daniel.turner@shopify.com> 1573059976 -0800 Rework StatsD usage to use separate client Update StatsD client initialization to resemble how we instantiated a client before. Add CHANGELOG entry.
f37e8d5
to
0e1605f
Compare
7df9ed6
to
b5eefbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-Authored-By: Timothy Smith <31742287+timothysmith0609@users.noreply.github.com>
What are you trying to accomplish with this PR?
Get rid of the StatsD monkeypatches that cause us to be stuck on a specific version of statsd-instrument.
How is this accomplished?
By instantiating a separate
StatsD::Instrument::Client
, there is no need to override the singleton anymore.What could go wrong?
Metrics may be broken after this change, although the test suite suggests otherwise.