将其他信息附加到Lambda超时消息吗? [英] Attach additional info to Lambda time-out message?

查看:58
本文介绍了将其他信息附加到Lambda超时消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Lambda超时时,它会向CloudWatch(如果启用)输出一条消息,指出任务超时".

When a Lambda times out, it outputs a message to CloudWatch (if enabled) saying "Task timed out".

将附加信息(例如有问题的通话的上下文)附加到消息将是有益的.现在,我在调用开始时就将上下文写入CloudWatch-但是,如果所有内容都包含在一条消息中,则有时会更可取.

It would be beneficial to attach additional info (such as the context of the offending call) to the message. Right now I'm writing the context to CloudWatch at the start of the invocation - but it would sometimes be preferable if everything was contained within a single message.

有可能吗?

推荐答案

不幸的是,没有几乎超时的挂机.但是,您也许可以检查在Lambda处理程序中获得的上下文对象,以查看剩余的运行时间以及是否接近超时以打印出更多信息.

Unfortunately there is no almost-timed-out-hook. You may however be able to inspect the context object you get in the Lambda handler to look at the remaining run time and if it gets close to timing out printing out the additional info.

在python中,您可以按照

In python you could use context.get_remaining_time_in_millis() as per the documentation to get that info.

这篇关于将其他信息附加到Lambda超时消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