File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 55
66import base64
77import gzip
8+ from functools import lru_cache
9+
810import ujson as json
911from io import BytesIO , BufferedReader
1012from enum import Enum
@@ -369,6 +371,7 @@ def extract_http_status_code_tag(trigger_tags, response):
369371 return str (status_code )
370372
371373
374+ @lru_cache (maxsize = 8 )
372375def is_step_function_event (event ):
373376 """
374377 Check if the event is a step function that invoked the current lambda.
@@ -381,14 +384,15 @@ def is_step_function_event(event):
381384 event = event .get ("Payload" , event )
382385
383386 # JSONPath style
384- if all ( field in event for field in ( "Execution" , "StateMachine" , "State" )) :
387+ if "Execution" in event and "StateMachine" in event and "State" in event :
385388 return True
386389
387390 # JSONata style
388- if "_datadog" in event :
389- return all (
390- field in event ["_datadog" ]
391- for field in ("Execution" , "StateMachine" , "State" , "serverless-version" )
392- )
393-
394- return False
391+ dd_context = event .get ("_datadog" )
392+ return (
393+ dd_context
394+ and "Execution" in dd_context
395+ and "StateMachine" in dd_context
396+ and "State" in dd_context
397+ and "serverless-version" in dd_context
398+ )
You can’t perform that action at this time.
0 commit comments