New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aws-lambda-powertools/metrics

Package Overview
Dependencies
Maintainers
0
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-lambda-powertools/metrics - npm Package Compare versions

Comparing version 2.11.0 to 2.12.0

7

lib/cjs/config/EnvironmentVariablesService.d.ts

@@ -11,2 +11,3 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';

private namespaceVariable;
private readonly disabledVariable;
/**

@@ -16,4 +17,10 @@ * Get the value of the `POWERTOOLS_METRICS_NAMESPACE` environment variable.

getNamespace(): string;
/**
* Get the value of the `POWERTOOLS_METRICS_DISABLED` or `POWERTOOLS_DEV` environment variables.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
getMetricsDisabled(): boolean;
}
export { EnvironmentVariablesService };
//# sourceMappingURL=EnvironmentVariablesService.d.ts.map

@@ -13,2 +13,3 @@ "use strict";

namespaceVariable = 'POWERTOOLS_METRICS_NAMESPACE';
disabledVariable = 'POWERTOOLS_METRICS_DISABLED';
/**

@@ -20,3 +21,18 @@ * Get the value of the `POWERTOOLS_METRICS_NAMESPACE` environment variable.

}
/**
* Get the value of the `POWERTOOLS_METRICS_DISABLED` or `POWERTOOLS_DEV` environment variables.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
getMetricsDisabled() {
const value = this.get(this.disabledVariable);
if (this.isValueFalse(value))
return false;
if (this.isValueTrue(value))
return true;
if (this.isDevMode())
return true;
return false;
}
}
exports.EnvironmentVariablesService = EnvironmentVariablesService;

@@ -158,2 +158,6 @@ import { Utility } from '@aws-lambda-powertools/commons';

private storedMetrics;
/**
* Whether to disable metrics
*/
private disabled;
constructor(options?: MetricsOptions);

@@ -351,2 +355,6 @@ /**

/**
* Whether metrics are disabled.
*/
protected isDisabled(): boolean;
/**
* A class method decorator to automatically log metrics after the method returns or throws an error.

@@ -595,2 +603,8 @@ *

/**
* Set the disbaled flag based on the environment variables `POWERTOOLS_METRICS_DISABLED` and `POWERTOOLS_DEV`.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
private setDisabled;
/**
* Set the options to be used by the Metrics instance.

@@ -597,0 +611,0 @@ *

48

lib/cjs/Metrics.js

@@ -169,2 +169,6 @@ "use strict";

/**
* Whether to disable metrics
*/
disabled = false;
/**
* Custom timestamp for the metrics

@@ -200,2 +204,6 @@ */

}
if (Object.hasOwn(this.dimensions, name) ||
Object.hasOwn(this.defaultDimensions, name)) {
this.#logger.warn(`Dimension "${name}" has already been added. The previous value will be overwritten.`);
}
this.dimensions[name] = value;

@@ -216,16 +224,5 @@ }

addDimensions(dimensions) {
const newDimensions = { ...this.dimensions };
for (const dimensionName of Object.keys(dimensions)) {
const value = dimensions[dimensionName];
if (value) {
newDimensions[dimensionName] = value;
}
else {
this.#logger.warn(`The dimension ${dimensionName} doesn't meet the requirements and won't be added. Ensure the dimension name and value are non empty strings`);
}
for (const [name, value] of Object.entries(dimensions)) {
this.addDimension(name, value);
}
if (Object.keys(newDimensions).length > constants_js_1.MAX_DIMENSION_COUNT) {
throw new RangeError(`Unable to add ${Object.keys(dimensions).length} dimensions: the number of metric dimensions must be lower than ${constants_js_1.MAX_DIMENSION_COUNT}`);
}
this.dimensions = newDimensions;
}

@@ -425,2 +422,8 @@ /**

/**
* Whether metrics are disabled.
*/
isDisabled() {
return this.disabled;
}
/**
* A class method decorator to automatically log metrics after the method returns or throws an error.

@@ -521,4 +524,6 @@ *

}
const emfOutput = this.serializeMetrics();
hasMetrics && this.console.log(JSON.stringify(emfOutput));
if (!this.disabled) {
const emfOutput = this.serializeMetrics();
hasMetrics && this.console.log(JSON.stringify(emfOutput));
}
this.clearMetrics();

@@ -729,5 +734,5 @@ this.clearDimensions();

*/
throwOnEmptyMetrics() {
/* v8 ignore start */ throwOnEmptyMetrics() {
this.shouldThrowOnEmptyMetrics = true;
}
} /* v8 ignore stop */
/**

@@ -818,2 +823,10 @@ * Gets the current number of dimensions count.

/**
* Set the disbaled flag based on the environment variables `POWERTOOLS_METRICS_DISABLED` and `POWERTOOLS_DEV`.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
setDisabled() {
this.disabled = this.getEnvVarsService().getMetricsDisabled();
}
/**
* Set the options to be used by the Metrics instance.

@@ -830,2 +843,3 @@ *

this.setCustomConfigService(customConfigService);
this.setDisabled();
this.setNamespace(namespace);

@@ -832,0 +846,0 @@ this.setService(serviceName);

@@ -11,2 +11,3 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';

private namespaceVariable;
private readonly disabledVariable;
/**

@@ -16,4 +17,10 @@ * Get the value of the `POWERTOOLS_METRICS_NAMESPACE` environment variable.

getNamespace(): string;
/**
* Get the value of the `POWERTOOLS_METRICS_DISABLED` or `POWERTOOLS_DEV` environment variables.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
getMetricsDisabled(): boolean;
}
export { EnvironmentVariablesService };
//# sourceMappingURL=EnvironmentVariablesService.d.ts.map

@@ -10,2 +10,3 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';

namespaceVariable = 'POWERTOOLS_METRICS_NAMESPACE';
disabledVariable = 'POWERTOOLS_METRICS_DISABLED';
/**

@@ -17,3 +18,18 @@ * Get the value of the `POWERTOOLS_METRICS_NAMESPACE` environment variable.

}
/**
* Get the value of the `POWERTOOLS_METRICS_DISABLED` or `POWERTOOLS_DEV` environment variables.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
getMetricsDisabled() {
const value = this.get(this.disabledVariable);
if (this.isValueFalse(value))
return false;
if (this.isValueTrue(value))
return true;
if (this.isDevMode())
return true;
return false;
}
}
export { EnvironmentVariablesService };

@@ -158,2 +158,6 @@ import { Utility } from '@aws-lambda-powertools/commons';

private storedMetrics;
/**
* Whether to disable metrics
*/
private disabled;
constructor(options?: MetricsOptions);

@@ -351,2 +355,6 @@ /**

/**
* Whether metrics are disabled.
*/
protected isDisabled(): boolean;
/**
* A class method decorator to automatically log metrics after the method returns or throws an error.

@@ -595,2 +603,8 @@ *

/**
* Set the disbaled flag based on the environment variables `POWERTOOLS_METRICS_DISABLED` and `POWERTOOLS_DEV`.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
private setDisabled;
/**
* Set the options to be used by the Metrics instance.

@@ -597,0 +611,0 @@ *

@@ -166,2 +166,6 @@ import { Console } from 'node:console';

/**
* Whether to disable metrics
*/
disabled = false;
/**
* Custom timestamp for the metrics

@@ -197,2 +201,6 @@ */

}
if (Object.hasOwn(this.dimensions, name) ||
Object.hasOwn(this.defaultDimensions, name)) {
this.#logger.warn(`Dimension "${name}" has already been added. The previous value will be overwritten.`);
}
this.dimensions[name] = value;

