Skip to content

Allow logger.metric to include additional context in it's payload

My team recently moved our stack from Lambda to Fargate. Lambda would enrich all logs from the same request with an @requestId field. Fargate does not do the same. Instead, we need to manually pass our requestId to our logs to ensure that we can easily query Cloudwatch to find our logs with from the same request.

Unfortunately, since logger.metric uses the MetricData type, we are not able to add a requestId field to the log statement.

For the other logger functions, we include this as a field under the payload. It would be nice if we could do the same thing here.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information