-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from nyaruka/cwatch_utils
Add utils funcs for creating metrics data
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cwatch | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" | ||
) | ||
|
||
// Some utility functions because the standard API is annoyingly verbose | ||
|
||
func Dimension(name, value string) types.Dimension { | ||
return types.Dimension{Name: aws.String(name), Value: aws.String(value)} | ||
} | ||
|
||
func Datum(metric string, value float64, unit types.StandardUnit, dims ...types.Dimension) types.MetricDatum { | ||
return types.MetricDatum{ | ||
MetricName: aws.String(metric), | ||
Dimensions: dims, | ||
Value: aws.Float64(value), | ||
Unit: unit, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters