-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(metrics): extract Metrics code snippets in separate files (#1245)
* docs(metrics): extract Metrics code snippets in separate files #1221 * fix(docs): hl_lines of multiValueMetrics code snippet
- Loading branch information
1 parent
439c794
commit 86d31c3
Showing
19 changed files
with
231 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics'; | ||
import middy from '@middy/core'; | ||
|
||
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); | ||
|
||
const lambdaHandler = async (_event: any, _context: any): Promise<void> => { | ||
metrics.addMetric('successfulBooking', MetricUnits.Count, 1); | ||
metrics.addMetadata('bookingId', '7051cd10-6283-11ec-90d6-0242ac120003'); | ||
}; | ||
|
||
export const handler = middy(lambdaHandler) | ||
.use(logMetrics(metrics)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Metrics } from '@aws-lambda-powertools/metrics'; | ||
|
||
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); | ||
|
||
export const handler = async (_event, _context): Promise<void> => { | ||
// ... | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'; | ||
import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
|
||
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); | ||
|
||
export class MyFunction implements LambdaInterface { | ||
|
||
@metrics.logMetrics({ captureColdStartMetric: true }) | ||
public async handler(_event: any, _context: any): Promise<void> { | ||
metrics.addMetric('successfulBooking', MetricUnits.Count, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics'; | ||
import middy from '@middy/core'; | ||
|
||
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); | ||
|
||
const lambdaHandler = async (_event: any, _context: any): Promise<void> => { | ||
metrics.addMetric('successfulBooking', MetricUnits.Count, 1); | ||
}; | ||
|
||
export const handler = middy(lambdaHandler) | ||
.use(logMetrics(metrics, { captureColdStartMetric: true })); |
Oops, something went wrong.