google-cloud-cpp icon indicating copy to clipboard operation
google-cloud-cpp copied to clipboard

Determine the project used to export GCS+gRPC metrics

Open coryan opened this issue 1 year ago • 0 comments

  • [ ] If the resource detector detects a GCP project, use that.
  • [x] If the storage::ProjectIdOption is set and not empty, use that.
  • [x] ~If the GAE_PROJECT environment variable is set, use that.~ ignore this, C++ does not work in GAE
  • [ ] If ADC points to a file, use the project_id field 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-id from the VM metadata
    curl -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.

coryan avatar May 01 '24 22:05 coryan