slackapi / slackapi/bolt-python
AWS Lambda Adapter: Expose aws_request_id and log_stream_name in SlackRequestHandler context
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 1.3k
- Forks
- 288
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 10
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en slack_bolt/adapter/aws_lambda/handler.py, donde SlackRequestHandler asigna el contexto de AWS Lambda a bolt_req.context. Verifica la población existente del contexto y expón aws_request_id y log_stream_name junto con los demás valores de Lambda; la tarea estará terminada cuando ambas claves estén disponibles durante el procesamiento de solicitudes de Bolt.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- aws, python
- Área
- cloud
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 48/100