in packages/opentelemetry-cloud-monitoring-exporter/src/monitoring.ts [75:103]
constructor(options: ExporterOptions = {}) {
this._metricPrefix = options.prefix ?? MetricExporter.DEFAULT_METRIC_PREFIX;
this._disableCreateMetricDescriptors =
!!options.disableCreateMetricDescriptors;
this._auth = new GoogleAuth({
credentials: options.credentials,
keyFile: options.keyFile,
keyFilename: options.keyFilename,
projectId: options.projectId,
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
this._monitoring = monitoring({
version: 'v3',
rootUrl:
'https://' + (options.apiEndpoint || 'monitoring.googleapis.com:443'),
headers: OT_REQUEST_HEADER,
userAgentDirectives: OT_USER_AGENTS.concat(
options.userAgent ? [options.userAgent] : []
),
});
// Start this async process as early as possible. It will be
// awaited on the first export because constructors are synchronous
this._projectId = this._auth.getProjectId().catch(err => {
diag.error(err);
});
}