in src/logger/MetricsContext.ts [156:178]
public getDimensions(): Array<Record<string, string>> {
// caller has explicitly called setDimensions
if (this.shouldUseDefaultDimensions === false) {
return this.dimensions;
}
// if there are no default dimensions, return the custom dimensions
if (Object.keys(this.defaultDimensions).length === 0) {
return this.dimensions;
}
// if default dimensions have been provided, but no custom dimensions, use the defaults
if (this.dimensions.length === 0) {
return [this.defaultDimensions];
}
// otherwise, merge the dimensions
// we do this on the read path because default dimensions
// may get updated asynchronously by environment detection
return this.dimensions.map(custom => {
return { ...this.defaultDimensions, ...custom };
});
}