From 2edc48082e9cc22b0d0c2614a612ba8fa2f6f76a Mon Sep 17 00:00:00 2001 From: DazWilkin Date: Fri, 11 Sep 2020 10:33:37 -0700 Subject: [PATCH] Explain how to specify Project ID --- exporter/metric/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/exporter/metric/README.md b/exporter/metric/README.md index f55fd67fc..55ce02128 100644 --- a/exporter/metric/README.md +++ b/exporter/metric/README.md @@ -27,10 +27,7 @@ import ( ) // Initialize exporter option. -projectID := os.Getenv("GOOGLE_CLOUD_PROJECT") -opts := []mexporter.Option{ - mexporter.WithProjectID(projectID), -} +opts := []mexporter.Option{} popts:= []push.Option{} // Create exporter (collector embedded with the exporter). @@ -60,6 +57,15 @@ The Google Cloud Monitoring exporter depends upon [`google.FindDefaultCredential * A JSON file whose path is specified by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. * A JSON file in a location known to the gcloud command-line tool. On Windows, this is `%APPDATA%/gcloud/application_default_credentials.json`. On other systems, `$HOME/.config/gcloud/application_default_credentials.json`. +When running code locally, you may need to specify a Google Project ID in addition to `GOOGLE_APPLICATION_CREDENTIALS`. This is best done using an environment variable (e.g. `GOOGLE_CLOUD_PROJECT`) and the `metric.WithProjectID` method, e.g.: + +```golang +projectID := os.Getenv("GOOGLE_CLOUD_PROJECT") +opts := []mexporter.Option{ + mexporter.WithProjectID(projectID), +} +``` + ## Useful links * For more information on OpenTelemetry, visit: https://opentelemetry.io/