forked from DataDog/datadog-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.py
More file actions
29 lines (21 loc) · 666 Bytes
/
extension.py
File metadata and controls
29 lines (21 loc) · 666 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
import logging
import requests
AGENT_URL = "http://127.0.0.1:8124"
HELLO_PATH = "/lambda/hello"
FLUSH_PATH = "/lambda/flush"
logger = logging.getLogger(__name__)
def is_extension_running():
try:
requests.get(AGENT_URL + HELLO_PATH)
except Exception as e:
logger.debug("Extension is not running, returned with error %s", e)
return False
return True
def flush_extension():
try:
requests.post(AGENT_URL + FLUSH_PATH, data={})
except Exception as e:
logger.debug("Failed to flush extension, returned with error %s", e)
return False
return True
should_use_extension = is_extension_running()