-
Notifications
You must be signed in to change notification settings - Fork 33
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
remove need for nil checks around statsd metrics #932
Conversation
7659ff5
to
25b0a27
Compare
25b0a27
to
a88ed97
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.
This is not a problem with this patch, but this makes me think that we might want to add some sort of check or safeguard that ensures we don't run without statsd in production (and perhaps staging?), which I can't imagine we would ever want to do...
We'd hopefully find out because our alerts would fire with a "not getting data" alarm. Def the next step is to make sure we have alerts in place using this data! |
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.
r+ for xpi/*
changes, thanks
Currently, we have to check if `autographer.stats` is nil anywhere we want to emit a statsd metric. This is error-prone and verbose. Work for AUT-150 (and more) would be easier if we do this here. This patch makes the `autographer.stats` field always non-nil. By default, `autographer`s created with `newAutographer` will have a `statsd.NoOpClient` object for its `stats` and if the autograph config has a statsd server configured, it will be replaced with a real statsd client when `autographer.addStats` is called. That addStats call will now always occur in autograph's main function. This moves the conditional for checking if the statsd server is configured into autographer.addStats. However, it would probably be better in the future for us to have this and the similar `autograph.add*` methods moved into the `newAutographer` contructor. This, though, at least makes the autographer type a lil safer on construction. This means that we use `statds.ClientInterface` instead of `*statsd.Client` everywhere to fit both client types. Along the way, we also have to fix up the main_test.go that was reproducing that conditional from the main inside it. We also fix an signer/xpi test that was depending on a statsd server running but not actually needing it to finish. This patch doesn't remove all of the nil checks. A follow up will be made to do so. Updates AUT-159 Updates AUT-150
934e070
to
4260381
Compare
Currently, we have to check if
autographer.stats
is nil anywhere wewant to emit a statsd metric. This is error-prone and verbose. Work for
AUT-150 (and more) would be easier if we do this here.
This patch makes the
autographer.stats
field always non-nil. Bydefault,
autographer
s created withnewAutographer
will have astatsd.NoOpClient
object for itsstats
and if the autograph confighas a statsd server configured, it will be replaced with a real statsd
client when
autographer.addStats
is called. That addStats call willnow always occur in autograph's main function.
This moves the conditional for checking if the statsd server is
configured into autographer.addStats. However, it would probably be
better in the future for us to have this and the similar
autograph.add*
methods moved into thenewAutographer
contructor.This, though, at least makes the autographer type a lil safer on
construction.
This means that we use
statds.ClientInterface
instead of*statsd.Client
everywhere to fit both client types.Along the way, we also have to fix up the main_test.go that was
reproducing that conditional from the main inside it. We also fix an
signer/xpi test that was depending on a statsd server running but not
actually needing it to finish.
This patch doesn't remove all of the nil checks. A follow up will be
made to do so.
Updates AUT-159
Updates AUT-150