The Go client library version 1.48.0 or later is required.
Containers
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.
Option 1: Docker
Ajoutez les lignes suivantes dans le Dockerfile de votre application :
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}
Ajoutez les arguments suivants à votre commande build Docker :
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)
Option 2: Datadog Tracing Library
Depuis la version 1.18, Go intègre les informations sur le contrôle des versions dans des binaires. La bibliothèque de tracing Datadog se sert de ces informations pour taguer vos données de télémétrie avec le SHA du commit et l’URL du référentiel les plus récents.
Pour adopter cette approche, vérifiez que votre service respecte les exigences suivantes :
- Version 1.18 ou ultérieure de Go
- Service conçu en tant que module Go, dont le chemin correspond à l’URL du référentiel de votre code
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Serverless
If you are using Serverless, you have three options depending on your serverless application’s setup.
- Outil CLI Datadog
- Utilisez la version 2.4.1 ou une version ultérieure du client
datadog-ci
. Vous devez exécuter l’outil CLI dans le même répertoire que le référentiel de code. - Plug-in Serverless Datadog
- Utilisez la version 5.18.0 ou une version ultérieure du plug-in.
- CDK Construct Datadog
- Utilisez la version 0.8.5 ou une version ultérieure de
datadog-cdk-constructs
pour AWS CDK v1.Utilisez la version 1.4.0 ou une version ultérieure de datadog-cdk-constructs
pour AWS CDK v2.
Option 2: Datadog Tracing Library
Depuis la version 1.18, Go intègre les informations sur le contrôle des versions dans des binaires. La bibliothèque de tracing Datadog se sert de ces informations pour taguer vos données de télémétrie avec le SHA du commit et l’URL du référentiel les plus récents.
Pour adopter cette approche, vérifiez que votre service respecte les exigences suivantes :
- Version 1.18 ou ultérieure de Go
- Service conçu en tant que module Go, dont le chemin correspond à l’URL du référentiel de votre code
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Host
If you are using a host, you have two options.
Option 1: Datadog Tracing Library
Depuis la version 1.18, Go intègre les informations sur le contrôle des versions dans des binaires. La bibliothèque de tracing Datadog se sert de ces informations pour taguer vos données de télémétrie avec le SHA du commit et l’URL du référentiel les plus récents.
Pour adopter cette approche, vérifiez que votre service respecte les exigences suivantes :
- Version 1.18 ou ultérieure de Go
- Service conçu en tant que module Go, dont le chemin correspond à l’URL du référentiel de votre code
Option 2: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
The Python client library version 1.12.0 or later is required.
Containers
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.
Option 1: Docker
Ajoutez les lignes suivantes dans le Dockerfile de votre application :
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}
Ajoutez les arguments suivants à votre commande build Docker :
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)
Si le package de votre application est généré avec setuptools :
- Installez le package
dd-trace
. - Ajoutez
import ddtrace.sourcecode.setuptools_auto
en tant que première importation dans le fichier setup.py
. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Si vous utilisez un fichier unifié contenant les paramètres du projet Python pour votre application :
- Installez le plug-in
hatch-datadog-build-metadata
et configurez-le de façon à intégrer les métadonnées git. Si un projet contient déjà des URL, reconfigurez-les afin d’utiliser des URL dynamiques, puis déplacez-les vers une autre section de configuration. Pour en savoir plus, consultez le code source du plug-in. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Serverless
If you are using Serverless, you have three options depending on your serverless application’s setup.
- Outil CLI Datadog
- Utilisez la version 2.4.1 ou une version ultérieure du client
datadog-ci
. Vous devez exécuter l’outil CLI dans le même répertoire que le référentiel de code. - Plug-in Serverless Datadog
- Utilisez la version 5.18.0 ou une version ultérieure du plug-in.
- CDK Construct Datadog
- Utilisez la version 0.8.5 ou une version ultérieure de
datadog-cdk-constructs
pour AWS CDK v1.Utilisez la version 1.4.0 ou une version ultérieure de datadog-cdk-constructs
pour AWS CDK v2.
Si le package de votre application est généré avec setuptools :
- Installez le package
dd-trace
. - Ajoutez
import ddtrace.sourcecode.setuptools_auto
en tant que première importation dans le fichier setup.py
. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Si vous utilisez un fichier unifié contenant les paramètres du projet Python pour votre application :
- Installez le plug-in
hatch-datadog-build-metadata
et configurez-le de façon à intégrer les métadonnées git. Si un projet contient déjà des URL, reconfigurez-les afin d’utiliser des URL dynamiques, puis déplacez-les vers une autre section de configuration. Pour en savoir plus, consultez le code source du plug-in. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Host
If you are using a host, you have two options.
Si le package de votre application est généré avec setuptools :
- Installez le package
dd-trace
. - Ajoutez
import ddtrace.sourcecode.setuptools_auto
en tant que première importation dans le fichier setup.py
. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Si vous utilisez un fichier unifié contenant les paramètres du projet Python pour votre application :
- Installez le plug-in
hatch-datadog-build-metadata
et configurez-le de façon à intégrer les métadonnées git. Si un projet contient déjà des URL, reconfigurez-les afin d’utiliser des URL dynamiques, puis déplacez-les vers une autre section de configuration. Pour en savoir plus, consultez le code source du plug-in. - Définissez la variable d’environnement
DD_MAIN_PACKAGE
sur le nom du principal package Python.
Option 2: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
The .NET client library version 2.24.1 or later is required.
As a first step, ensure that your .pdb
files are deployed alongside your .NET assemblies (.dll
or .exe
) in the same folder.
Then, follow the rest of the instructions based on your specific deployment model:
Containers
If you are using Docker containers, you have three options: using Docker, using Microsoft SourceLink, or configuring your application with DD_GIT_*
environment variables.
Option 1: Docker
Ajoutez les lignes suivantes dans le Dockerfile de votre application :
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}
Ajoutez les arguments suivants à votre commande build Docker :
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)
Option 2: Microsoft SourceLink
Si vous utilisez Microsoft SourceLink, Dtadog peut extraire le SHA du commit git et l’URL du référentiel à partir de l’assemblage .NET.
- Ouvrez le fichier de votre projet (
.csproj
) dans un environnement de développement intégré (EDI), puis ajoutez une référence à l’un des packages NuGet suivants, selon l’endroit où votre référentiel git est hébergé :
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Serverless
If you are using Serverless, you have three options depending on your serverless application’s setup.
- Outil CLI Datadog
- Utilisez la version 2.4.1 ou une version ultérieure du client
datadog-ci
. Vous devez exécuter l’outil CLI dans le même répertoire que le référentiel de code. - Plug-in Serverless Datadog
- Utilisez la version 5.18.0 ou une version ultérieure du plug-in.
- CDK Construct Datadog
- Utilisez la version 0.8.5 ou une version ultérieure de
datadog-cdk-constructs
pour AWS CDK v1.Utilisez la version 1.4.0 ou une version ultérieure de datadog-cdk-constructs
pour AWS CDK v2.
Option 2: Microsoft SourceLink
Si vous utilisez Microsoft SourceLink, Dtadog peut extraire le SHA du commit git et l’URL du référentiel à partir de l’assemblage .NET.
- Ouvrez le fichier de votre projet (
.csproj
) dans un environnement de développement intégré (EDI), puis ajoutez une référence à l’un des packages NuGet suivants, selon l’endroit où votre référentiel git est hébergé :
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Host
If you are using a host, you have two options: using Microsoft SourceLink or configuring your application with DD_GIT_*
environment variables.
Option 1: Microsoft SourceLink
Si vous utilisez Microsoft SourceLink, Dtadog peut extraire le SHA du commit git et l’URL du référentiel à partir de l’assemblage .NET.
- Ouvrez le fichier de votre projet (
.csproj
) dans un environnement de développement intégré (EDI), puis ajoutez une référence à l’un des packages NuGet suivants, selon l’endroit où votre référentiel git est hébergé :
Option 2: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
The Node.js client library version 3.21.0 or later is required.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 links and snippets will not work.
Containers
If you are using Docker containers, you have several options: using a plugin if your application is bundled, using Docker, or configuring your application with DD_GIT_*
environment variables.
Option 1: Bundler plugin
If you’re bundling your application from a Git directory, you can use plugins to inject Git metadata into the runtime bundle.
Bundling with esbuild
Use the dd-trace/esbuild
plugin to automatically inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. See the plugin documentation.
Install dd-trace
v5.68.0 or later for automatic Git tag injection.
const esbuild = require('esbuild');
+ const ddPlugin = require('dd-trace/esbuild');
esbuild.build({
entryPoints: ['index.js'],
bundle: true,
platform: 'node',
target: ['node20'],
format: 'cjs',
outfile: 'dist/bundle.js',
packages: 'external',
external: ['dd-trace', 'express']
+ plugins: [ddPlugin],
}).catch((e) => {
console.error(e);
process.exit(1);
});
Bundling with Rollup
Use rollup-plugin-inject-process-env to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const injectProcessEnv = require('rollup-plugin-inject-process-env');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
external: [
'express',
'dd-trace'
],
plugins: [
nodeResolve(),
commonjs()
+ injectProcessEnv({
+ DD_GIT_REPOSITORY_URL,
+ DD_GIT_COMMIT_SHA
+ })
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
Bundling with webpack
Use the BannerPlugin to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const webpack = require('webpack');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
target: 'node',
entry: './index.js',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'commonjs2'
},
externals: [
'express',
'dd-trace'
],
plugins: [
+ new webpack.BannerPlugin({
+ raw: true,
+ entryOnly: true,
+ banner:
+ `process.env.DD_GIT_REPOSITORY_URL=${JSON.stringify(DD_GIT_REPOSITORY_URL)};` +
+ `process.env.DD_GIT_COMMIT_SHA=${JSON.stringify(DD_GIT_COMMIT_SHA)};`,
+ }),
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
Option 2: Docker
Ajoutez les lignes suivantes dans le Dockerfile de votre application :
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}
Ajoutez les arguments suivants à votre commande build Docker :
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)
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Serverless
If you are using Serverless, you have several options depending on your serverless application’s setup.
Option 1: Bundler plugin
If you’re bundling your application from a Git directory, you can use plugins to inject Git metadata into the runtime bundle.
Bundling with esbuild
Use the dd-trace/esbuild
plugin to automatically inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. See the plugin documentation.
Install dd-trace
v5.68.0 or later for automatic Git tag injection.
const esbuild = require('esbuild');
+ const ddPlugin = require('dd-trace/esbuild');
esbuild.build({
entryPoints: ['index.js'],
bundle: true,
platform: 'node',
target: ['node20'],
format: 'cjs',
outfile: 'dist/bundle.js',
packages: 'external',
external: ['dd-trace', 'express']
+ plugins: [ddPlugin],
}).catch((e) => {
console.error(e);
process.exit(1);
});
Bundling with Rollup
Use rollup-plugin-inject-process-env to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const injectProcessEnv = require('rollup-plugin-inject-process-env');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
external: [
'express',
'dd-trace'
],
plugins: [
nodeResolve(),
commonjs()
+ injectProcessEnv({
+ DD_GIT_REPOSITORY_URL,
+ DD_GIT_COMMIT_SHA
+ })
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
Bundling with webpack
Use the BannerPlugin to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const webpack = require('webpack');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
target: 'node',
entry: './index.js',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'commonjs2'
},
externals: [
'express',
'dd-trace'
],
plugins: [
+ new webpack.BannerPlugin({
+ raw: true,
+ entryOnly: true,
+ banner:
+ `process.env.DD_GIT_REPOSITORY_URL=${JSON.stringify(DD_GIT_REPOSITORY_URL)};` +
+ `process.env.DD_GIT_COMMIT_SHA=${JSON.stringify(DD_GIT_COMMIT_SHA)};`,
+ }),
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
- Outil CLI Datadog
- Utilisez la version 2.4.1 ou une version ultérieure du client
datadog-ci
. Vous devez exécuter l’outil CLI dans le même répertoire que le référentiel de code. - Plug-in Serverless Datadog
- Utilisez la version 5.18.0 ou une version ultérieure du plug-in.
- CDK Construct Datadog
- Utilisez la version 0.8.5 ou une version ultérieure de
datadog-cdk-constructs
pour AWS CDK v1.Utilisez la version 1.4.0 ou une version ultérieure de datadog-cdk-constructs
pour AWS CDK v2.
Option 3: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Host
For host-based environments, you have two options based on your build and deploy configuration.
Option 1: Bundler plugin
If you’re bundling your application from a Git directory, you can use plugins to inject Git metadata into the runtime bundle.
Bundling with esbuild
Use the dd-trace/esbuild
plugin to automatically inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. See the plugin documentation.
Install dd-trace
v5.68.0 or later for automatic Git tag injection.
const esbuild = require('esbuild');
+ const ddPlugin = require('dd-trace/esbuild');
esbuild.build({
entryPoints: ['index.js'],
bundle: true,
platform: 'node',
target: ['node20'],
format: 'cjs',
outfile: 'dist/bundle.js',
packages: 'external',
external: ['dd-trace', 'express']
+ plugins: [ddPlugin],
}).catch((e) => {
console.error(e);
process.exit(1);
});
Bundling with Rollup
Use rollup-plugin-inject-process-env to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const injectProcessEnv = require('rollup-plugin-inject-process-env');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
external: [
'express',
'dd-trace'
],
plugins: [
nodeResolve(),
commonjs()
+ injectProcessEnv({
+ DD_GIT_REPOSITORY_URL,
+ DD_GIT_COMMIT_SHA
+ })
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
Bundling with webpack
Use the BannerPlugin to inject DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
in your runtime bundle. Run the bundle step inside a Git repository so the script can read .git/
information.
+ const webpack = require('webpack');
+ const { DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA } = getGitInfo();
module.exports = {
target: 'node',
entry: './index.js',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'commonjs2'
},
externals: [
'express',
'dd-trace'
],
plugins: [
+ new webpack.BannerPlugin({
+ raw: true,
+ entryOnly: true,
+ banner:
+ `process.env.DD_GIT_REPOSITORY_URL=${JSON.stringify(DD_GIT_REPOSITORY_URL)};` +
+ `process.env.DD_GIT_COMMIT_SHA=${JSON.stringify(DD_GIT_COMMIT_SHA)};`,
+ }),
]
};
The getGitInfo()
function executes git commands to return DD_GIT_REPOSITORY_URL
and DD_GIT_COMMIT_SHA
variables. It needs to be executed in the git repository.
const { execSync } = require('child_process');
function getGitInfo() {
try {
const commitSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const repositoryUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
console.log('Build-time Git metadata:', {
commitSha,
repositoryUrl,
});
return {
DD_GIT_REPOSITORY_URL: repositoryUrl,
DD_GIT_COMMIT_SHA: commitSha,
};
} catch (error) {
console.warn('Could not get Git metadata at build time:', error.message);
return {
DD_GIT_REPOSITORY_URL: '',
DD_GIT_COMMIT_SHA: '',
};
}
}
Option 2: DD_GIT_*
Environment Variables
Configurez votre application avec les variables d’environnement DD_GIT_*
:
export DD_GIT_COMMIT_SHA="<commit_Sha>"
export DD_GIT_REPOSITORY_URL="<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
The Ruby client library version 1.6.0 or later is required.
Containers
If you are using Docker containers, you have two options: using Docker or configuring your application with the DD_TAGS
environment variable.
Option 1: Docker
Ajoutez les lignes suivantes dans le Dockerfile de votre application :
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}"
Ajoutez les arguments suivants à votre commande build Docker :
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)
Configurez votre application avec la variable d’environnement DD_TAGS
:
export DD_TAGS="git.commit.sha:<commit_Sha>,git.repository_url:<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Serverless
If you are using Serverless, you have two options depending on your serverless application’s setup.
- Outil CLI Datadog
- Utilisez la version 2.4.1 ou une version ultérieure du client
datadog-ci
. Vous devez exécuter l’outil CLI dans le même répertoire que le référentiel de code. - Plug-in Serverless Datadog
- Utilisez la version 5.18.0 ou une version ultérieure du plug-in.
- CDK Construct Datadog
- Utilisez la version 0.8.5 ou une version ultérieure de
datadog-cdk-constructs
pour AWS CDK v1.Utilisez la version 1.4.0 ou une version ultérieure de datadog-cdk-constructs
pour AWS CDK v2.
Configurez votre application avec la variable d’environnement DD_TAGS
:
export DD_TAGS="git.commit.sha:<commit_Sha>,git.repository_url:<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.
Host
If you are using a host, configure your application with the DD_TAGS
environment variable.
Configurez votre application avec la variable d’environnement DD_TAGS
:
export DD_TAGS="git.commit.sha:<commit_Sha>,git.repository_url:<git-provider.example/me/my-repo>"
Remplacez <commit_Sha>
par le SHA du commit servant à build votre application. Pour l’obtenir, exécutez git rev-parse HEAD
lors du build. Le SHA doit être passé aux variables d’environnement du runtime.