This PR ensures that the traceId and spanId are boxed as a String object when creating the dd-trace/span-context type (so that later it won't error out when calling toArray())
Motivation
We have a customer issue linked here.
The error stacktrace is
2023-12-07T13:57:10.020Z c241f8c3-8001-4a5d-a333-6ae15155d2a2 DEBUG {
"status": "debug",
"message": "id.toArray is not a function",
"name": "TypeError",
"stack": "TypeError: id.toArray is not a function\n at AgentEncoder._encodeId (/var/task/node_modules/dd-trace/packages/dd-trace/src/encode/0.4.js:168:13)\n at AgentEncoder._encode (/var/task/node_modules/dd-trace/packages/dd-trace/src/encode/0.4.js:96:12)\n at AgentEncoder.encode (/var/task/node_modules/dd-trace/packages/dd-trace/src/encode/0.4.js:45:10)\n at Writer._encode (/var/task/node_modules/dd-trace/packages/dd-trace/src/exporters/common/writer.js:39:19)\n at Writer.append (/var/task/node_modules/dd-trace/packages/dd-trace/src/exporters/common/writer.js:35:10)\n at AgentExporter.export (/var/task/node_modules/dd-trace/packages/dd-trace/src/exporters/agent/index.js:45:18)\n at SpanProcessor.process (/var/task/node_modules/dd-trace/packages/dd-trace/src/span_processor.js:53:30)\n at DatadogSpan.finish (/var/task/node_modules/dd-trace/packages/dd-trace/src/opentracing/span.js:183:21)\n at SpanWrapper.finish (/var/task/node_modules/datadog-lambda-js/dist/trace/span-wrapper.js:28:19)\n at TraceListener.<anonymous> (/var/task/node_modules/datadog-lambda-js/dist/trace/listener.js:227:39)"
}
This issue can be replicated when trying to passing down x-ray trace context with DD_MERGE_XRAY_TRACES: true
What does this PR do?
This PR ensures that the traceId and spanId are boxed as a String object when creating the dd-trace/span-context type (so that later it won't error out when calling toArray())
Motivation
We have a customer issue linked here. The error stacktrace is
This issue can be replicated when trying to passing down x-ray trace context with
DD_MERGE_XRAY_TRACES: true
Testing Guidelines
Additional Notes
Types of Changes
Check all that apply