Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): Fix linting issue and add linting to the pre-push hook #440

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lerna-lint
npm run test
42 changes: 21 additions & 21 deletions packages/metrics/src/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,27 +281,6 @@ class Metrics implements MetricsInterface {
this.storedMetrics = {};
}

/**
* Throw an Error if the metrics buffer is empty.
*
* @example
*
* ```typescript
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
* import { Context } from 'aws-lambda';
*
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
*
* export const handler = async (event: any, context: Context) => {
* metrics.throwOnEmptyMetrics();
* metrics.publishStoredMetrics(); // will throw since no metrics added.
* }
* ```
*/
public throwOnEmptyMetrics(): void {
this.shouldThrowOnEmptyMetrics = true;
}

/**
* Function to create the right object compliant with Cloudwatch EMF (Event Metric Format).
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html for more details
Expand Down Expand Up @@ -386,6 +365,27 @@ class Metrics implements MetricsInterface {
});
}

/**
* Throw an Error if the metrics buffer is empty.
*
* @example
*
* ```typescript
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
* import { Context } from 'aws-lambda';
*
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
*
* export const handler = async (event: any, context: Context) => {
* metrics.throwOnEmptyMetrics();
* metrics.publishStoredMetrics(); // will throw since no metrics added.
* }
* ```
*/
public throwOnEmptyMetrics(): void {
this.shouldThrowOnEmptyMetrics = true;
}

private getCurrentDimensionsCount(): number {
return Object.keys(this.dimensions).length + Object.keys(this.defaultDimensions).length;
}
Expand Down