11import type { Callback , Context , Handler } from 'aws-lambda' ;
22import { Console } from 'node:console' ;
33import { Utility } from '@aws-lambda-powertools/commons' ;
4- import type { MetricsInterface } from './MetricsInterface' ;
5- import {
6- type ConfigServiceInterface ,
7- EnvironmentVariablesService ,
8- } from './config' ;
4+ import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types' ;
5+ import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js' ;
96import {
107 MAX_DIMENSION_COUNT ,
118 MAX_METRICS_SIZE ,
129 DEFAULT_NAMESPACE ,
1310 COLD_START_METRIC ,
1411 MAX_METRIC_VALUES_SIZE ,
15- } from './constants' ;
12+ MetricUnit as MetricUnits ,
13+ MetricResolution as MetricResolutions ,
14+ } from './constants.js' ;
1615import {
17- MetricsOptions ,
18- Dimensions ,
19- EmfOutput ,
20- HandlerMethodDecorator ,
21- StoredMetrics ,
22- ExtraOptions ,
23- MetricUnit ,
24- MetricUnits ,
25- MetricResolution ,
26- MetricDefinition ,
27- } from './types' ;
16+ type MetricsOptions ,
17+ type Dimensions ,
18+ type EmfOutput ,
19+ type StoredMetrics ,
20+ type ExtraOptions ,
21+ type MetricDefinition ,
22+ type ConfigServiceInterface ,
23+ type MetricsInterface ,
24+ type MetricUnit ,
25+ type MetricResolution ,
26+ } from './types/index.js ' ;
2827
2928/**
3029 * ## Intro
@@ -82,7 +81,7 @@ import {
8281 * @metrics .logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
8382 * public handler(_event: unknown, _context: unknown): Promise<void> {
8483 * // ...
85- * metrics.addMetric('test-metric', MetricUnits .Count, 10);
84+ * metrics.addMetric('test-metric', MetricUnit .Count, 10);
8685 * // ...
8786 * }
8887 * }
@@ -98,13 +97,13 @@ import {
9897 * @example
9998 *
10099 * ```typescript
101- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
100+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
102101 *
103102 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
104103 *
105104 * export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
106105 * metrics.captureColdStartMetric();
107- * metrics.addMetric('test-metric', MetricUnits .Count, 10);
106+ * metrics.addMetric('test-metric', MetricUnit .Count, 10);
108107 * metrics.publishStoredMetrics();
109108 * };
110109 * ```
@@ -199,15 +198,15 @@ class Metrics extends Utility implements MetricsInterface {
199198 * or when calling {@link Metrics.publishStoredMetrics}.
200199 *
201200 * You can add a metric by specifying the metric name, unit, and value. For convenience,
202- * we provide a set of constants for the most common units in {@link MetricUnits }.
201+ * we provide a set of constants for the most common units in {@link MetricUnit }.
203202 *
204203 * @example
205204 * ```typescript
206- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
205+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
207206 *
208207 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
209208 *
210- * metrics.addMetric('successfulBooking', MetricUnits .Count, 1);
209+ * metrics.addMetric('successfulBooking', MetricUnit .Count, 1);
211210 * ```
212211 *
213212 * Optionally, you can specify the metric resolution, which can be either `High` or `Standard`.
@@ -216,11 +215,11 @@ class Metrics extends Utility implements MetricsInterface {
216215 *
217216 * @example
218217 * ```typescript
219- * import { Metrics, MetricUnits , MetricResolution } from '@aws-lambda-powertools/metrics';
218+ * import { Metrics, MetricUnit , MetricResolution } from '@aws-lambda-powertools/metrics';
220219 *
221220 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
222221 *
223- * metrics.addMetric('successfulBooking', MetricUnits .Count, 1, MetricResolution.High);
222+ * metrics.addMetric('successfulBooking', MetricUnit .Count, 1, MetricResolution.High);
224223 * ```
225224 *
226225 * @param name - The metric name
@@ -232,7 +231,7 @@ class Metrics extends Utility implements MetricsInterface {
232231 name : string ,
233232 unit : MetricUnit ,
234233 value : number ,
235- resolution : MetricResolution = MetricResolution . Standard
234+ resolution : MetricResolution = MetricResolutions . Standard
236235 ) : void {
237236 this . storeMetric ( name , unit , value , resolution ) ;
238237 if ( this . isSingleMetric ) this . publishStoredMetrics ( ) ;
@@ -380,7 +379,7 @@ class Metrics extends Utility implements MetricsInterface {
380379 * @example
381380 *
382381 * ```typescript
383- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
382+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
384383 *
385384 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); // Sets metric namespace, and service as a metric dimension
386385 *
@@ -424,7 +423,7 @@ class Metrics extends Utility implements MetricsInterface {
424423 ) . map ( ( metricDefinition ) => ( {
425424 Name : metricDefinition . name ,
426425 Unit : metricDefinition . unit ,
427- ...( metricDefinition . resolution === MetricResolution . High
426+ ...( metricDefinition . resolution === MetricResolutions . High
428427 ? { StorageResolution : metricDefinition . resolution }
429428 : { } ) ,
430429 } ) ) ;
@@ -512,7 +511,7 @@ class Metrics extends Utility implements MetricsInterface {
512511 * ```typescript
513512 * const singleMetric = metrics.singleMetric();
514513 * singleMetric.addDimension('InnerDimension', 'true');
515- * singleMetric.addMetric('single-metric', MetricUnits .Percent, 50);
514+ * singleMetric.addMetric('single-metric', MetricUnit .Percent, 50);
516515 * ```
517516 *
518517 * @returns the Metrics
@@ -738,4 +737,4 @@ class Metrics extends Utility implements MetricsInterface {
738737 }
739738}
740739
741- export { Metrics , MetricUnits , MetricResolution } ;
740+ export { Metrics } ;
0 commit comments