forked from stackimpact/stackimpact-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws_lambda.py
More file actions
40 lines (29 loc) · 734 Bytes
/
aws_lambda.py
File metadata and controls
40 lines (29 loc) · 734 Bytes
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
from __future__ import print_function
import stackimpact
import random
import threading
import time
import signal
agent = stackimpact.start(
agent_key = 'agent key here',
app_name = 'LambdaDemoPython',
app_environment = 'prod',
block_profiler_disabled = True)
def simulate_cpu_work():
for j in range(0, 100000):
random.randint(1, 1000000)
mem = []
def simulate_mem_leak():
for i in range(0, 1000):
obj = {'v': random.randint(0, 1000000)}
mem.append(obj)
def handler(event, context):
span = agent.profile()
simulate_cpu_work()
simulate_mem_leak()
span.stop()
response = {
"statusCode": 200,
"body": 'Done'
}
return response