Skip to content
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

Schneems/rack compat #18

Closed
wants to merge 31 commits into from
Closed

Conversation

schneems
Copy link

No description provided.

apghero and others added 30 commits August 10, 2017 10:21
In most cases the metrics being collected are not actually timings,
but instead are counters. There are, however, some things that *are*
actually "timers" which we need to address in a future commit.

For now, we still submit the counters, as timers, to statsd to
maintain the statsd aggregation facilities that are useful for per
request stat tracking.

(Tests are probably failing after this commit)
RackReporter reports only counters (as timers), which are useful in a
per request context (e.g. how many minor collections are happening per
request), using sampling strategies.

However, data for the entire process, which previously was reported as
Rack::Server should not be sampled. Instead, the PeriodicReporter
reports to statsd as counts and gauges, providing a more accurate look
at the server's characteristics over time.

The intention of PeriodicReporter is to be used by a clock that
measures, and then reports on an interval corresponding to the statsd
flushInterval (by default something like 10 seconds). A clock is
not included in this commit. Stay tuned.
Periodic collects metrics and reports them to reporter on an interval,
rather than on a per request basis (such as the Rack class). To avoid
large rearchitecting, it mimics that of the Rack Middleware by
conforming to the environment passing model of the reporter and
metrics storage, using *it's* thread local storage for that of
persisted last values of counters to track changes.

In addition, we add a RailTie, specifically for the enabling and
starting the periodic reporter.
- ReporterTest ensures that report implementations do nothing
- Move ReporterTest -> RackReporterTest
- Add PeriodicReporterTest which tests sample rates implementation.
Provide a test helper for Statsd which yields after a call to
`:block`. This provides a basis for mocking out the `:count` and
`gauge` methods.
For reasons of Linux, and, related to Puma things, this SYN_RECV
counter isn't an effective tool for measuring anything meaningful.
The Linux kernel actually has two queues, and the queue that is
important to measure ... can't be. So, this SYN_RECV counter is
really measuring the number of client initiated connections that
haven't completed the 3-way TCP handshake (e.g. haven't ACK'd),
and that's a typical thing of a malicious actor, or very slow
internet connection (but something we'd unlikely catch at a 20
second polling).

There's an item in Puma (and possibly other ruby web servers,
called the "backlog", which represents the number of connections
waiting for a thread in the thread pool. This is likely a more
interesting measurement, but even more interesting is probably
the amount of time those connections sit idle waiting to be
picked up, which we can get from the Heroku router. Since we're
targetting Heroku with this, we'll simply dismiss this as being
useful and move on.
Rename trashed to barnes.
Remove any and all assumptions that things are request driven. It's
all periodic, all the time.

In addition, simplify the concept of a meter, into a panel which
contains instruments that can be `instrument!`'d. These `!`methods
modify passed in state and are essentially folded over to collect
the current values of the gauges and counters. The instruments
themselves emit the proper key, and in the case of counters that
we'd like to treat as special counters, they apply sampling. See
an explanation of that in doc.rb.

Fix up the Railtie such that we can actually configure this thing
a bit easier, and remove things we'll just plain not utilize, like
the ChangeInstrument and GaugeInstrument which weren't utilized
and confused things.
- prefer named args
- don't use `send` when possible to avoid
- Barnes.start now can be called by Rack for easy starting
- Railties uses Barnes.start
- Prefer aborting when there's an exception in the background thread
@schneems schneems closed this Oct 23, 2017
@schneems
Copy link
Author

Ugh, sorry.

@jeremy
Copy link
Member

jeremy commented Oct 24, 2017

🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants