aws-embedded-metrics
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -101,26 +101,14 @@ "use strict"; | ||
MetricsContext.validateDimensionSet(incomingDimensionSet); | ||
if (this.dimensions.length === 0) { | ||
this.dimensions.push(incomingDimensionSet); | ||
return; | ||
} | ||
for (let i = 0; i < this.dimensions.length; i++) { | ||
const existingDimensionSet = this.dimensions[i]; | ||
// check for duplicate dimensions when putting | ||
// this is an O(n^2) operation, but since we never expect to have more than | ||
// 10 dimensions, this is acceptable for almost all cases. | ||
// This makes re-using loggers much easier. | ||
// Duplicate dimensions sets are removed before being added to the end of the collection. | ||
// This ensures the latest dimension key-value is used as a target member on the root EMF node. | ||
// This operation is O(n^2), but acceptable given sets are capped at 10 dimensions | ||
const incomingDimensionSetKeys = Object.keys(incomingDimensionSet); | ||
this.dimensions = this.dimensions.filter(existingDimensionSet => { | ||
const existingDimensionSetKeys = Object.keys(existingDimensionSet); | ||
const incomingDimensionSetKeys = Object.keys(incomingDimensionSet); | ||
if (existingDimensionSetKeys.length !== incomingDimensionSetKeys.length) { | ||
this.dimensions.push(incomingDimensionSet); | ||
return; | ||
return true; | ||
} | ||
for (let j = 0; j < existingDimensionSetKeys.length; j++) { | ||
if (!incomingDimensionSetKeys.includes(existingDimensionSetKeys[j])) { | ||
// we're done now because we know that the dimensions keys are not identical | ||
this.dimensions.push(incomingDimensionSet); | ||
return; | ||
} | ||
} | ||
} | ||
return !existingDimensionSetKeys.every(existingDimensionSetKey => incomingDimensionSetKeys.includes(existingDimensionSetKey)); | ||
}); | ||
this.dimensions.push(incomingDimensionSet); | ||
} | ||
@@ -127,0 +115,0 @@ /** |
{ | ||
"name": "aws-embedded-metrics", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "AWS Embedded Metrics Client Library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
120603
2339