@aws-lambda-powertools/metrics
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -30,3 +30,3 @@ import { MetricsInterface } from '.'; | ||
* | ||
* const metrics = new Metrics({namespace:"MyService", serviceName:"withDecorator"}); | ||
* const metrics = new Metrics({ namespace:'MyService', serviceName:'withDecorator' }); | ||
* | ||
@@ -37,4 +37,4 @@ * export class MyFunctionWithDecorator { | ||
* | ||
* @metrics.logMetrics({captureColdStartMetric: true, throwOnEmptyMetrics: true, }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> { | ||
* @metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<void> { | ||
* // ... | ||
@@ -46,4 +46,4 @@ * metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
* | ||
* export const handlerClass = new MyFunctionWithDecorator() | ||
* export const handler = handlerClass.handler | ||
* export const handlerClass = new MyFunctionWithDecorator(); | ||
* export const handler = handlerClass.handler; | ||
* ``` | ||
@@ -60,6 +60,6 @@ * | ||
* | ||
* const metrics = new Metrics({namespace: "MyService", serviceName: "MyFunction"}); | ||
* const metrics = new Metrics({ namespace: 'MyService', serviceName: 'MyFunction' }); | ||
* | ||
* export const handler = async (_event: any, _context: any) => { | ||
* metrics.captureColdStart(); | ||
* export const handler = async (_event: any, _context: any): Promise<void> => { | ||
* metrics.captureColdStartMetric(); | ||
* metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
@@ -122,10 +122,10 @@ * metrics.publishStoredMetrics(); | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"}); | ||
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' }); | ||
* | ||
* export const handler = async (event: any, context: Context) => { | ||
* export const handler = async (event: any, context: Context): Promise<void> => { | ||
* metrics.captureColdStartMetric(); | ||
* } | ||
* }; | ||
* ``` | ||
@@ -144,10 +144,10 @@ */ | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Callback, Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"CdkExample", serviceName:"withDecorator"}); | ||
* const metrics = new Metrics({ namespace:'CdkExample', serviceName:'withDecorator' }); | ||
* | ||
* export class MyFunctionWithDecorator { | ||
* | ||
* @metrics.logMetrics({captureColdStartMetric: true}) | ||
* @metrics.logMetrics({ captureColdStartMetric: true }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> { | ||
@@ -158,4 +158,4 @@ * // ... | ||
* | ||
* export const handlerClass = new MyFunctionWithDecorator() | ||
* export const handler = handlerClass.handler | ||
* export const handlerClass = new MyFunctionWithDecorator(); | ||
* export const handler = handlerClass.handler; | ||
* ``` | ||
@@ -175,5 +175,5 @@ * | ||
* | ||
* const metrics = new Metrics({namespace: "CdkExample", serviceName: "MyFunction"}); // Sets metric namespace, and service as a metric dimension | ||
* const metrics = new Metrics({ namespace: 'CdkExample', serviceName: 'MyFunction' }); // Sets metric namespace, and service as a metric dimension | ||
* | ||
* export const handler = async (_event: any, _context: any) => { | ||
* export const handler = async (_event: any, _context: any): Promise<void> => { | ||
* metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
@@ -215,11 +215,11 @@ * metrics.publishStoredMetrics(); | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"}); | ||
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' }); | ||
* | ||
* export const handler = async (event: any, context: Context) => { | ||
* export const handler = async (event: any, context: Context): Promise<void> => { | ||
* metrics.throwOnEmptyMetrics(); | ||
* metrics.publishStoredMetrics(); // will throw since no metrics added. | ||
* } | ||
* }; | ||
* ``` | ||
@@ -226,0 +226,0 @@ */ |
@@ -37,3 +37,3 @@ "use strict"; | ||
* | ||
* const metrics = new Metrics({namespace:"MyService", serviceName:"withDecorator"}); | ||
* const metrics = new Metrics({ namespace:'MyService', serviceName:'withDecorator' }); | ||
* | ||
@@ -44,4 +44,4 @@ * export class MyFunctionWithDecorator { | ||
* | ||
* @metrics.logMetrics({captureColdStartMetric: true, throwOnEmptyMetrics: true, }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> { | ||
* @metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<void> { | ||
* // ... | ||
@@ -53,4 +53,4 @@ * metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
* | ||
* export const handlerClass = new MyFunctionWithDecorator() | ||
* export const handler = handlerClass.handler | ||
* export const handlerClass = new MyFunctionWithDecorator(); | ||
* export const handler = handlerClass.handler; | ||
* ``` | ||
@@ -67,6 +67,6 @@ * | ||
* | ||
* const metrics = new Metrics({namespace: "MyService", serviceName: "MyFunction"}); | ||
* const metrics = new Metrics({ namespace: 'MyService', serviceName: 'MyFunction' }); | ||
* | ||
* export const handler = async (_event: any, _context: any) => { | ||
* metrics.captureColdStart(); | ||
* export const handler = async (_event: any, _context: any): Promise<void> => { | ||
* metrics.captureColdStartMetric(); | ||
* metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
@@ -146,10 +146,10 @@ * metrics.publishStoredMetrics(); | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"}); | ||
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' }); | ||
* | ||
* export const handler = async (event: any, context: Context) => { | ||
* export const handler = async (event: any, context: Context): Promise<void> => { | ||
* metrics.captureColdStartMetric(); | ||
* } | ||
* }; | ||
* ``` | ||
@@ -188,10 +188,10 @@ */ | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Callback, Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"CdkExample", serviceName:"withDecorator"}); | ||
* const metrics = new Metrics({ namespace:'CdkExample', serviceName:'withDecorator' }); | ||
* | ||
* export class MyFunctionWithDecorator { | ||
* | ||
* @metrics.logMetrics({captureColdStartMetric: true}) | ||
* @metrics.logMetrics({ captureColdStartMetric: true }) | ||
* public handler(_event: any, _context: Context, _callback: Callback<any>): void | Promise<any> { | ||
@@ -202,4 +202,4 @@ * // ... | ||
* | ||
* export const handlerClass = new MyFunctionWithDecorator() | ||
* export const handler = handlerClass.handler | ||
* export const handlerClass = new MyFunctionWithDecorator(); | ||
* export const handler = handlerClass.handler; | ||
* ``` | ||
@@ -247,5 +247,5 @@ * | ||
* | ||
* const metrics = new Metrics({namespace: "CdkExample", serviceName: "MyFunction"}); // Sets metric namespace, and service as a metric dimension | ||
* const metrics = new Metrics({ namespace: 'CdkExample', serviceName: 'MyFunction' }); // Sets metric namespace, and service as a metric dimension | ||
* | ||
* export const handler = async (_event: any, _context: any) => { | ||
* export const handler = async (_event: any, _context: any): Promise<void> => { | ||
* metrics.addMetric('test-metric', MetricUnits.Count, 10); | ||
@@ -340,11 +340,11 @@ * metrics.publishStoredMetrics(); | ||
* ```typescript | ||
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
* import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
* import { Context } from 'aws-lambda'; | ||
* | ||
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"}); | ||
* const metrics = new Metrics({ namespace:'serverlessAirline', serviceName:'orders' }); | ||
* | ||
* export const handler = async (event: any, context: Context) => { | ||
* export const handler = async (event: any, context: Context): Promise<void> => { | ||
* metrics.throwOnEmptyMetrics(); | ||
* metrics.publishStoredMetrics(); // will throw since no metrics added. | ||
* } | ||
* }; | ||
* ``` | ||
@@ -351,0 +351,0 @@ */ |
{ | ||
"name": "@aws-lambda-powertools/metrics", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "The metrics package for the AWS Lambda powertools (TypeScript) library", | ||
@@ -90,3 +90,3 @@ "author": { | ||
}, | ||
"gitHead": "74310456754ce9ce92afba9b80082ffed606f14e" | ||
"gitHead": "1b8d963974e9ccc5994148a44410a6e0cfe3f4ba" | ||
} |
71035