Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 2c12eb8

Browse files
authored
📒Update README with more information
1 parent 73bab23 commit 2c12eb8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
# go-metrics-stackdriver
2+
[![godoc](https://godoc.org/github.com/google/go-metrics-stackdriver?status.svg)](http://godoc.org/github.com/google/go-metrics-stackdriver)
23

34
This library provides a stackdriver sink for applications instrumented with the
45
[go-metrics](https://github.com/armon/go-metrics) library.
56

7+
## Details
8+
9+
[stackdriver.NewSink](https://godoc.org/github.com/google/go-metrics-stackdriver#NewSink)'s return value satisfies the go-metrics library's [MetricSink](https://godoc.org/github.com/armon/go-metrics#MetricSink) interface. When providing a `stackdriver.Sink` to libraries and applications instrumented against `MetricSink`, the metrics will be aggregated within this library and written to stackdriver as [Generic Task](https://cloud.google.com/monitoring/api/resources#tag_generic_task) timeseries metrics.
10+
11+
## Example
12+
13+
```go
14+
import "github.com/google/go-metrics-stackdriver"
15+
...
16+
client, _ := monitoring.NewMetricClient(context.Background())
17+
ss := stackdriver.NewSink(60*time.Second, &stackdriver.TaskInfo{
18+
ProjectID: projectID,
19+
Location: "us-east1-c",
20+
Job: "example-app",
21+
}, client)
22+
...
23+
ss.SetGauge([]string{"foo"}, 42)
24+
ss.IncrCounter([]string{"baz"}, 1)
25+
ss.AddSample([]string{"method", "const"}, 200)
26+
```
27+
28+
The [full example](example/main.go) can be run from a cloud shell console to test how metrics are collected and displayed.
29+
30+
631
__This is not an officially supported Google product.__

0 commit comments

Comments
 (0)