Skip to content

metric: added calculator and handlers for requests / messages per runner

Compare
Choose a tag to compare
@j4k4 j4k4 released this 22 Aug 14:46
· 19 commits to main since this release

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

  • metric: added calculator and handlers for requests / messages per runner by @j4k4 in #1142

Full Changelog: v0.21.6...v0.22.0