Skip to content

Commit 2943e51

Browse files
author
Michael Brewer
committed
fix(metrics): correct typedoc examples
1 parent ae6fb28 commit 2943e51

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

packages/metrics/src/Metrics.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ const DEFAULT_NAMESPACE = 'default_namespace';
4343
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
4444
* import { Callback, Context } from 'aws-lambda';
4545
*
46-
* const metrics = new Metrics({namespace:"MyService", serviceName:"withDecorator"});
46+
* const metrics = new Metrics({ namespace:'MyService', serviceName:'withDecorator' });
4747
*
4848
* export class MyFunctionWithDecorator {
4949
*
5050
* // 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`
5151
*
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> {
5454
* // ...
5555
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
5656
* // ...
5757
* }
5858
* }
5959
*
60-
* export const handlerClass = new MyFunctionWithDecorator()
61-
* export const handler = handlerClass.handler
60+
* export const handlerClass = new MyFunctionWithDecorator();
61+
* export const handler = handlerClass.handler;
6262
* ```
6363
*
6464
* ### Standard function
@@ -70,10 +70,10 @@ const DEFAULT_NAMESPACE = 'default_namespace';
7070
* ```typescript
7171
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
7272
*
73-
* const metrics = new Metrics({namespace: "MyService", serviceName: "MyFunction"});
73+
* const metrics = new Metrics({ namespace: 'MyService', serviceName: 'MyFunction' });
7474
*
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();
7777
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
7878
* metrics.publishStoredMetrics();
7979
* };
@@ -161,14 +161,14 @@ class Metrics implements MetricsInterface {
161161
* @example
162162
*
163163
* ```typescript
164-
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
164+
* import { Metrics } from '@aws-lambda-powertools/metrics';
165165
* import { Context } from 'aws-lambda';
166166
*
167-
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
167+
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' });
168168
*
169-
* export const handler = async (event: any, context: Context) => {
169+
* export const handler = async (event: any, context: Context): Promise<void> => {
170170
* metrics.captureColdStartMetric();
171-
* }
171+
* };
172172
* ```
173173
*/
174174
public captureColdStartMetric(): void {
@@ -207,21 +207,21 @@ class Metrics implements MetricsInterface {
207207
* @example
208208
*
209209
* ```typescript
210-
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
210+
* import { Metrics } from '@aws-lambda-powertools/metrics';
211211
* import { Callback, Context } from 'aws-lambda';
212212
*
213-
* const metrics = new Metrics({namespace:"CdkExample", serviceName:"withDecorator"});
213+
* const metrics = new Metrics({ namespace:'CdkExample', serviceName:'withDecorator' });
214214
*
215215
* export class MyFunctionWithDecorator {
216216
*
217-
* @metrics.logMetrics({captureColdStartMetric: true})
217+
* @metrics.logMetrics({ captureColdStartMetric: true })
218218
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> {
219219
* // ...
220220
* }
221221
* }
222222
*
223-
* export const handlerClass = new MyFunctionWithDecorator()
224-
* export const handler = handlerClass.handler
223+
* export const handlerClass = new MyFunctionWithDecorator();
224+
* export const handler = handlerClass.handler;
225225
* ```
226226
*
227227
* @decorator Class
@@ -267,9 +267,9 @@ class Metrics implements MetricsInterface {
267267
* ```typescript
268268
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
269269
*
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
271271
*
272-
* export const handler = async (_event: any, _context: any) => {
272+
* export const handler = async (_event: any, _context: any): Promise<void> => {
273273
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
274274
* metrics.publishStoredMetrics();
275275
* };
@@ -371,15 +371,15 @@ class Metrics implements MetricsInterface {
371371
* @example
372372
*
373373
* ```typescript
374-
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
374+
* import { Metrics } from '@aws-lambda-powertools/metrics';
375375
* import { Context } from 'aws-lambda';
376376
*
377-
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
377+
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' });
378378
*
379-
* export const handler = async (event: any, context: Context) => {
379+
* export const handler = async (event: any, context: Context): Promise<void> => {
380380
* metrics.throwOnEmptyMetrics();
381381
* metrics.publishStoredMetrics(); // will throw since no metrics added.
382-
* }
382+
* };
383383
* ```
384384
*/
385385
public throwOnEmptyMetrics(): void {

typedoc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
22
out: 'api',
3-
exclude: ['**/node_modules/**', '**/*.test.ts', '**/*.json'],
3+
exclude: [ '**/node_modules/**', '**/*.test.ts', '**/*.json' ],
44
name: 'aws-lambda-powertools-typescript',
55
excludePrivate: true,
66
entryPointStrategy: 'packages',
7-
readme: "./README.md",
7+
readme: './README.md',
88
};

0 commit comments

Comments
 (0)