Skip to content

Commit b3b8a35

Browse files
committed
lint
1 parent 83d7914 commit b3b8a35

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

datadog_lambda/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ class TraceContextSource(object):
3737

3838

3939
# X-Ray deamon
40-
class XrayDeamon(object):
41-
HOST = "127.0.0.1"
42-
PORT = 2000
40+
class XrayDaemon(object):
41+
XRAY_TRACE_ID_HEADER_NAME = "_X_AMZN_TRACE_ID"
42+
XRAY_DAEMON_ADDRESS = "AWS_XRAY_DAEMON_ADDRESS"

datadog_lambda/tracing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
SamplingPriority,
1212
TraceHeader,
1313
TraceContextSource,
14+
XrayDaemon,
1415
)
1516
from datadog_lambda.xray import (
1617
send_segment,
1718
parse_xray_header,
18-
XRAY_TRACE_ID_HEADER_NAME,
1919
)
2020
from ddtrace import tracer, patch
2121
from ddtrace import __version__ as ddtrace_version
@@ -61,7 +61,9 @@ def _get_xray_trace_context():
6161
if not is_lambda_context():
6262
return None
6363

64-
xray_trace_entity = parse_xray_header(os.environ.get(XRAY_TRACE_ID_HEADER_NAME, ""))
64+
xray_trace_entity = parse_xray_header(
65+
os.environ.get(XrayDaemon.XRAY_TRACE_ID_HEADER_NAME, "")
66+
)
6567
if xray_trace_entity is None:
6668
return None
6769
trace_context = {

datadog_lambda/xray.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
import time
66
import socket
77

8-
from datadog_lambda.constants import XraySubsegment, TraceContextSource
8+
from datadog_lambda.constants import XrayDaemon, XraySubsegment, TraceContextSource
99

10-
XRAY_TRACE_ID_HEADER_NAME = "_X_AMZN_TRACE_ID"
11-
XRAY_DAEMON_ADDRESS = "AWS_XRAY_DAEMON_ADDRESS"
1210
logger = logging.getLogger(__name__)
1311

1412

@@ -98,10 +96,14 @@ def build_segment(context, key, metadata):
9896

9997

10098
def send_segment(key, metadata):
101-
host_port_tuple = get_xray_host_port(os.environ.get(XRAY_DAEMON_ADDRESS, ""))
99+
host_port_tuple = get_xray_host_port(
100+
os.environ.get(XrayDaemon.XRAY_DAEMON_ADDRESS, "")
101+
)
102102
if host_port_tuple is None:
103103
return None
104-
context = parse_xray_header(os.environ.get(XRAY_TRACE_ID_HEADER_NAME, ""))
104+
context = parse_xray_header(
105+
os.environ.get(XrayDaemon.XRAY_TRACE_ID_HEADER_NAME, "")
106+
)
105107
if context is None:
106108
logger.debug(
107109
"Failed to create segment since it was not possible to get trace context from header"

tests/test_tracing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def setUp(self):
5858
global dd_tracing_enabled
5959
dd_tracing_enabled = False
6060
os.environ["_X_AMZN_TRACE_ID"] = fake_xray_header_value
61-
os.environ["XRAY_DAEMON_ADDRESS"] = "1.1.1.1:8888"
6261
patcher = patch("datadog_lambda.tracing.send_segment")
6362
self.mock_send_segment = patcher.start()
6463
self.addCleanup(patcher.stop)
@@ -71,7 +70,6 @@ def tearDown(self):
7170
global dd_tracing_enabled
7271
dd_tracing_enabled = False
7372
del os.environ["_X_AMZN_TRACE_ID"]
74-
del os.environ["XRAY_DAEMON_ADDRESS"]
7573

7674
def test_without_datadog_trace_headers(self):
7775
lambda_ctx = get_mock_context()

0 commit comments

Comments
 (0)