Skip to content

Commit 2c80c99

Browse files
author
Ace Nassri
authored
GCF: delete extraneous getmetrics sample (#1734)
1 parent 3a651b2 commit 2c80c99

2 files changed

Lines changed: 0 additions & 58 deletions

File tree

functions/log/index.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,52 +48,6 @@ const getLogEntries = async () => {
4848
};
4949
// [END functions_log_retrieve]
5050

51-
// [START functions_log_get_metrics]
52-
// By default, the client will authenticate using the service account file
53-
// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use
54-
// the project specified by the GCLOUD_PROJECT environment variable. See
55-
// https://github.com/googleapis/google-cloud-node/blob/master/docs/authentication.md
56-
const Monitoring = require('@google-cloud/monitoring');
57-
58-
const getMetrics = (callback) => {
59-
// Instantiates a client
60-
const monitoring = Monitoring.v3().metricServiceApi();
61-
62-
// Create two datestrings, a start and end range
63-
const oneWeekAgo = new Date();
64-
oneWeekAgo.setHours(oneWeekAgo.getHours() - 7 * 24);
65-
66-
const options = {
67-
name: monitoring.projectPath(process.env.GCLOUD_PROJECT),
68-
// There is also: cloudfunctions.googleapis.com/function/execution_count
69-
filter:
70-
'metric.type="cloudfunctions.googleapis.com/function/execution_times"',
71-
interval: {
72-
startTime: {
73-
seconds: oneWeekAgo.getTime() / 1000,
74-
},
75-
endTime: {
76-
seconds: Date.now() / 1000,
77-
},
78-
},
79-
view: 1,
80-
};
81-
82-
console.log('Data:');
83-
84-
let error;
85-
86-
// Iterate over all elements.
87-
monitoring
88-
.listTimeSeries(options)
89-
.on('error', (err) => {
90-
error = err;
91-
})
92-
.on('data', (element) => console.log(element))
93-
.on('end', () => callback(error));
94-
// [END functions_log_get_metrics]
95-
};
96-
9751
// [START functions_log_stackdriver]
9852
exports.processLogEntry = (data) => {
9953
const dataBuffer = Buffer.from(data.data, 'base64');
@@ -106,4 +60,3 @@ exports.processLogEntry = (data) => {
10660
// [END functions_log_stackdriver]
10761

10862
exports.getLogEntries = getLogEntries;
109-
exports.getMetrics = getMetrics;

functions/log/test/index.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ describe('functions_log_retrieve', () => {
8787
});
8888
});
8989

90-
describe('functions_log_get_metrics', () => {
91-
it('getMetrics: should retrieve metrics', () => {
92-
const sample = getSample();
93-
const callback = sinon.stub();
94-
95-
sample.program.getMetrics(callback);
96-
97-
assert.strictEqual(callback.callCount, 1);
98-
});
99-
});
100-
10190
describe('functions_log_stackdriver', () => {
10291
it('processLogEntry: should process log entry', () => {
10392
const sample = getSample();

0 commit comments

Comments
 (0)