Name: aws-sdk-go-counter
Owner: Clever
Description: Wrapper around aws-sdk-go that counts API requests made to AWS.
Forked from: aws/aws-sdk-go
Created: 2017-09-06 00:25:17.0
Updated: 2018-03-29 02:55:46.0
Pushed: 2018-02-21 16:52:56.0
Size: 50399
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Wrapper around aws-sdk-go that counts API requests made to AWS.
AWS APIs have rate limits, so monitoring the rate at which code is using different AWS APIs is useful.
Take normal aws-sdk-go client usage like this:
age main
rt (
"log"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
main() {
sess := session.New()
svc := s3.New(sess)
_, err := svc.ListBuckets(nil)
if err != nil {
log.Fatal(err)
}
and wrap it
age main
rt (
"fmt"
"log"
"github.com/Clever/aws-sdk-go-counter/counter/s3counter"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
main() {
sess := session.New()
svc := s3counter.New(s3.New(sess))
_, err := svc.ListBuckets(nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", svc.Counters())
Output:
ListBuckets:1]
You could also print the values periodically in the background e.g.
go func() {
ticker := time.NewTicker(10 * time.Second)
for _ = range ticker.C {
fmt.Printf("%v\n", svc.Counters())
}
}()
At Clever you could also route logs to metrics backends like SignalFX, e.g. https://github.com/Clever/workflow-manager/pull/87.
This repo uses a modified version of aws-sdk-go's codegen to produce the code in the counter/
directory.
Run make deps
+ make all
in the the counter
directory to generate the counters.