- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Datadog’s source code integration allows you to connect your telemetry with your Git repositories. It allows debugging stack traces, slow profiles, and other issues by accessing the relevant lines of your source code.
Datadog Agent v7.35.0 or later is required.
If you have APM set up already, navigate to Integrations > Link Source Code and configure the source code integration for your backend services.
Your telemetry must be tagged with Git information that ties the running application version with a particular repository and commit.
For supported languages, Datadog recommends embedding Git information in the deployed artifacts, which is then extracted by the Datadog Tracing Libraries automatically.
For other languages and configurations, you can configure telemetry tagging yourself.
You can embed the repository URL and commit hash in your build artifact. The Datadog Tracing Libraries use this information to automatically add the right tags to your APM service telemetry.
Select one of the following languages that supports embedding git information:
If you are using Docker containers, you have three options: using Docker, using the Datadog tracing library, or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
Go embeds version control information in binaries since version 1.18. The Datadog tracing library uses this information to tag your telemetry with the latest commit SHA and repository URL.
Ensure your service meets the following requirements to use this approach:
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have three options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.Go embeds version control information in binaries since version 1.18. The Datadog tracing library uses this information to tag your telemetry with the latest commit SHA and repository URL.
Ensure your service meets the following requirements to use this approach:
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, you have two options.
Go embeds version control information in binaries since version 1.18. The Datadog tracing library uses this information to tag your telemetry with the latest commit SHA and repository URL.
Ensure your service meets the following requirements to use this approach:
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have three options: using Docker, using the Datadog tracing library, or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
If your application is packaged with setuptools:
dd-trace
package.import ddtrace.sourcecode.setuptools_auto
as the first import to the setup.py
file.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.If your application is using a unified Python project settings file:
hatch-datadog-build-metadata
plugin and configure it to embed git metadata. If a project already has URLs, reconfigure them as dynamic and move them to another configuration section. For more information, see the plugin source code.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have three options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.If your application is packaged with setuptools:
dd-trace
package.import ddtrace.sourcecode.setuptools_auto
as the first import to the setup.py
file.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.If your application is using a unified Python project settings file:
hatch-datadog-build-metadata
plugin and configure it to embed git metadata. If a project already has URLs, reconfigure them as dynamic and move them to another configuration section. For more information, see the plugin source code.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, you have two options.
If your application is packaged with setuptools:
dd-trace
package.import ddtrace.sourcecode.setuptools_auto
as the first import to the setup.py
file.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.If your application is using a unified Python project settings file:
hatch-datadog-build-metadata
plugin and configure it to embed git metadata. If a project already has URLs, reconfigure them as dynamic and move them to another configuration section. For more information, see the plugin source code.DD_MAIN_PACKAGE
environment variable as the name of the primary Python package.DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have three options: using Docker, using Microsoft SourceLink, or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
If you are using Microsoft SourceLink, Datadog can extract the git commit SHA and repository URL from your .NET assembly.
Open your project’s file (.csproj
) in an IDE and add a reference to one of the following NuGet packages, depending on where your git repository is hosted:
Provider | Microsoft SourceLink |
---|---|
GitHub | Microsoft.SourceLink.GitHub |
Bitbucket | Microsoft.SourceLink.Bitbucket |
GitLab | Microsoft.SourceLink.GitLab |
Azure DevOps | Microsoft.SourceLink.AzureRepos.Git |
Azure DevOps Server | Microsoft.SourceLink.AzureDevOpsServer.Git |
Ensure that your .pdb
files are deployed alongside your .NET assemblies (.dll
or .exe
) in the same folder.
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have three options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.If you are using Microsoft SourceLink, Datadog can extract the git commit SHA and repository URL from your .NET assembly.
Open your project’s file (.csproj
) in an IDE and add a reference to one of the following NuGet packages, depending on where your git repository is hosted:
Provider | Microsoft SourceLink |
---|---|
GitHub | Microsoft.SourceLink.GitHub |
Bitbucket | Microsoft.SourceLink.Bitbucket |
GitLab | Microsoft.SourceLink.GitLab |
Azure DevOps | Microsoft.SourceLink.AzureRepos.Git |
Azure DevOps Server | Microsoft.SourceLink.AzureDevOpsServer.Git |
Ensure that your .pdb
files are deployed alongside your .NET assemblies (.dll
or .exe
) in the same folder.
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, you have two options: using Microsoft SourceLink or configuring your application with DD_GIT_*
environment variables.
If you are using Microsoft SourceLink, Datadog can extract the git commit SHA and repository URL from your .NET assembly.
Open your project’s file (.csproj
) in an IDE and add a reference to one of the following NuGet packages, depending on where your git repository is hosted:
Provider | Microsoft SourceLink |
---|---|
GitHub | Microsoft.SourceLink.GitHub |
Bitbucket | Microsoft.SourceLink.Bitbucket |
GitLab | Microsoft.SourceLink.GitLab |
Azure DevOps | Microsoft.SourceLink.AzureRepos.Git |
Azure DevOps Server | Microsoft.SourceLink.AzureDevOpsServer.Git |
Ensure that your .pdb
files are deployed alongside your .NET assemblies (.dll
or .exe
) in the same folder.
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have two options: using Docker or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have two options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, configure your application with DD_GIT_*
environment variables.
Configure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have two options: using Docker or configuring your application with the DD_TAGS
environment variable.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_TAGS="git.repository_url:${DD_GIT_REPOSITORY_URL},git.commit.sha:${DD_GIT_COMMIT_SHA}"
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
DD_TAGS
Environment VariableConfigure your application with the DD_TAGS
environment variable:
export DD_TAGS="git.commit.sha:<commitSha>,git.repository_url:<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have two options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.DD_TAGS
Environment VariableConfigure your application with the DD_TAGS
environment variable:
export DD_TAGS="git.commit.sha:<commitSha>,git.repository_url:<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, configure your application with the DD_TAGS
environment variable.
Configure your application with the DD_TAGS
environment variable:
export DD_TAGS="git.commit.sha:<commitSha>,git.repository_url:<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have two options: using Docker or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Serverless, you have two options depending on your serverless application’s setup.
datadog-ci
client version 2.4.1 or later. You must run the CLI tool in the same directory as the code repository.datadog-cdk-constructs
version 0.8.5 or later for AWS CDK v1.Use the datadog-cdk-constructs
version 1.4.0 or later for AWS CDK v2.DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, configure your application with DD_GIT_*
environment variables.
Configure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using Docker containers, you have two options: using Docker or configuring your application with DD_GIT_*
environment variables.
Add the following lines to your application’s Dockerfile:
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
Add the following arguments to your Docker build command:
docker build . \
-t my-application \
--build-arg DD_GIT_REPOSITORY_URL=<git-provider.example/me/my-repo> \
--build-arg DD_GIT_COMMIT_SHA=$(git rev-parse HEAD)
DD_GIT_*
Environment VariablesConfigure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If you are using a host, configure your application with DD_GIT_*
environment variables.
Configure your application with the DD_GIT_*
environment variables:
export DD_GIT_COMMIT_SHA="<commitSha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Replace <commitSha>
with the commit SHA used to build your application. You can retrieve this by running git rev-parse HEAD
at build time, and it needs to be passed into the runtime environment variables.
If your build process is executed in CI within a Docker container, perform the following steps to ensure that the build can access Git information:
Add the following text to your .dockerignore
file. This ensures that the build process is able to access a subset of the .git
folder, enabling it to determine the git commit hash and repository URL.
!.git/HEAD
!.git/config
!.git/refs
Add the following line of code to your Dockerfile
. Ensure that it is placed before the actual build is ran.
COPY .git ./.git
For unsupported languages, use the git.commit.sha
and git.repository_url
tags to link data to a specific commit. Ensure that the git.repository_url
tag does not contain protocols. For example, if your repository URL is https://github.com/example/repo
, the value for the git.repository_url
tag should be github.com/example/repo
.
To link your telemetry with source code, your repository metadata must be synchronized to Datadog. Datadog doesn’t store the actual content of files in your repository, only the Git commit and tree objects.
The source code integration supports the following Git providers:
Provider | Context Links Support | Code Snippets Support |
---|---|---|
GitHub SaaS (github.com) | Yes | Yes |
GitHub Enterprise Server | Yes | Yes |
GitLab SaaS (gitlab.com) | Yes | Yes |
GitLab self-managed | Yes | No |
Bitbucket | Yes | No |
Azure DevOps Services | Yes | No |
Azure DevOps Server | Yes | No |
Install Datadog’s GitHub integration on the GitHub integration tile to allow Datadog to synchronize your repository metadata automatically. When specifying permissions on the integration tile, select at least Read permissions for Contents.
Setting up the GitHub integration also allows you to see inline code snippets in Error Tracking, Continuous Profiler, Serverless Monitoring, CI Visibility, and Application Security Monitoring.
To link telemetry with your source code, upload your repository metadata with the datadog-ci git-metadata upload
command.
When you run datadog-ci git-metadata upload
within a Git repository, Datadog receives the repository URL, the commit SHA of the current branch, and a list of tracked file paths.
Run this command for every commit that you need to be synchronized with Datadog.
If you are using gitlab.com, this also allows you to see inline code snippets in Error Tracking, Continuous Profiler, Serverless Monitoring, CI Visibility, and Application Security Monitoring.
To ensure the data is being collected, run datadog-ci git-metadata upload
in your CI pipeline.
You can expect to see the following output:
Reporting commit 007f7f466e035b052415134600ea899693e7bb34 from repository git@my-git-server.com:my-org/my-repository.git.
180 tracked file paths will be reported.
✅ Handled in 0.077 seconds.
To link telemetry with your source code, upload your repository metadata with the datadog-ci git-metadata upload
command.
When you run datadog-ci git-metadata upload
within a Git repository, Datadog receives the repository URL, the commit SHA of the current branch, and a list of tracked file paths.
Run this command for every commit that you need to be synchronized with Datadog.
To ensure the data is being collected, run datadog-ci git-metadata upload
in your CI pipeline.
You can expect to see the following output:
Reporting commit 007f7f466e035b052415134600ea899693e7bb34 from repository git@my-git-server.com:my-org/my-repository.git.
180 tracked file paths will be reported.
✅ Handled in 0.077 seconds.
You can see links from stack frames to their source repository in Error Tracking.
If you’re using the GitHub integration, or if you’re hosting your repositories on the GitLab SaaS instance (gitlab.com), click Connect to preview on stack frames. You can see inline code snippets directly in the stack trace.
You can see a source code preview for profile frames in the Continuous Profiler.
Opt
or Alt
to enable the preview.You can also see links from profile frames to their source repository. This is supported for profiles broken down by line, method, or file.
You can see links from errors in your Lambda functions’ associated stack traces to their source repository in Serverless Monitoring.
If you’re using the GitHub integration, click Connect to preview on error frames. You can see inline code snippets directly in the Lambda function’s stack trace.
You can see links from failed test runs to their source repository in Test Visibility.
For more information, see Enhancing Developer Workflows with Datadog.
You can see links from failed Static Analysis and Software Composition Analysis scans to their source repository in Code Analysis.
For more information, see the Code Analysis documentation.
You can see links from errors in your security signals’ associated stack traces to their source repository in Application Security Monitoring.
If you’re using the GitHub integration, click Connect to preview on error frames. You can see inline code snippets directly in the security signal’s stack trace.
추가 유용한 문서, 링크 및 기사: