@@ -209,6 +209,20 @@ def extract_context_from_http_event_or_context(
209209 return context
210210
211211
212+ def extract_context_from_request_header_or_context (event , lambda_context , event_source ):
213+ request = event .get ("request" )
214+ if isinstance (request , (set , dict )) and "headers" in request :
215+ context = extract_context_from_http_event_or_context (
216+ request ,
217+ lambda_context ,
218+ event_source ,
219+ decode_authorizer_context = False ,
220+ )
221+ else :
222+ context = extract_context_from_lambda_context (lambda_context )
223+ return context
224+
225+
212226def create_sns_event (message ):
213227 return {
214228 "Records" : [
@@ -627,6 +641,10 @@ def extract_dd_trace_context(
627641
628642 if extractor is not None :
629643 context = extract_context_custom_extractor (extractor , event , lambda_context )
644+ elif isinstance (event , (set , dict )) and "request" in event :
645+ context = extract_context_from_request_header_or_context (
646+ event , lambda_context , event_source
647+ )
630648 elif isinstance (event , (set , dict )) and "headers" in event :
631649 context = extract_context_from_http_event_or_context (
632650 event , lambda_context , event_source , decode_authorizer_context
0 commit comments