zapier / prom-aggregation-gateway

An aggregating push gateway for Prometheus
Mozilla Public License 2.0
116 stars 26 forks source link

Add aggregate options #32

Closed mplachter closed 1 year ago

mplachter commented 1 year ago

This MR adds the ability to add aggregate options, one of which is to ignore labels.

Benchmark Before

pkg: prom-aggregation-gateway
BenchmarkConcurrentAggregate/metric_type_simpleGauge-10                   152410             77365 ns/op           87347 B/op       1313 allocs/op
BenchmarkConcurrentAggregate/metric_type_fullMetrics-10                    84994            140624 ns/op          194174 B/op       3773 allocs/op
BenchmarkConcurrentAggregate/metric_type_multiLabel-10                    216140             47299 ns/op           62705 B/op        593 allocs/op
BenchmarkConcurrentAggregate/metric_type_labelFields-10                   257414             47539 ns/op           61830 B/op        553 allocs/op
BenchmarkConcurrentAggregate/metric_type_reorderedLabels-10               257733             45932 ns/op           62706 B/op        593 allocs/op
done
PASS
ok      prom-aggregation-gateway        62.053s

Two new tests were added as well multiLabelIgnore and ignoredLabels

Benchmark After

pkg: prom-aggregation-gateway
BenchmarkConcurrentAggregate/metric_type_simpleGauge-10                   160633             76634 ns/op           87347 B/op       1313 allocs/op
BenchmarkConcurrentAggregate/metric_type_fullMetrics-10                    85020            141702 ns/op          194174 B/op       3773 allocs/op
BenchmarkConcurrentAggregate/metric_type_multiLabel-10                    228883             51287 ns/op           64626 B/op        673 allocs/op
BenchmarkConcurrentAggregate/metric_type_multiLabelIgnore-10              236571             50984 ns/op           65026 B/op        703 allocs/op
BenchmarkConcurrentAggregate/metric_type_labelFields-10                   229822             49480 ns/op           61830 B/op        553 allocs/op
BenchmarkConcurrentAggregate/metric_type_reorderedLabels-10               247396             48567 ns/op           63026 B/op        603 allocs/op
BenchmarkConcurrentAggregate/metric_type_ignoredLabels-10                 247699             48915 ns/op           64866 B/op        703 allocs/op
PASS
ok      prom-aggregation-gateway        88.855s

There is a small performance hit, but there are optimization techniques still on the table to improve performance when ignoring labels.