diff --git a/functions/log/index.js b/functions/log/index.js index 026e5b7013..151cdfa3b7 100644 --- a/functions/log/index.js +++ b/functions/log/index.js @@ -48,52 +48,6 @@ const getLogEntries = async () => { }; // [END functions_log_retrieve] -// [START functions_log_get_metrics] -// By default, the client will authenticate using the service account file -// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use -// the project specified by the GCLOUD_PROJECT environment variable. See -// https://github.com/googleapis/google-cloud-node/blob/master/docs/authentication.md -const Monitoring = require('@google-cloud/monitoring'); - -const getMetrics = (callback) => { - // Instantiates a client - const monitoring = Monitoring.v3().metricServiceApi(); - - // Create two datestrings, a start and end range - const oneWeekAgo = new Date(); - oneWeekAgo.setHours(oneWeekAgo.getHours() - 7 * 24); - - const options = { - name: monitoring.projectPath(process.env.GCLOUD_PROJECT), - // There is also: cloudfunctions.googleapis.com/function/execution_count - filter: - 'metric.type="cloudfunctions.googleapis.com/function/execution_times"', - interval: { - startTime: { - seconds: oneWeekAgo.getTime() / 1000, - }, - endTime: { - seconds: Date.now() / 1000, - }, - }, - view: 1, - }; - - console.log('Data:'); - - let error; - - // Iterate over all elements. - monitoring - .listTimeSeries(options) - .on('error', (err) => { - error = err; - }) - .on('data', (element) => console.log(element)) - .on('end', () => callback(error)); - // [END functions_log_get_metrics] -}; - // [START functions_log_stackdriver] exports.processLogEntry = (data) => { const dataBuffer = Buffer.from(data.data, 'base64'); @@ -106,4 +60,3 @@ exports.processLogEntry = (data) => { // [END functions_log_stackdriver] exports.getLogEntries = getLogEntries; -exports.getMetrics = getMetrics; diff --git a/functions/log/test/index.test.js b/functions/log/test/index.test.js index 24d93cfd96..5c92f939ef 100644 --- a/functions/log/test/index.test.js +++ b/functions/log/test/index.test.js @@ -87,17 +87,6 @@ describe('functions_log_retrieve', () => { }); }); -describe('functions_log_get_metrics', () => { - it('getMetrics: should retrieve metrics', () => { - const sample = getSample(); - const callback = sinon.stub(); - - sample.program.getMetrics(callback); - - assert.strictEqual(callback.callCount, 1); - }); -}); - describe('functions_log_stackdriver', () => { it('processLogEntry: should process log entry', () => { const sample = getSample();