-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippeddocumentationImprovements or additions to documentationImprovements or additions to documentationmetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utilitynot-a-bugNew and existing bug reports incorrectly submitted as bugNew and existing bug reports incorrectly submitted as bug
Description
Expected Behavior
const metrics = new Metrics({
namespace: 'cci',
})
const lambdaHandler = async (
_event: unknown,
_context: unknown
): Promise<void> => {
const taskTotal = metrics.singleMetric()
taskTotal.addMetadata("caseId", caseId)
taskTotal.addMetric("deleteme-taskTotal", MetricUnit.Count, 1)
}
Works as expected however, doing instead the other way around:
taskTotal.addMetric("deleteme-taskTotal", MetricUnit.Count, 1)
taskTotal.addMetadata("caseId", caseId)
Seems to result in no metadata being appended to the EMF cloudwatch log.
This is confusing because the documentation example shows addMetadata() being called after addMetadata https://docs.powertools.aws.dev/lambda/typescript/latest/core/metrics/#adding-metadata
Current Behavior
taskTotal.addMetric("deleteme-taskTotal", MetricUnit.Count, 1)
taskTotal.addMetadata("caseId", caseId)
Does not add metadata to the cloudwatch log
Code snippet
taskTotal.addMetric("deleteme-taskTotal", MetricUnit.Count, 1)
taskTotal.addMetadata("caseId", caseId)
Steps to Reproduce
"@aws-lambda-powertools/logger": "^2.8.0",
"@aws-lambda-powertools/metrics": "^2.8.0",
Possible Solution
I'd suggest either updating docs to specify explicitly the order required, or making it work in either order
Powertools for AWS Lambda (TypeScript) version
2.8.0
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
No response
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippeddocumentationImprovements or additions to documentationImprovements or additions to documentationmetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utilitynot-a-bugNew and existing bug reports incorrectly submitted as bugNew and existing bug reports incorrectly submitted as bug
Type
Projects
Status
Shipped