Skip to content

Commit

Permalink
Address PR comments on README update
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-aws-uk committed Jan 14, 2022
1 parent de85af3 commit bd217ef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions examples/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

This is a deployable CDK app that deploys AWS Lambda functions as part of a CloudFormation stack. These Lambda functions use the utilities made available as part of AWS Lambda Powertools (TypeScript) to demonstrate their usage.

The example functions, located in the `lib` folder, are triggered automatically when deployed using the CDK construct defined in `lib/example-function.ts`.
You will need to have a valid AWS Account in order to deploy these resources. These resources may incur costs to your AWS Account.

The example functions, located in the `lib` folder, are invoked automatically, twice, when deployed using the CDK construct defined in `lib/example-function.ts`. The first invocation demonstrates the effect on logs/metrics/annotations when the Lambda function has a cold start, and the latter without a cold start.

## Deploying the stack

* Ensure that CDK v2 is installed globally on your machine (if not, run `npm install -g aws-cdk`)
* Navigate to this location of the repo in your terminal (`examples/cdk`)
* `npm install`
* `npx cdk deploy --all --profile <YOUR_AWS_PROFILE>`
* `cdk deploy --all --profile <YOUR_AWS_PROFILE>`

Note: Prior to deploying you may need to run `npx cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.
Note: Prior to deploying you may need to run `cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.

## Viewing Utility Outputs

All utility outputs can be viewed from the CloudWatch console.
All utility outputs can be viewed in the Amazon CloudWatch console.

* `Logger` outputs to Logs > Log groups
* `Metrics` outputs to Metrics > All metrics > LambdaPowertoolsTypeScript-CDKExample
* `Tracer` outputs to X-Ray traces > Traces
* `Logger` output can be found in Logs > Log groups
* `Metrics` output can be found in Metrics > All metrics > CdkExample
* `Tracer` output can be found in X-Ray traces > Traces
4 changes: 2 additions & 2 deletions packages/metrics/src/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Metrics implements MetricsInterface {
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
* import { Callback, Context } from 'aws-lambda';
*
* const metrics = new Metrics({namespace:"LambdaPowertoolsTypeScript-CDKExample", serviceName:"withDecorator"});
* const metrics = new Metrics({namespace:"CdkExample", serviceName:"withDecorator"});
*
* export class MyFunctionWithDecorator {
*
Expand Down Expand Up @@ -267,7 +267,7 @@ class Metrics implements MetricsInterface {
* ```typescript
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
*
* const metrics = new Metrics({namespace: "LambdaPowertoolsTypeScript-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) => {
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/metrics/tests/e2e/decorator.test.MyFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metrics, MetricUnits } from '../../src';
import { Context } from 'aws-lambda';
import { LambdaInterface } from '../../examples/utils/lambda/LambdaInterface';

const namespace = process.env.EXPECTED_NAMESPACE ?? 'LambdaPowertoolsTypeScript-CDKExample';
const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample';
const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandardHandler';
const metricName = process.env.EXPECTED_METRIC_NAME ?? 'MyMetric';
const metricUnit = (process.env.EXPECTED_METRIC_UNIT as MetricUnits) ?? MetricUnits.Count;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metrics, MetricUnits } from '../../src';
import { Context } from 'aws-lambda';

const namespace = process.env.EXPECTED_NAMESPACE ?? 'LambdaPowertoolsTypeScript-CDKExample';
const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample';
const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandardHandler';
const metricName = process.env.EXPECTED_METRIC_NAME ?? 'MyMetric';
const metricUnit = (process.env.EXPECTED_METRIC_UNIT as MetricUnits) ?? MetricUnits.Count;
Expand Down

0 comments on commit bd217ef

Please sign in to comment.