Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 082683c

Browse files
committed
Fix tests
1 parent 353dde6 commit 082683c

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

datadog_lambda/tracing.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def _get_dd_trace_native_context():
7171
parent_id = span.context.span_id
7272
trace_id = span.context.trace_id
7373
return {
74-
"parent_id": str(parent_id),
75-
"trace_id": str(trace_id),
76-
"sampling_priority": SamplingPriority.AUTO_KEEP,
74+
"parent-id": str(parent_id),
75+
"trace-id": str(trace_id),
76+
"sampling-priority": SamplingPriority.AUTO_KEEP,
7777
"source": Source.DDTRACE,
7878
}
7979

@@ -106,17 +106,17 @@ def extract_dd_trace_context(event):
106106
sampling_priority = lowercase_headers.get(TraceHeader.SAMPLING_PRIORITY)
107107
if trace_id and parent_id and sampling_priority:
108108
logger.debug("Extracted Datadog trace context from headers")
109-
dd_trace_context = {
109+
metadata = {
110110
"trace-id": trace_id,
111111
"parent-id": parent_id,
112112
"sampling-priority": sampling_priority,
113-
"source": Source.EVENT,
114113
}
115114
xray_recorder.begin_subsegment(XraySubsegment.NAME)
116115
subsegment = xray_recorder.current_subsegment()
117-
subsegment.put_metadata(
118-
XraySubsegment.KEY, dd_trace_context, XraySubsegment.NAMESPACE
119-
)
116+
117+
subsegment.put_metadata(XraySubsegment.KEY, metadata, XraySubsegment.NAMESPACE)
118+
dd_trace_context = metadata.copy()
119+
dd_trace_context["source"] = Source.EVENT
120120
xray_recorder.end_subsegment()
121121
else:
122122
# AWS Lambda runtime caches global variables between invocations,

datadog_lambda/wrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
set_correlation_ids,
2323
)
2424
from datadog_lambda.constants import Source
25-
from ddtrace import tracer, Span
25+
from ddtrace import tracer
2626
from ddtrace.propagation.http import HTTPPropagator
2727

2828

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
install_requires=[
3131
"aws-xray-sdk==2.4.3",
3232
"datadog==0.32.0",
33+
"ddtrace==0.31.0",
3334
"wrapt==1.11.2",
3435
"setuptools==42.0.2",
3536
],

tests/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ WORKDIR /test
88

99
# Install datadog-lambda with dev dependencies from local
1010
COPY . .
11-
RUN pip install .[dev]
11+
RUN pip install .[dev]
12+
RUN pip install --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace-dev/index.html ddtrace==0.35.1.dev5+g1e11b2dd -t .[dev]

0 commit comments

Comments
 (0)