For vector and range queries, the Prometheus HTTP API takes a timeout
parameter. Previously, we ignored this parameter. Now, we check to see
if the context passed to the query contains a deadline, and if so,
compare that to the current time to calculate an appropriate timeout for
query evaulation.
This causes the Prometheus provider to take a stop channel as an
argument, which allows us to stop the lister (which keeps the series list
up to date) in the unit tests.
This adds `verify-gofmt` and `gofmt` make targets for quick go-fmting.
It also adds a `verify` target which verifies `gofmt` and the runs the
unit tests.
Travis now runs `make verify` instead of just `make test` as the tests.
Several of the unit tests were out of date with the interface or type
definitions. Now that we're running CI, they need to be up to date
(they should have been anyway, but that's a different story).
This commit marks the phony targets in the Makefile as phony, following
good Makefile practices (for example, so we don't have have issues with
someone creating a file with a matching name in the future, etc).
This commit causes the `all` Makefile rule to trigger `build` instead
of `docker-build`. This allows people with convoluted setups that
involve `go build`-ing and `docker build`-ing on different machines (like
@directxman12) to not complain as much.
This commit adds a Makefile rule for installing the vendor directory.
Both the `build` and `docker-build` phony rules depend on the `vendor`
rule, which in turn depends on the `glide.lock` rule. This means that
any time the `glide.lock` file is updated, the vendor directory will be
re-installed.
The `build` Makefile target attempted to place the generated artifact in
`/build`, where it should have used a local directory instead. This
commit makes the directory configurable using the `OUT_DIR` argument,
and defaults it to ./_output
k8s.io/custom-metrics-boilerplate was "renamed" to
"github.com/directxman12/custom-metrics-boilerplate". This updates all
references to point to the correct location.
This commit instruments prometheus query times by prometheus endpoint,
allowing us to see how quickly prometheus answers the queries that
back the custom-metrics API endpoints.
The initial functionality works. There's still a number of TODOs to
clean up, and some edge cases to work around, and some errors that could
be handled better.