For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/source_code/service-mapping.md. A documentation index is available at /llms.txt.

Service Mapping for Source Code Integration

Overview

You can associate your APM spans with Git data to link a running application version with a particular repository and commit. This unlocks source code features in APM-powered products.

Embed Git information in your deployed build artifacts to allow Datadog SDKs to read it and automatically attach git.commit.sha and git.repository_url tags to every span.

If you already have APM set up, navigate to Integrations > Link Source Code to configure the source code integration for your backend services.

Embed Git information in your build artifacts

You can embed a repository URL and commit hash in your build artifact. The Datadog SDKs use this information to automatically add tags to your APM service telemetry.

Select one of the following languages that support embedding Git information:

Build inside a Docker container

If your build process is executed in CI within a Docker container, use a named context to make your .git folder available at build time:

  1. Add your .git folder as a named build context:

    docker build [...] --build-context dotgit=<path to your local .git folder>
    
  2. In your Dockerfile, mount the .git folder before running your build:

    RUN --mount=from=dotgit,target=<path to where you expect .git to be in your build container> <your build command>
    

Further reading

Additional helpful documentation, links, and articles: