Skip to content

Commit

Permalink
feat: add metrics for sqs api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Mar 16, 2024
1 parent 124f217 commit 476c42a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/sqs_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/soerenschneider/dyndns/conf"
"github.com/soerenschneider/dyndns/internal/common"
"github.com/soerenschneider/dyndns/internal/metrics"
)

type SqsDispatch struct {
Expand Down Expand Up @@ -43,6 +44,7 @@ func (h *SqsDispatch) Notify(msg *common.UpdateRecordRequest) error {

// TODO: change interface signature
ctx := context.Background()
metrics.SqsApiCalls.WithLabelValues("send_message").Inc()
result, err := h.client.SendMessageWithContext(ctx, &sqs.SendMessageInput{
MessageBody: aws.String(string(data)),
QueueUrl: aws.String(h.queueUrl),
Expand Down
7 changes: 7 additions & 0 deletions internal/metrics/metrics_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ var (
Namespace: namespace,
Name: "notification_errors",
})

SqsApiCalls = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "sqs",
Help: "The total amount of SQS API calls",
Name: "api_calls_total",
}, []string{"operation"})
)

func StartMetricsServer(addr string) {
Expand Down

0 comments on commit 476c42a

Please sign in to comment.