Skip to content

Commit 2884d9c

Browse files
author
zhanzeyu.frederic
committed
add trace patch
1 parent bd285f4 commit 2884d9c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

trace.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from ddtrace import patch_all, tracer
4+
5+
6+
def patch():
7+
"""设置 datadog tracer,需要保证环境内有 DD_AGENT_HOST、DD_TRACE_AGENT_PORT 环境变量"""
8+
patch_all()
9+
if os.environ.get("DD_AGENT_HOST", None) and os.environ.get("DD_TRACE_AGENT_PORT", None):
10+
tracer.configure(hostname=os.environ['DD_AGENT_HOST'],
11+
port=os.environ['DD_TRACE_AGENT_PORT'])
12+
else:
13+
print("WARNING: or DD_TRACE_AGENT_PORT not set, ignore configuring datadog tracer.")

0 commit comments

Comments
 (0)