Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// for more details.
// Expects ADCs to be provided through the environment as ${GOOGLE_APPLICATION_CREDENTIALS}
// A Stackdriver workspace is required and provided through the environment as ${GOOGLE_PROJECT_ID}
const projectId = process.env.GOOGLE_PROJECT_ID;
// GOOGLE_APPLICATION_CREDENTIALS are expected by a dependency of this code
// Not this code itself. Checking for existence here but not retaining (as not needed)
if (!projectId || !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw Error('Unable to proceed without a Project ID');
}
// Creates Stackdriver exporter
const exporter = new StackdriverTraceExporter({ projectId: projectId });
// Starts Stackdriver exporter
tracing.registerExporter(exporter).start();
// Starts tracing and set sampling rate
const tracer = tracing.start({
samplingRate: 1 // For demo purposes, always sample
}).tracer;
// Defines basedir and version
const basedir = path.dirname(require.resolve('grpc'));
const version = require(path.join(basedir, 'package.json')).version;
// Enables GRPC plugin: Method that enables the instrumentation patch.
plugin.enable(grpc, tracer, version, /** plugin options */{}, basedir);
return tracer;
}// See https://developers.google.com/identity/protocols/application-default-credentials
// for more details.
// Expects ADCs to be provided through the environment as ${GOOGLE_APPLICATION_CREDENTIALS}
// A Stackdriver workspace is required and provided through the environment as ${GOOGLE_PROJECT_ID}
const projectId = process.env.GOOGLE_PROJECT_ID;
// GOOGLE_APPLICATION_CREDENTIALS are expected by a dependency of this code
// Not this code itself. Checking for existence here but not retaining (as not needed)
if (!projectId || !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw Error('Unable to proceed without a Project ID');
}
// Creates Stackdriver exporter
const exporter = new StackdriverTraceExporter({ projectId: projectId });
// Starts Stackdriver exporter
tracing.registerExporter(exporter).start();
// Starts tracing and set sampling rate
const tracer = tracing.start({
samplingRate: 1 // For demo purposes, always sample
}).tracer;
// Defines basedir and version
const basedir = path.dirname(require.resolve('grpc'));
const version = require(path.join(basedir, 'package.json')).version;
// Enables GRPC plugin: Method that enables the instrumentation patch.
plugin.enable(grpc, tracer, version, /** plugin options */{}, basedir);
return tracer;
}