-
Notifications
You must be signed in to change notification settings - Fork 0
/
comprehensive.py
47 lines (35 loc) · 975 Bytes
/
comprehensive.py
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
import logging
import random
import time
from datadog import DDConfig, DDClient
log = logging.getLogger(__name__)
ddcfg = DDConfig(
service="demo-svc",
env="test",
version_use_git=True,
tracing_enabled=True,
)
ddclient = DDClient(config=ddcfg)
logging.basicConfig(
level=logging.DEBUG,
handlers=[
ddclient.LogHandler(),
logging.StreamHandler(),
],
)
def do_work(quantity):
with ddclient.trace("do.work") as operation:
ddclient.count()
operation.set_tag("quantity", quantity)
ddclient.info("about to do some serious work")
log.error("test error")
with ddclient.measure("work"):
for i in range(quantity):
with ddclient.trace("sub.work"):
time.sleep(random.randint(10, 1000) / 1000)
ddclient.warning("uhoh")
ddclient.error("whoops")
ddclient.profiling_start()
do_work(2)
ddclient.profiling_stop()
ddclient.flush()