-
Notifications
You must be signed in to change notification settings - Fork 165
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shipped
Description
Expected Behavior
There should be no warnings when I am not trying to set the metric dimensions myself.
Current Behavior
When we instantiate a Metrics class and call the captureColdStartMetric
method. There are two messages with the message

Code snippet
import { Metrics } from '@aws-lambda-powertools/metrics';
const metrics = new Metrics();
export const lambdaHandler = () => {
metrics.captureColdStartMetric();
return;
};
Steps to Reproduce
- Create a lambda function
- Instantiate a Metrics class without any options
- Invoke the
captureColdStartMetric
method from the Metrics utility in the Lambda function - Invoke the Lambda function
- View the logs from the Lambda function
Possible Solution
The warnings were added as part of #4222. But because thesetDefaultDimensions
is being called in multiple places implicitly when instantiating the class and invoking the captureColdStartMetric
function, the function tries to warn the user about the dimension being overridden.
The setDefaultDimensions
is being called in:
- https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/metrics/src/Metrics.ts#L1116
- https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/metrics/src/Metrics.ts#L1097
- https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/metrics/src/Metrics.ts#L441-L443
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
22.x
Packaging format used
npm, Lambda Layers
Execution logs
Dimension "service" has already been added. The previous value will be overwritten.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shipped
Type
Projects
Status
Shipped