UNPKG

vulcain-corejs

Version:
46 lines (44 loc) 1.41 kB
"use strict"; const system_1 = require('../configurations/globals/system'); /** * Metrics adapter for testing * Emit metrics on console * * @export * @class ConsoleMetrics */ class ConsoleMetrics { constructor(address) { this.customTags = ""; this.tags = ",environment=" + system_1.System.environment + ",service=" + system_1.System.serviceName + ',version=' + system_1.System.serviceVersion; } /** * Add tags as an array of string like <tag-name>=<tag-value> * * @param {...Array<string>} tags * * @memberOf Metrics */ setTags(...tags) { this.customTags = "," + tags.join(','); } log(msg) { } increment(metric, delta) { this.log(`METRICS: incr ${metric + this.tags + this.customTags} : ${delta || 1}`); } decrement(metric, delta) { this.log(`METRICS: decr ${metric + this.tags + this.customTags} : ${delta || -1}`); } counter(metric, delta) { this.log(`METRICS: counter ${metric + this.tags + this.customTags} : ${delta}`); } gauge(metric, value) { this.log(`METRICS: gauge ${metric + this.tags + this.customTags} : ${value}`); } timing(metric, duration) { this.log(`METRICS: timing ${metric + this.tags + this.customTags} : ${duration}ms`); } } exports.ConsoleMetrics = ConsoleMetrics; //# sourceMappingURL=consoleMetrics.js.map