-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (46 loc) · 1.45 KB
/
Copy pathmain.py
File metadata and controls
56 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
import logging
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
import stackref.settings as settings
from stackref.settings import return_error
from stackref.process_fn_method import process_fn_method
from stackref.process_post_method import process_post_method
print(':: Loading function')
sentry_sdk.init(
dsn="https://YOUR_SENTRY_KEY@oYOUR_ORG.ingest.sentry.io/YOUR_PROJECT",
integrations=[
AwsLambdaIntegration()
],
enable_tracing=True,
profiles_sample_rate=1.0,
traces_sample_rate=1.0
)
'''
main
'''
def main(event, context):
log.debug(f":: Received event: {json.dumps(event, indent=2)}")
if (
'requestContext' in event and
'http' in event['requestContext'] and
'method' in event['requestContext']['http']
):
if event['requestContext']['http']['method'] == "POST":
return process_post_method(event)
else:
return return_error(405, 'main: unhandled method')
elif (
'requestContext' in event and
'http' not in event['requestContext'] and
'intFnName' in event['requestContext']
):
return process_fn_method(event, event['requestContext']['intFnName'])
return return_error(500, 'main')
settings.init()
logging.basicConfig(level=logging.ERROR)
log = logging.getLogger(__name__)
settings.logging_config()
log.setLevel(settings.log_level)
if __name__ == "__main__":
main()