slackapi / slackapi/bolt-python
AWS Lambda Adapter: Expose aws_request_id and log_stream_name in SlackRequestHandler context
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.3k
- フォーク
- 288
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
slack_bolt/adapter/aws_lambda/handler.py から始めます。ここで SlackRequestHandler は AWS Lambda のコンテキストを bolt_req.context にマッピングします。既存のコンテキストの設定を確認し、他の Lambda 値とともに aws_request_id と log_stream_name を公開します。Bolt リクエストの処理中に両方のキーが利用可能になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- aws, python
- 領域
- cloud
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 48/100