stackdriver_exporter
stackdriver_exporter copied to clipboard
Does not respect GOOGLE_CLOUD_QUOTA_PROJECT env variable
The monitoring.Service is constructed with a http.Client based on google.DefaultClient from golang.org/x/oauth2/google.
It seems this does not respect the environment variable GOOGLE_CLOUD_QUOTA_PROJECT to set the X-goog-user-project request header (GCP docs). The use of WithHTTPClient takes precedence and so the code that would otherwise set up the client in a way that respected the quota project is not used.
I can't see a straightforward way to fix this without specifically adding something into stackdriver_exporter to configure the quota project – but I'm not an expert in Go or the GCP client libraries.
I wondered if the NewClient function from google.golang.org/api/transport/http would be a better base Client, but the package docs say "This package is not intended for use by end developers" so it'd probably be a risky thing to introduce a direct dependency on it