open-vault/vendor/github.com/google/go-metrics-stackdriver
Tommy Murphy a936a77f01
stackdriver: metric label extraction (#8073)
* stackdriver: use label extraction and add debug config

* go.mod: update go-metrics-stackdriver

* vendor go-metrics-stackdriver
2020-03-13 07:58:45 +01:00
..
vault stackdriver: metric label extraction (#8073) 2020-03-13 07:58:45 +01:00
CONTRIBUTING.md
go.mod stackdriver: metric label extraction (#8073) 2020-03-13 07:58:45 +01:00
go.sum stackdriver: metric label extraction (#8073) 2020-03-13 07:58:45 +01:00
LICENSE
README.md stackdriver: metric label extraction (#8073) 2020-03-13 07:58:45 +01:00
stackdriver.go stackdriver: metric label extraction (#8073) 2020-03-13 07:58:45 +01:00

go-metrics-stackdriver

godoc

This library provides a stackdriver sink for applications instrumented with the go-metrics library.

Details

stackdriver.NewSink's return value satisfies the go-metrics library's 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 timeseries metrics.

Example

import "github.com/google/go-metrics-stackdriver"
...
client, _ := monitoring.NewMetricClient(context.Background())
ss := stackdriver.NewSink(client, &stackdriver.Config{
  ProjectID: projectID,
})
...
ss.SetGauge([]string{"foo"}, 42)
ss.IncrCounter([]string{"baz"}, 1)
ss.AddSample([]string{"method", "const"}, 200)

The full example can be run from a cloud shell console to test how metrics are collected and displayed.

You can also try out the example using Cloud Run!

Run on Google Cloud

This is not an officially supported Google product.