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

Commit

Permalink
fix example to use new api to start and stop exporting. (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
rghetia authored Aug 30, 2019
1 parent 4b7f306 commit 211cb75
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions examples/stats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,17 @@ func main() {
// to setup the authorization.
// See https://developers.google.com/identity/protocols/application-default-credentials
// for more details.
_, err := stackdriver.NewExporter(stackdriver.Options{
se, err := stackdriver.NewExporter(stackdriver.Options{
ProjectID: "your-project-id", // Google Cloud Console project ID for stackdriver.
MonitoredResource: monitoredresource.Autodetect(),
})
se.StartMetricsExporter()
defer se.StopMetricsExporter()

if err != nil {
log.Fatal(err)
}

// Set reporting period to report data at 60 seconds.
// The recommended reporting period by Stackdriver Monitoring is >= 1 minute:
// https://cloud.google.com/monitoring/custom-metrics/creating-metrics#writing-ts.
view.SetReportingPeriod(60 * time.Second)

// Create view to see the processed video size cumulatively.
// Subscribe will allow view data to be exported.
// Once no longer need, you can unsubscribe from the view.
Expand Down

0 comments on commit 211cb75

Please sign in to comment.