metric: added calculator and handlers for requests / messages per runner
This release introduces a more powerful version of the "messages per runner" metric from the stream package.
The MPR metric was produced by a kernel module and used to perform auto scaling for SQS consumers.
The whole functionality was implemented and limited to the stream package.\
The feature of doing metric calculations via a kernel module was moved to the metric/calculator
package which implements a more generic approach to this. To achieve this, the calculator calls a set of provided handlers periodically. The handlers are returning the calculated metrics which should be published:
type Handler interface {
GetMetrics(ctx context.Context) (metric.Data, error)
}
By default there are two registered handlers. The stream_messages_per_runner
which is the replacement for the old MPR metric and the httpserver_requests_per_runner
handler from the httpserver package which calculates the count of requests served by one instance of the server.
Once enabled via metric.calculator.enabled: true
the default settings will look similar to:
metric:
calculator:
cloudwatch:
client: "default"
dynamodb:
naming:
pattern: '{env}-{modelId}'
ecs:
cluster: '{env}'
service: '{app_group}-{app_name}'
enabled: true
handlers:
httpserver_requests_per_runner:
enabled: true
max_increase_percent: 200
max_increase_period: 5m0s
period: 1m0s
target_value: 100
stream_messages_per_runner:
enabled: true
max_increase_percent: 200
max_increase_period: 5m0s
period: 1m0s
target_value: 100
leader_election: metric_calculator
period: 1m0s
What's Changed
Full Changelog: v0.21.6...v0.22.0