Skip to content

Commit e0119ba

Browse files
committed
feat: adopted Utility class
1 parent 313596c commit e0119ba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: packages/metrics/src/Metrics.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Callback, Context } from 'aws-lambda';
2+
import { Utility } from '@aws-lambda-powertools/commons';
23
import { MetricsInterface } from '.';
34
import { ConfigServiceInterface, EnvironmentVariablesService } from './config';
45
import {
@@ -79,20 +80,21 @@ const DEFAULT_NAMESPACE = 'default_namespace';
7980
* };
8081
* ```
8182
*/
82-
class Metrics implements MetricsInterface {
83+
class Metrics extends Utility implements MetricsInterface {
8384
private customConfigService?: ConfigServiceInterface;
8485
private defaultDimensions: Dimensions = {};
8586
private dimensions: Dimensions = {};
8687
private envVarsService?: EnvironmentVariablesService;
8788
private functionName?: string;
88-
private isColdStart: boolean = true;
8989
private isSingleMetric: boolean = false;
9090
private metadata: { [key: string]: string } = {};
9191
private namespace?: string;
9292
private shouldThrowOnEmptyMetrics: boolean = false;
9393
private storedMetrics: StoredMetrics = {};
9494

9595
public constructor(options: MetricsOptions = {}) {
96+
super();
97+
9698
this.dimensions = {};
9799
this.setOptions(options);
98100
}
@@ -172,8 +174,7 @@ class Metrics implements MetricsInterface {
172174
* ```
173175
*/
174176
public captureColdStartMetric(): void {
175-
if (!this.isColdStart) return;
176-
this.isColdStart = false;
177+
if (!this.isColdStart()) return;
177178
const singleMetric = this.singleMetric();
178179

179180
if (this.dimensions.service) {

0 commit comments

Comments
 (0)