@@ -43,22 +43,22 @@ const DEFAULT_NAMESPACE = 'default_namespace';
43
43
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
44
44
* import { Callback, Context } from 'aws-lambda';
45
45
*
46
- * const metrics = new Metrics({namespace:" MyService" , serviceName:" withDecorator" });
46
+ * const metrics = new Metrics({ namespace:' MyService' , serviceName:' withDecorator' });
47
47
*
48
48
* export class MyFunctionWithDecorator {
49
49
*
50
50
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/39371 and might show as *@metrics * instead of `@metrics.logMetrics`
51
51
*
52
- * @metrics .logMetrics({captureColdStartMetric: true, throwOnEmptyMetrics: true, })
53
- * public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any > {
52
+ * @metrics .logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
53
+ * public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<void > {
54
54
* // ...
55
55
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
56
56
* // ...
57
57
* }
58
58
* }
59
59
*
60
- * export const handlerClass = new MyFunctionWithDecorator()
61
- * export const handler = handlerClass.handler
60
+ * export const handlerClass = new MyFunctionWithDecorator();
61
+ * export const handler = handlerClass.handler;
62
62
* ```
63
63
*
64
64
* ### Standard function
@@ -70,10 +70,10 @@ const DEFAULT_NAMESPACE = 'default_namespace';
70
70
* ```typescript
71
71
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
72
72
*
73
- * const metrics = new Metrics({namespace: " MyService" , serviceName: " MyFunction" });
73
+ * const metrics = new Metrics({ namespace: ' MyService' , serviceName: ' MyFunction' });
74
74
*
75
- * export const handler = async (_event: any, _context: any) => {
76
- * metrics.captureColdStart ();
75
+ * export const handler = async (_event: any, _context: any): Promise<void> => {
76
+ * metrics.captureColdStartMetric ();
77
77
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
78
78
* metrics.publishStoredMetrics();
79
79
* };
@@ -161,14 +161,14 @@ class Metrics implements MetricsInterface {
161
161
* @example
162
162
*
163
163
* ```typescript
164
- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
164
+ * import { Metrics } from '@aws-lambda-powertools/metrics';
165
165
* import { Context } from 'aws-lambda';
166
166
*
167
- * const metrics = new Metrics({namespace:" serverlessAirline" , serviceName:" orders" });
167
+ * const metrics = new Metrics({ namespace:' serverlessAirline' , serviceName:' orders' });
168
168
*
169
- * export const handler = async (event: any, context: Context) => {
169
+ * export const handler = async (event: any, context: Context): Promise<void> => {
170
170
* metrics.captureColdStartMetric();
171
- * }
171
+ * };
172
172
* ```
173
173
*/
174
174
public captureColdStartMetric ( ) : void {
@@ -207,21 +207,21 @@ class Metrics implements MetricsInterface {
207
207
* @example
208
208
*
209
209
* ```typescript
210
- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
210
+ * import { Metrics } from '@aws-lambda-powertools/metrics';
211
211
* import { Callback, Context } from 'aws-lambda';
212
212
*
213
- * const metrics = new Metrics({namespace:" CdkExample" , serviceName:" withDecorator" });
213
+ * const metrics = new Metrics({ namespace:' CdkExample' , serviceName:' withDecorator' });
214
214
*
215
215
* export class MyFunctionWithDecorator {
216
216
*
217
- * @metrics .logMetrics({captureColdStartMetric: true})
217
+ * @metrics .logMetrics({ captureColdStartMetric: true })
218
218
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> {
219
219
* // ...
220
220
* }
221
221
* }
222
222
*
223
- * export const handlerClass = new MyFunctionWithDecorator()
224
- * export const handler = handlerClass.handler
223
+ * export const handlerClass = new MyFunctionWithDecorator();
224
+ * export const handler = handlerClass.handler;
225
225
* ```
226
226
*
227
227
* @decorator Class
@@ -267,9 +267,9 @@ class Metrics implements MetricsInterface {
267
267
* ```typescript
268
268
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
269
269
*
270
- * const metrics = new Metrics({namespace: " CdkExample" , serviceName: " MyFunction" }); // Sets metric namespace, and service as a metric dimension
270
+ * const metrics = new Metrics({ namespace: ' CdkExample' , serviceName: ' MyFunction' }); // Sets metric namespace, and service as a metric dimension
271
271
*
272
- * export const handler = async (_event: any, _context: any) => {
272
+ * export const handler = async (_event: any, _context: any): Promise<void> => {
273
273
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
274
274
* metrics.publishStoredMetrics();
275
275
* };
@@ -371,15 +371,15 @@ class Metrics implements MetricsInterface {
371
371
* @example
372
372
*
373
373
* ```typescript
374
- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
374
+ * import { Metrics } from '@aws-lambda-powertools/metrics';
375
375
* import { Context } from 'aws-lambda';
376
376
*
377
- * const metrics = new Metrics({namespace:" serverlessAirline" , serviceName:" orders" });
377
+ * const metrics = new Metrics({ namespace:' serverlessAirline' , serviceName:' orders' });
378
378
*
379
- * export const handler = async (event: any, context: Context) => {
379
+ * export const handler = async (event: any, context: Context): Promise<void> => {
380
380
* metrics.throwOnEmptyMetrics();
381
381
* metrics.publishStoredMetrics(); // will throw since no metrics added.
382
- * }
382
+ * };
383
383
* ```
384
384
*/
385
385
public throwOnEmptyMetrics ( ) : void {
0 commit comments