Skip to content

Commit 7178c5f

Browse files
committed
Release 1.0.0
1 parent 6fe063a commit 7178c5f

File tree

15 files changed

+58
-25
lines changed

15 files changed

+58
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
- Add items here as needed.
10+
11+
## [1.0.0] - 2017-07-26
12+
913
- Make project public on GitHub.

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Metrics Library for Go
22

3-
[![Travis](https://img.shields.io/travis/istreamlabs/go-metrics.svg)](https://travis-ci.org/istreamlabs/go-metrics) [![Codecov](https://img.shields.io/codecov/c/github/istreamlabs/go-metrics.svg)](https://codecov.io/gh/istreamlabs/go-metrics) [![GitHub tag](https://img.shields.io/github/tag/istreamlabs/go-metrics.svg)](https://github.com/istreamlabs/go-metrics/releases) [![License](https://img.shields.io/github/license/istreamlabs/go-metrics.svg)](https://github.com/istreamlabs/go-metrics/blob/master/LICENSE)
3+
[![Travis](https://img.shields.io/travis/istreamlabs/go-metrics.svg)](https://travis-ci.org/istreamlabs/go-metrics) [![Codecov](https://img.shields.io/codecov/c/github/istreamlabs/go-metrics.svg)](https://codecov.io/gh/istreamlabs/go-metrics) [![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/istreamlabs/go-metrics/metrics) [![GitHub tag](https://img.shields.io/github/tag/istreamlabs/go-metrics.svg)](https://github.com/istreamlabs/go-metrics/releases) [![License](https://img.shields.io/github/license/istreamlabs/go-metrics.svg)](https://github.com/istreamlabs/go-metrics/blob/master/LICENSE)
44

55
A library that provides an interface for sending metrics from your script, application, or service. Metrics consist of a name, value, and optionally some tags that are made up of key/value pairs.
66

@@ -22,15 +22,21 @@ Generally you will instantiate one of the above clients and then write metrics t
2222
dep ensure github.com/istreamlabs/go-metrics
2323

2424
# Otherwise, just go get it:
25-
go get github.com/istreamlabs/go-metrics
25+
go get github.com/istreamlabs/go-metrics/metrics
2626
```
2727

2828
Then you can use it:
2929

3030
```go
31-
import "github.com/istreamlabs/go-metrics"
32-
33-
client := metrics.NewDataDogClient("127.0.0.1:8125", "myprefix")
31+
import "github.com/istreamlabs/go-metrics/metrics"
32+
33+
var client metrics.Client
34+
if os.Getenv("env") == "prod" {
35+
client = metrics.NewDataDogClient("127.0.0.1:8125", "myprefix")
36+
} else {
37+
// Log to standard out instead of sending production metrics.
38+
client = metrics.NewLoggerClient(nil)
39+
}
3440

3541
// Simple incrementing counter
3642
client.Incr("requests.count")
@@ -41,7 +47,7 @@ client.WithTags(map[string]string{
4147
}).Incr("requests.count")
4248
```
4349

44-
The above code would result in `myprefix.requests.count` with a value of `1` showing up in DataDog if you have [`dogstatsd`](https://docs.datadoghq.com/guides/dogstatsd/) running locally. See the [`Client`](https://godoc.org/github.com/istreamlabs/go-metrics/#Client) interface for a list of available metrics methods.
50+
The above code would result in `myprefix.requests.count` with a value of `1` showing up in DataDog if you have [`dogstatsd`](https://docs.datadoghq.com/guides/dogstatsd/) running locally and an environment variable `env` set to `prod`, otherwise it will print metrics to standard out. See the [`Client`](https://godoc.org/github.com/istreamlabs/go-metrics/metrics/#Client) interface for a list of available metrics methods.
4551

4652
Also provided are useful clients for testing. For example, the following asserts that a metric with the given name, value, and tag was emitted during a test:
4753

@@ -61,7 +67,7 @@ func TestFoo(t *testing.T)
6167
}
6268
```
6369

64-
For more information and examples, see the [godocs](https://godoc.org/github.com/istreamlabs/go-metrics/).
70+
For more information and examples, see the [godocs](https://godoc.org/github.com/istreamlabs/go-metrics/metrics).
6571

6672
## License
6773

client.go renamed to metrics/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// development, and testing use cases. Generally you will instantiate one
77
// of these clients and then write metrics to it:
88
//
9+
// import "github.com/istreamlabs/go-metrics/metrics"
10+
//
911
// client := metrics.NewDataDogClient("127.0.0.1:8125", "myprefix")
1012
//
1113
// // Simple incrementing counter
File renamed without changes.

datadog_test.go renamed to metrics/datadog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77

88
"github.com/DataDog/datadog-go/statsd"
9-
"github.com/istreamlabs/go-metrics"
9+
"github.com/istreamlabs/go-metrics/metrics"
1010
)
1111

1212
func ExampleDataDogClient() {
File renamed without changes.
File renamed without changes.

logger_test.go renamed to metrics/logger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77

88
"github.com/DataDog/datadog-go/statsd"
9-
"github.com/istreamlabs/go-metrics"
9+
"github.com/istreamlabs/go-metrics/metrics"
1010
)
1111

1212
// LogRecorder dumps log messages into an array.
File renamed without changes.

metrics/null_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package metrics_test
2+
3+
import (
4+
"testing"
5+
"time"
6+
7+
"github.com/DataDog/datadog-go/statsd"
8+
"github.com/istreamlabs/go-metrics/metrics"
9+
)
10+
11+
func ExampleNullClient() {
12+
client := metrics.NewNullClient()
13+
client.WithTags(map[string]string{
14+
"tag1": "value1",
15+
"tag2": "value2",
16+
}).Incr("requests.count")
17+
client.Incr("other")
18+
19+
// Output:
20+
}
21+
22+
func TestNullClientMethods(t *testing.T) {
23+
client := metrics.NewNullClient()
24+
25+
client.Incr("count")
26+
client.Decr("count")
27+
client.Count("count", 5)
28+
29+
client.Gauge("gauge", 10)
30+
31+
client.Histogram("histo", 1.25)
32+
client.Timing("timing", time.Duration(123))
33+
34+
client.Event(&statsd.Event{})
35+
}

0 commit comments

Comments
 (0)