Skip to content

Commit

Permalink
refactor: remove metrics module
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Apr 14, 2024
1 parent 4d0a95a commit 7f81bf8
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 79 deletions.
3 changes: 0 additions & 3 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ dockerSupportedVersions:
linux: https://docs.docker.com/engine/install/

landoFile: .lando.yml
stats:
- report: true
url: https://metrics.lando.dev
7 changes: 0 additions & 7 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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);
Expand Down
37 changes: 0 additions & 37 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
},
});
};
1 change: 0 additions & 1 deletion lib/lando.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 0 additions & 12 deletions lib/metrics.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/error.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion test/lando.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
});
Expand Down

0 comments on commit 7f81bf8

Please sign in to comment.