Skip to content

Commit 02616ea

Browse files
authored
Update README.md
1 parent 22c163c commit 02616ea

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

README.md

+33-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
Go implementation of AWS CloudWatch [Embedded Metric Format](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html)
77

88
It's aim is to simplify reporting metrics to CloudWatch:
9-
- using EMF avoids additional HTTP calls as it just logs JSON to stdout
10-
- built in support for Lambda functions default dimensions and properties (happy to accept PR for EC2 support)
11-
- no need for defining additional dependencies (or mocks in tests) to report metrics from inside your code
9+
- using EMF avoids additional HTTP API calls to CloudWatch as metrics are logged in JSON format to stdout
10+
- no need for additional dependencies in your services (or mocks in tests) to report metrics from inside your code
11+
- built in support for default dimensions and properties for Lambda functions
12+
- TODO support for default dimensions and properties for EC2 (please send pull requests)
1213

13-
Examples:
14+
Supports namespaces, setting dimensions and properties as well as different contexts (at least partially).
15+
16+
Usage:
1417
```
1518
emf.New().Namespace("mtg").Metric("totalWins", 1500).Log()
1619
@@ -21,3 +24,29 @@ emf.New().DimensionSet(emf.NewDimension("format", "edh"), emf.NewDimension("comm
2124
MetricAs("wins", 1499, emf.Count).Log()
2225
```
2326

27+
You may also use the lib together with `defer`.
28+
```
29+
m := emf.New() // or some more complicated init setting up whatever you fancy
30+
defer m.Log()
31+
32+
// any reporting metrics calls here
33+
```
34+
35+
Functions for reporting metrics:
36+
```
37+
func Metric(name string, value int)
38+
func Metrics(m map[string]int)
39+
func MetricAs(name string, value int, unit MetricUnit)
40+
func MetricsAs(m map[string]int, unit MetricUnit)
41+
42+
func MetricFloat(name string, value float64)
43+
func MetricsFloat(m map[string]float64)
44+
func MetricFloatAs(name string, value float64, unit MetricUnit)
45+
func MetricsFloatAs(m map[string]float64, unit MetricUnit)
46+
```
47+
48+
Functions for setting up dimensions:
49+
```
50+
func Dimension(key, value string)
51+
func DimensionSet(dimensions ...Dimension) // use `func NewDimension` for creating one
52+
```

0 commit comments

Comments
 (0)