stackdriver_exporter icon indicating copy to clipboard operation
stackdriver_exporter copied to clipboard

Does not respect GOOGLE_CLOUD_QUOTA_PROJECT env variable

Open michaelbannister opened this issue 7 months ago • 1 comments

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.

michaelbannister avatar Apr 28 '25 13:04 michaelbannister

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

michaelbannister avatar Apr 28 '25 14:04 michaelbannister