@@ -213,16 +221,5 @@ }

addDimensions(dimensions) {
const newDimensions = { ...this.dimensions };
for (const dimensionName of Object.keys(dimensions)) {
const value = dimensions[dimensionName];
if (value) {
newDimensions[dimensionName] = value;
}
else {
this.#logger.warn(`The dimension ${dimensionName} doesn't meet the requirements and won't be added. Ensure the dimension name and value are non empty strings`);
}
for (const [name, value] of Object.entries(dimensions)) {
this.addDimension(name, value);
}
if (Object.keys(newDimensions).length > MAX_DIMENSION_COUNT) {
throw new RangeError(`Unable to add ${Object.keys(dimensions).length} dimensions: the number of metric dimensions must be lower than ${MAX_DIMENSION_COUNT}`);
}
this.dimensions = newDimensions;
}

@@ -422,2 +419,8 @@ /**

/**
* Whether metrics are disabled.
*/
isDisabled() {
return this.disabled;
}
/**
* A class method decorator to automatically log metrics after the method returns or throws an error.

@@ -518,4 +521,6 @@ *

}
const emfOutput = this.serializeMetrics();
hasMetrics && this.console.log(JSON.stringify(emfOutput));
if (!this.disabled) {
const emfOutput = this.serializeMetrics();
hasMetrics && this.console.log(JSON.stringify(emfOutput));
}
this.clearMetrics();

@@ -726,5 +731,5 @@ this.clearDimensions();

*/
throwOnEmptyMetrics() {
/* v8 ignore start */ throwOnEmptyMetrics() {
this.shouldThrowOnEmptyMetrics = true;
}
} /* v8 ignore stop */
/**

@@ -815,2 +820,10 @@ * Gets the current number of dimensions count.

/**
* Set the disbaled flag based on the environment variables `POWERTOOLS_METRICS_DISABLED` and `POWERTOOLS_DEV`.
*
* The `POWERTOOLS_METRICS_DISABLED` environment variable takes precedence over `POWERTOOLS_DEV`.
*/
setDisabled() {
this.disabled = this.getEnvVarsService().getMetricsDisabled();
}
/**
* Set the options to be used by the Metrics instance.

@@ -827,2 +840,3 @@ *

this.setCustomConfigService(customConfigService);
this.setDisabled();
this.setNamespace(namespace);

@@ -829,0 +843,0 @@ this.setService(serviceName);

{
"name": "@aws-lambda-powertools/metrics",
"version": "2.11.0",
"version": "2.12.0",
"description": "The metrics package for the Powertools for AWS Lambda (TypeScript) library",

@@ -27,6 +27,6 @@ "author": {

"dependencies": {
"@aws-lambda-powertools/commons": "^2.11.0"
"@aws-lambda-powertools/commons": "^2.12.0"
},
"peerDependencies": {
"@middy/core": "4.x || 5.x"
"@middy/core": "4.x || 5.x || 6.x"
},

@@ -33,0 +33,0 @@ "peerDependenciesMeta": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc