slackapi / slackapi/bolt-python

AWS Lambda Adapter: Expose aws_request_id and log_stream_name in SlackRequestHandler context

未关闭
#1,035 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

area:adapter enhancement
主要语言
Python
星标
1.3k
派生
288
平均合并
1 天 8 小时
30 天内合并 PR
10

描述

I would like to add two parameters from the AWS Lambda context into the BoltRequest context in AWS :

  • aws_request_id
  • log_stream_name

These parameters are useful for manual logging and are accessible directly from the context variable within lambda_handler(event, context) function when not in Bolt framework. I would like to also make them available in Bolt framework. Proposed code mirrors how bolt_req.context is currently populated in AWS Lambda adapter handler:

$ git diff
diff --git a/slack_bolt/adapter/aws_lambda/handler.py b/slack_bolt/adapter/aws_lambda/handler.py
index 1ba44dd..ba3e183 100644
--- a/slack_bolt/adapter/aws_lambda/handler.py
+++ b/slack_bolt/adapter/aws_lambda/handler.py
@@ -55,7 +55,11 @@ class SlackRequestHandler:
             bolt_req = to_bolt_request(event)
             # https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
             aws_lambda_function_name = context.function_name
+            aws_request_id = context.aws_request_id
+            log_stream_name = context.log_stream_name
             bolt_req.context["aws_lambda_function_name"] = aws_lambda_function_name
+            bolt_req.context["aws_request_id"] = aws_request_id
+            bolt_req.context["log_stream_name"] = log_stream_name
             bolt_req.context["aws_lambda_invoked_function_arn"] = context.invoked_function_arn
             bolt_req.context["lambda_request"] = event
             bolt_resp = self.app.dispatch(bolt_req)

I am open to implementing this feature myself if there is desire to add it to bolt-python.

Category (place an x in each of the [ ])
  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 slack_bolt/adapter/aws_lambda/handler.py 开始,其中 SlackRequestHandler 会将 AWS Lambda context 映射到 bolt_req.context。检查现有的 context 填充逻辑,并将 aws_request_id 和 log_stream_name 与其他 Lambda 值一起暴露出来;当这两个键在 Bolt 请求处理期间都可用时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, python
领域
cloud
Issue 类型
功能
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。