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

Commit 211cb75

Browse files
authored
fix example to use new api to start and stop exporting. (#190)
1 parent 4b7f306 commit 211cb75

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

examples/stats/main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,17 @@ func main() {
4646
// to setup the authorization.
4747
// See https://developers.google.com/identity/protocols/application-default-credentials
4848
// for more details.
49-
_, err := stackdriver.NewExporter(stackdriver.Options{
49+
se, err := stackdriver.NewExporter(stackdriver.Options{
5050
ProjectID: "your-project-id", // Google Cloud Console project ID for stackdriver.
5151
MonitoredResource: monitoredresource.Autodetect(),
5252
})
53+
se.StartMetricsExporter()
54+
defer se.StopMetricsExporter()
55+
5356
if err != nil {
5457
log.Fatal(err)
5558
}
5659

57-
// Set reporting period to report data at 60 seconds.
58-
// The recommended reporting period by Stackdriver Monitoring is >= 1 minute:
59-
// https://cloud.google.com/monitoring/custom-metrics/creating-metrics#writing-ts.
60-
view.SetReportingPeriod(60 * time.Second)
61-
6260
// Create view to see the processed video size cumulatively.
6361
// Subscribe will allow view data to be exported.
6462
// Once no longer need, you can unsubscribe from the view.

0 commit comments

Comments
 (0)