From 7f81bf8ea2d2f80d107c25fc11dfcf4db4095b51 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sun, 14 Apr 2024 07:23:54 +0300 Subject: [PATCH] refactor: remove metrics module --- config.yml | 3 --- lib/app.js | 7 ------- lib/bootstrap.js | 37 ------------------------------------- lib/lando.js | 1 - lib/metrics.js | 12 ------------ lib/utils.js | 17 ----------------- test/error.spec.js | 2 +- test/lando.spec.js | 1 - 8 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 lib/metrics.js diff --git a/config.yml b/config.yml index ee0f80eb1..5211e4864 100644 --- a/config.yml +++ b/config.yml @@ -23,6 +23,3 @@ dockerSupportedVersions: linux: https://docs.docker.com/engine/install/ landoFile: .lando.yml -stats: - - report: true - url: https://metrics.lando.dev diff --git a/lib/app.js b/lib/app.js index fc97fc75c..e4e45ed6f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -79,12 +79,6 @@ module.exports = class App { * @since 3.0.0 * @alias app.events */ - /** - * The apps metric reporter - * - * @since 3.0.0 - * @alias app.metrics - */ /** * The apps url scanner * @@ -107,7 +101,6 @@ module.exports = class App { this.shell, lando.config.instance, ); - this.metrics = bootstrap.setupMetrics(this.log, lando.config); this.Promise = lando.Promise; this.events = new AsyncEvents(this.log); this.scanUrls = scan(this.log); diff --git a/lib/bootstrap.js b/lib/bootstrap.js index e74611638..9434659c9 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -100,19 +100,6 @@ const parseLandofileConfig = (config = {}) => ({ landoFile: true, }); -/* - * Gets the current env var and returns the key needed for metrics - */ -const getMetricsContext = () => { - if (_.has(process, 'env.GITPOD_WORKSPACE_ID') || _.has(process, 'env.CODESPACES')) { - return 'remote'; - } else if ( _.has(process, 'env.CI')) { - return 'ci'; - } else { - return 'local'; - } -}; - /* * Helper to build config */ @@ -261,27 +248,3 @@ exports.setupEngine = (config, cache, events, log, shell, id) => { const compose = (cmd, datum) => exports.dc(shell, config.composeBin, cmd, datum); return new Engine(daemon, docker, compose, config); }; - -/* - * Helper to setup metrics - */ -exports.setupMetrics = (log, config) => { - const Metrics = require('./metrics'); - const command = _.get(config, 'command._', 'unknown'); - return new Metrics({ - log, - id: config.id, - endpoints: config.stats, - data: { - command: `lando ${command}`, - context: getMetricsContext(), - devMode: false, - instance: config.instance || 'unknown', - nodeVersion: process.version, - mode: config.mode || 'unknown', - os: config.os, - product: config.product, - version: config.version, - }, - }); -}; diff --git a/lib/lando.js b/lib/lando.js index 8024e4576..d513e121f 100644 --- a/lib/lando.js +++ b/lib/lando.js @@ -195,7 +195,6 @@ module.exports = class Lando { this.cache = bootstrap.setupCache(this.log, this.config); this.cli = new Cli(); this.log = new Log(this.config); - this.metrics = bootstrap.setupMetrics(this.log, this.config); this.error = new ErrorHandler(this.log); this.events = new AsyncEvents(this.log); this.user = require('./user'); diff --git a/lib/metrics.js b/lib/metrics.js deleted file mode 100644 index fde7e6522..000000000 --- a/lib/metrics.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -const Promise = require('./promise'); - -/* - * Creates a new Metrics thing. - */ -module.exports = class Metrics { - report() { - return Promise.resolve(); - }; -}; diff --git a/lib/utils.js b/lib/utils.js index c4eafd8fc..8489b1a35 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -103,23 +103,6 @@ exports.getUser = (service, info = []) => { return _.get(_.find(info, {service}), 'meUser', 'www-data'); }; -/* - * Helper to parse metrics data - */ -exports.metricsParse = app => { - // Metadata to report. - const data = { - app: _.get(app, 'id', 'unknown'), - type: _.get(app, 'config.recipe', 'none'), - }; - // Build an array of services to send as well - if (_.has(app, 'config.services')) { - data.services = _.map(_.get(app, 'config.services'), service => service.type); - } - // Return - return data; -}; - /* * We might have datum but we need to wrap in array so Promise.each knows * what to do diff --git a/test/error.spec.js b/test/error.spec.js index 61e2badff..cdf90ea12 100644 --- a/test/error.spec.js +++ b/test/error.spec.js @@ -36,7 +36,7 @@ describe('error', () => { }); }); - it('should log message and report to metrics by default', () => { + it('should log message by default', () => { const error = new ErrorHandler({error: sinon.spy()}); return error.handle().then(code => { error.log.error.callCount.should.equal(1); diff --git a/test/lando.spec.js b/test/lando.spec.js index 25a828710..e4e8e5ec4 100644 --- a/test/lando.spec.js +++ b/test/lando.spec.js @@ -81,7 +81,6 @@ describe('lando', () => { pluginDirs: [srcRoot], }); return lando.bootstrap().then(lando => { - lando.config.stats.should.be.an('array').and.not.be.empty; // We need to clear out tasks because it seems to persist from require to require lando.tasks.tasks = []; });