diff --git a/README.md b/README.md index beebba0..f50f86f 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ CustomMetrics is a NodeJS library to emit and query custom metrics for AWS apps. ->CustomMetrics is under active development and is not (yet) ready for production use. This README documentation is incomplete. All feedback is welcome. - ## Background AWS CloudWatch offers metrics to monitor specific aspects of your apps that are not covered by the default AWS infrastructure metrics. diff --git a/src/index.ts b/src/index.ts index 2203ee9..dbcacf6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -419,25 +419,12 @@ export class CustomMetrics { (buffer.count && elt.count >= buffer.count) || this.timestamp >= elt.timestamp ) { - /* KEEP - this.log.trace( - `Emit buffered metric ${namespace}/${metricName} = ${point.sum}, sum ${elt.sum} count ${ - elt.count - } remaining ${elt.timestamp - this.timestamp}` - ) */ point.timestamp = elt.timestamp await this.emitDimensionedMetric(namespace, metricName, point, dimensions, options) } elt.count += point.count elt.sum += point.sum - /* KEEP - this.log.trace( - `Buffer metric ${namespace}/${metricName} = sum ${elt.sum} count ${elt.count}, remaining ${ - elt.timestamp - this.timestamp - }`, {buffers: this.buffers} - ) */ - CustomMetrics.saveInstance({key}, this) return { spans: [{points: [{count: elt.count, sum: elt.sum}]}], @@ -1102,9 +1089,9 @@ export class CustomMetrics { } /* - UNDOCUMENTED DEPRECATED Allocate a CustomMetrics instance from the cache */ + //REMOVE static allocInstance(tags: object, options: MetricOptions = {}) { let key = JSON.stringify(tags) let metrics = Instances[key] @@ -1114,6 +1101,7 @@ export class CustomMetrics { return metrics } + //REMOVE static freeInstance(tags: object) { let key = JSON.stringify(tags) delete Instances[key] @@ -1123,6 +1111,7 @@ export class CustomMetrics { delete Instances[key] } + //REMOVE static getInstance(tags: object) { let key = JSON.stringify(tags) return Instances[key] @@ -1133,6 +1122,7 @@ export class CustomMetrics { Instances[key] = metrics } + //REMOVE static getCache() { return Instances } diff --git a/test/cache.ts b/test/cache.ts deleted file mode 100644 index 70d7fa0..0000000 --- a/test/cache.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - cache.ts - CustomMetrics instance cache - - UNDOCUMENTED AND DEPRECATED - */ -import {client, table, CustomMetrics} from './utils/init' - -// jest.setTimeout(7200 * 1000) - -test('Alloc', async () => { - let tags = {name: 'primary'} - let metrics = CustomMetrics.allocInstance(tags, {client, table, log: true}) - expect(metrics).toBeDefined() - expect(metrics instanceof CustomMetrics).toBe(true) - expect(typeof metrics.emit == 'function').toBe(true) - - let inst = CustomMetrics.getInstance(tags) - expect(inst).toEqual(metrics) - - let cache = CustomMetrics.getCache() - expect(cache).toBeDefined() - expect(Object.keys(cache).length).toBe(1) - expect(cache[JSON.stringify(tags)]).toEqual(metrics) - - inst = CustomMetrics.allocInstance(tags) - expect(inst).toEqual(metrics) - cache = CustomMetrics.getCache() - expect(Object.keys(cache).length).toBe(1) - CustomMetrics.flushAll() - - CustomMetrics.freeInstance(tags) - inst = CustomMetrics.getInstance(tags) - expect(inst).toBeUndefined() - expect(cache).toBeDefined() - expect(Object.keys(cache).length).toBe(0) - - CustomMetrics.freeInstanceByKey('unknown') -}) \ No newline at end of file