google-cloud-cpp
google-cloud-cpp copied to clipboard
Determine the project used to export GCS+gRPC metrics
- [ ] If the resource detector detects a GCP project, use that.
- [x] If the
storage::ProjectIdOptionis set and not empty, use that. - [x] ~If the
GAE_PROJECTenvironment variable is set, use that.~ ignore this, C++ does not work in GAE - [ ] If ADC points to a file, use the
project_idfield from that file (if applicable). - https://google.aip.dev/auth/4112 for service account key files - The field may exist in user credentials, and does not exist for external accounts - [x] ~The Google Cloud SDK project ID~ ignore for now. This is really difficult in C++, and only useful with user credentials, which are not expected to need metrics that often.
- [ ] If we are using GCE credentials, use the value of
computeMetadata/v1/project/project-idfrom the VM metadatacurl -sv -HMetadata-Flavor:Google http://metadata.google.internal./computeMetadata/v1/project/project-id - [x] Parse the project id from the ADC file.
- [x] Fetch the project id from the GCE credentials.
- [x] Add project id accessors to the oauth2 credentials files.
We may be able to use the resource detector. OTOH, we need to add this functionality to the REST credentials. This will all require converting GUACs to REST credentials, performing one query and then discarding the infrastructure created to make the query.