11import type { Callback , Context , Handler } from 'aws-lambda' ;
22import { Utility } from '@aws-lambda-powertools/commons' ;
3- import type { MetricsInterface } from './MetricsInterface' ;
4- import {
5- type ConfigServiceInterface ,
6- EnvironmentVariablesService ,
7- } from './config' ;
3+ import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types' ;
4+ import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js' ;
85import {
96 MAX_DIMENSION_COUNT ,
107 MAX_METRICS_SIZE ,
118 DEFAULT_NAMESPACE ,
129 COLD_START_METRIC ,
1310 MAX_METRIC_VALUES_SIZE ,
14- } from './constants' ;
11+ MetricUnit as MetricUnits ,
12+ MetricResolution as MetricResolutions ,
13+ } from './constants.js' ;
1514import {
16- MetricsOptions ,
17- Dimensions ,
18- EmfOutput ,
19- HandlerMethodDecorator ,
20- StoredMetrics ,
21- ExtraOptions ,
22- MetricUnit ,
23- MetricUnits ,
24- MetricResolution ,
25- MetricDefinition ,
26- } from './types' ;
15+ type MetricsOptions ,
16+ type Dimensions ,
17+ type EmfOutput ,
18+ type StoredMetrics ,
19+ type ExtraOptions ,
20+ type MetricDefinition ,
21+ type ConfigServiceInterface ,
22+ type MetricsInterface ,
23+ type MetricUnit ,
24+ type MetricResolution ,
25+ } from './types/index.js ' ;
2726
2827/**
2928 * ## Intro
@@ -83,7 +82,7 @@ import {
8382 * @metrics .logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
8483 * public handler(_event: any, _context: any): Promise<void> {
8584 * // ...
86- * metrics.addMetric('test-metric', MetricUnits .Count, 10);
85+ * metrics.addMetric('test-metric', MetricUnit .Count, 10);
8786 * // ...
8887 * }
8988 * }
@@ -99,13 +98,13 @@ import {
9998 * @example
10099 *
101100 * ```typescript
102- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
101+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
103102 *
104103 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
105104 *
106105 * export const handler = async (_event: any, _context: any): Promise<void> => {
107106 * metrics.captureColdStartMetric();
108- * metrics.addMetric('test-metric', MetricUnits .Count, 10);
107+ * metrics.addMetric('test-metric', MetricUnit .Count, 10);
109108 * metrics.publishStoredMetrics();
110109 * };
111110 * ```
@@ -188,15 +187,15 @@ class Metrics extends Utility implements MetricsInterface {
188187 * or when calling {@link Metrics.publishStoredMetrics}.
189188 *
190189 * You can add a metric by specifying the metric name, unit, and value. For convenience,
191- * we provide a set of constants for the most common units in {@link MetricUnits }.
190+ * we provide a set of constants for the most common units in {@link MetricUnit }.
192191 *
193192 * @example
194193 * ```typescript
195- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
194+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
196195 *
197196 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
198197 *
199- * metrics.addMetric('successfulBooking', MetricUnits .Count, 1);
198+ * metrics.addMetric('successfulBooking', MetricUnit .Count, 1);
200199 * ```
201200 *
202201 * Optionally, you can specify the metric resolution, which can be either `High` or `Standard`.
@@ -205,11 +204,11 @@ class Metrics extends Utility implements MetricsInterface {
205204 *
206205 * @example
207206 * ```typescript
208- * import { Metrics, MetricUnits , MetricResolution } from '@aws-lambda-powertools/metrics';
207+ * import { Metrics, MetricUnit , MetricResolution } from '@aws-lambda-powertools/metrics';
209208 *
210209 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
211210 *
212- * metrics.addMetric('successfulBooking', MetricUnits .Count, 1, MetricResolution.High);
211+ * metrics.addMetric('successfulBooking', MetricUnit .Count, 1, MetricResolution.High);
213212 * ```
214213 *
215214 * @param name - The metric name
@@ -221,7 +220,7 @@ class Metrics extends Utility implements MetricsInterface {
221220 name : string ,
222221 unit : MetricUnit ,
223222 value : number ,
224- resolution : MetricResolution = MetricResolution . Standard
223+ resolution : MetricResolution = MetricResolutions . Standard
225224 ) : void {
226225 this . storeMetric ( name , unit , value , resolution ) ;
227226 if ( this . isSingleMetric ) this . publishStoredMetrics ( ) ;
@@ -369,12 +368,12 @@ class Metrics extends Utility implements MetricsInterface {
369368 * @example
370369 *
371370 * ```typescript
372- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
371+ * import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
373372 *
374373 * const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); // Sets metric namespace, and service as a metric dimension
375374 *
376375 * export const handler = async (_event: any, _context: any): Promise<void> => {
377- * metrics.addMetric('test-metric', MetricUnits .Count, 10);
376+ * metrics.addMetric('test-metric', MetricUnit .Count, 10);
378377 * metrics.publishStoredMetrics();
379378 * };
380379 * ```
@@ -413,7 +412,7 @@ class Metrics extends Utility implements MetricsInterface {
413412 ) . map ( ( metricDefinition ) => ( {
414413 Name : metricDefinition . name ,
415414 Unit : metricDefinition . unit ,
416- ...( metricDefinition . resolution === MetricResolution . High
415+ ...( metricDefinition . resolution === MetricResolutions . High
417416 ? { StorageResolution : metricDefinition . resolution }
418417 : { } ) ,
419418 } ) ) ;
@@ -499,7 +498,7 @@ class Metrics extends Utility implements MetricsInterface {
499498 * ```typescript
500499 * const singleMetric = metrics.singleMetric();
501500 * singleMetric.addDimension('InnerDimension', 'true');
502- * singleMetric.addMetric('single-metric', MetricUnits .Percent, 50);
501+ * singleMetric.addMetric('single-metric', MetricUnit .Percent, 50);
503502 * ```
504503 *
505504 * @returns the Metrics
@@ -706,4 +705,4 @@ class Metrics extends Utility implements MetricsInterface {
706705 }
707706}
708707
709- export { Metrics , MetricUnits , MetricResolution } ;
708+ export { Metrics } ;
0 commit comments