slackapi / slackapi/bolt-python

AWS Lambda Adapter: Expose aws_request_id and log_stream_name in SlackRequestHandler context

Aperta
#1,035 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

area:adapter enhancement
Lingua principale
Python
Stelle
1.3k
Fork
288
Merge medio
1g 8h
PR unite (30g)
10

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in slack_bolt/adapter/aws_lambda/handler.py, dove SlackRequestHandler associa il contesto AWS Lambda a bolt_req.context. Verifica il popolamento esistente del contesto ed esponi aws_request_id e log_stream_name insieme agli altri valori Lambda; il lavoro è completato quando entrambe le chiavi sono disponibili durante la gestione delle richieste Bolt.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, python
Ambito
cloud
Tipo di issue
Funzionalità
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.