Join the Preview!
Code Origins is currently in Preview. To join the preview, follow the instructions below to enable the feature on your compatible services.
To submit questions, feedback, or requests related to Code Origins, fill out this form with details.
Overview
Code Origins captures the exact locations in your codebase where APM spans are created. When enabled on a compatible service, it automatically adds file path, line number, and function name to each service entry span, making it easier to:
- Debug performance issues
- Understand code execution flow
- Identify performance bottlenecks
In Trace Explorer, select a span from an enabled service to see Code Origin details on the Overview tab:
Getting started
Prerequisites
Compatibility requirements
Runtime Language | Tracing Library Version | Frameworks |
---|
Java | 1.47.0+ | Spring Boot/Data, gRPC servers, Micronaut 4, Kafka consumers |
Python | 2.15.0+ | Django, Flask, Starlette and derivatives |
Node.js | 4.49.0+ | Fastify |
.NET | 3.15.0+ | ASP.NET, ASP.NET Core |
Enable Code Origins
Run your service with the following environment variable:
export DD_CODE_ORIGIN_FOR_SPANS_ENABLED=true
For transpiled Node.js applications (for example, Typescript), make sure to generate and publish source maps with the deployed application, and to run Node.js with the
--enable-source-maps
flag. Otherwise, code previews do not work. See the Node.js
Source Code Integration documentation for more details.
Using Code Origins
In the Trace Explorer
Navigate to the Trace Explorer.
Search for “Service Entry Spans” from your Code Origins-enabled services.
Click on a span to view its details.
In the trace details side panel, look for the “Code Origin” section.
From the Code Origin section:
Kick off a Live Debugger session on the running service by clicking “Start Debug Session” to capture logs at the Code Origin method location. Or, select a breakpoint in the gutter of the code preview to capture logs at the selected line of code.
Click on source code variables to add them as attributes to future spans with Dynamic Instrumentation.
In your IDE
Set up your Datadog IDE Integration.
- Supported IDEs: IntelliJ, VS Code
- Supported Languages: Java, Python
View RED metrics (Requests, Errors, and Duration) as inline annotations above your endpoint methods.
Troubleshooting
Code Origin section is missing
Verify Code Origins is enabled in your tracing library configuration.
Confirm that your service meets all compatibility requirements (that is, service language, supported frameworks, and minimum tracer version).
For most services, Code Origins data is captured for service entry spans only. You can filter to “Service Entry Spans” in the APM Trace Explorer.
To search for all spans that include Code Origins, use the query @_dd.code_origin.type:*
in the APM Trace Explorer.
Code preview is not visible
- Ensure that all Source Code Integration setup requirements are met.
- For transpiled Node.js applications (for example, Typescript), make sure to generate and publish source maps with the deployed application, and to run Node.js with the
--enable-source-maps
flag. Otherwise, code previews do not work. See the Node.js Source Code Integration documentation for more details.
Further Reading
Additional helpful documentation, links, and articles: