1# 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)
3
4This library provides a stackdriver sink for applications instrumented with the
5[go-metrics](https://github.com/armon/go-metrics) library.
6
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
14import "github.com/google/go-metrics-stackdriver"
15...
16client, _ := monitoring.NewMetricClient(context.Background())
17ss := stackdriver.NewSink(client, &stackdriver.Config{
18  ProjectID: projectID,
19})
20...
21ss.SetGauge([]string{"foo"}, 42)
22ss.IncrCounter([]string{"baz"}, 1)
23ss.AddSample([]string{"method", "const"}, 200)
24```
25
26The [full example](example/main.go) can be run from a cloud shell console to test how metrics are collected and displayed.
27
28
29__This is not an officially supported Google product.__
30