Code Origins for Spans

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Join the Preview!

Code Origins is currently in Preview. To join the preview, follow the instructions below. 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, it automatically adds file path, line number, and function name to each span, making it easier to:

  • Debug performance issues
  • Understand code execution flow
  • Identify performance bottlenecks

In Trace Explorer, select a span to see Code Origin details on the Overview tab:

Code Origin Details

Getting started

Prerequisites

Compatibility requirements

Runtime LanguageTracing Library VersionFrameworks
Java1.47.0+Spring Boot/Data, gRPC servers, Micronaut 4, Kafka consumers
Python2.15.0+Django, Flask, Starlette and derivatives
Node.js4.49.0+Fastify
.NET3.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

Using Code Origins

In the Trace Explorer

  1. Navigate to the Trace Explorer.

  2. Click on any trace to view its details.

  3. In the span details panel, look for the “Code Origin” section.

    Code Origin Details in Traces Explorer
  4. Optionally, click on source code variables to add them as attributes to future spans with Dynamic Instrumentation.

    Code Origin - Add span tag with Dynamic Instrumentation

In your IDE

  1. Set up your Datadog IDE Integration.

    • Supported IDEs: IntelliJ, VS Code
    • Supported Languages: Java, Python
  2. View RED metrics (Requests, Errors, and Duration) as inline annotations above your endpoint methods.

    Code Origin Details in IDE

Troubleshooting

If Code Origin information is missing:

  1. Verify Code Origins is enabled in your tracing library configuration.
  2. Confirm that your service meets all compatibility requirements.
    • In particular, check whether your service’s language and framework support Code Origins.
  3. Filter for spans that include Code Origins using the query @_dd.code_origin.type:* in the Trace Explorer.
  4. Enable Source Code Integration to see code previews in the APM Trace side panel.

Further Reading

PREVIEWING: camille.jouan/et-datadog-operator