Instead of iterating a map of enabled collectors, iterate a sorted
slice to achieve determinism across scrapes.
Having a consistent order in the metrics output enables Proemetheus to
apply optimizations during metric parsing and ingestion.
Reenable feature to filter the exposition of metric families by their
name. This is now done at startup time, thereby not slowing down the
critical path.
Dependent on the environment users might or might not want to encode the
responses of kube-state-metrics via gzip independent of the
`Accept-Header` that the client (Prometheus) sends.
This patch introduces a custom client go store, MetricsStore. It is
updated by a corresponding reflector. Instead of generating the
Prometheus custom metrics on demand, metrics are generated on new
Kubernetes object arrival.
In addition this patch replaces most of the logic of the Prometheus
client_golang package by its optimized custom logic to render metrics in
text format.
Next to these main changes this patch also includes:
- Documentation/design: Add performance optimization proposal
- tests/e2e.sh: Ignore "no help text" warnings by promtool
- .travis.yml: Run tests in parallel
As non of the Travis tests depend on each other, there is no reason to
run them in sequence. Instead this patch makes them run in parallel.
This patch adds a simple go benchmark test, injecting Kubernetes objects
and simulating scrape requests. It uses the Kubernetes client-go fake
client. Alongside comes some refactoring of each collectors structure
using informer factories to be compatible with the fake client.
The patch lays the groundwork to make future performance optimizations
comparable with past versions.
How to run test:
`go test -race -bench . -memprofile=mem.out -cpuprofile=cpu.out`
This commit reworks node metrics in the same manner as deployment
metrics.
The node states are broken out into one time series for each possible
conditional state. One constant metric holds textual meta information
about cluster nodes.
* Rework container restart metric
This commit reworks the container restart metric in the same manner as
deployment metrics. The format remains unchanged to the previous format
as in one metric per container via labels.
* Normalize expected string representation
To be able to compare strings easier when a failure occurs, remove empty
lines and trim whitespace for each line of the expected metrics string.
* Update prometheus client vendoring
* Rework deployment metrics
This change extracts the deployment metrics into their own
deployment collector. The metrics are collected synchronously with
each scrape rather than every 10 seconds.
The `deployment` label replaces the `name` label to avoid name
collisions further up in the monitoring chain.