Skip to content

Commit

Permalink
Explain how to specify Project ID
Browse files Browse the repository at this point in the history
  • Loading branch information
DazWilkin committed Sep 11, 2020
1 parent 7e67ff1 commit 2edc480
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions exporter/metric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit 2edc480

Please sign in to comment.