Skip to content

Commit

Permalink
Fix: add metric validation
Browse files Browse the repository at this point in the history
  • Loading branch information
junho100 committed Dec 22, 2024
1 parent aefae91 commit 18bb613
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/infrastructure/monitoring/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package monitoring

import (
"context"
"fmt"
"log"
"time"

Expand All @@ -27,6 +28,17 @@ func NewCloudWatchClient() (*CloudWatchClient, error) {
}

func (c *CloudWatchClient) PutMetric(namespace, metricName string, value float64, unit types.StandardUnit, dimensions []types.Dimension) error {
if len(dimensions) > 0 {
for _, dim := range dimensions {
if dim.Name == nil || *dim.Name == "" {
return fmt.Errorf("dimension name이 비어있습니다")
}
if dim.Value == nil || *dim.Value == "" {
return fmt.Errorf("dimension value가 비어있습니다")
}
}
}

now := time.Now()

input := &cloudwatch.PutMetricDataInput{
Expand Down

0 comments on commit 18bb613

Please sign in to comment.