如何唯一标识运行我的函数的AWS Lambda容器? [英] How can I uniquely ID the AWS Lambda container that my function is running in?
问题描述
我想获取我的函数正在其中运行的(AWS Lambda容器)实例ID.
I would like to get the (AWS Lambda container) instance ID that my function is running in.
现在我只记录它-在调试缓存算法问题时对我有帮助:我可以确定在同一实例中发生了哪些调用.
For now I would just log it - it would help me when debugging issues with my caching algorithm: I could identify which invocations were happening in the same instance.
我查看了上下文文档对象并且在那里什么也看不到.
I looked at the docs for the context object and don't see anything there.
我可以手动完成操作-并将其作为我的后备答案-但我想我会检查某种实际实例ID是否可用.
I could do it manually - and I'll put that below as my fallback answer - but I thought I would check whether some sort of real instance ID is available somehow.
推荐答案
可以仅生成一个随机GUID,并将其保存在全局文件中. (我只是开始研究这个容器重用的问题以及数据缓存的潜力,但是我假设当实例被重用时,节点的全局"对象保持不变.)
Could just generate a random GUID save that in global. (I'm just starting to look at this issue of container re-use and the potential for data caching, but I assume that node's 'global' object remains intact when an instance is re-used.)
这篇关于如何唯一标识运行我的函数的AWS Lambda容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!