AWS Lambda is tightly integrated with other AWS services and provides excellent opportunities for improving your service’s observability posture. Sparta includes a CloudWatch Metrics publisher that periodically publishes metrics to CloudWatch.
This periodic task publishes environment-level metrics that have been detected by the gopsutil package. Metrics include:
You can provide an optional map[string]string
set of dimensions to which the metrics
should be published. This enables targeted alert conditions
that can be used to improve system resiliency.
To register the metric publisher, call the RegisterLambdaUtilizationMetricPublisher
at some
point in your main()
call graph. For example:
import spartaCloudWatch "github.com/mweagle/Sparta/v3/aws/cloudwatch"
func main() {
...
spartaCloudWatch.RegisterLambdaUtilizationMetricPublisher(map[string]string{
"BuildId": sparta.StampedBuildID,
})
...
}
The optional map[string]string
parameter is the custom Name-Value pairs to use as a CloudWatch Dimension