, . GCP, Cloud Function, Compute Engine.
. Cloud Trace
private_key, client_email projectId GCP. json .
, Cloud Trace Node.js .
credentials projectId :
: : . https://developers.google.com/accounts/docs/application-default-credentials . GoogleAuth. (/srv/node_modules/google-auth-library/build/src/auth/googleauth.js:248:31) (/srv/node_modules/google-auth-library/build/src/auth/googleauth.js: 47:23) Object.next(/srv/node_modules/google-auth-library/build/src/auth/googleauth.js:28:53) (/srv/node_modules/google-auth-library/build/src/auth/googleauth.js: 19: 58) at at process._tickDomainCallback ( /process/next_tick.js: 229: 7)
You can transfer credentialsand projectIdhow the environment variables. After configuration credentials, the projectIderror disappeared.
const tracer = require('@google-cloud/trace-agent').start({
samplingRate: 0,
bufferSize: 1,
credentials: {
client_email: process.env.CLIENT_EMAIL,
private_key: process.env.TRACE_AGENT_ADMIN,
},
projectId: process.env.X_GOOGLE_GCLOUD_PROJECT || process.env.PROJECT_ID,
});
X_GOOGLE_GCLOUD_PROJECT is a built-in environment variable for executing a cloud function
source
share