From be6fbd973f50d729f9379ae1b5faba8270954bb5 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 11:53:56 -0400 Subject: [PATCH 01/52] update containers overview page with tabs --- .../serverless/google_cloud_run/containers.md | 23 ++++++++++++++----- .../google-cloud-run-container-options.html | 21 ----------------- 2 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 layouts/shortcodes/google-cloud-run-container-options.html diff --git a/content/en/serverless/google_cloud_run/containers.md b/content/en/serverless/google_cloud_run/containers.md index a1146e10ce832..c3cd8ca0b2e65 100644 --- a/content/en/serverless/google_cloud_run/containers.md +++ b/content/en/serverless/google_cloud_run/containers.md @@ -15,11 +15,8 @@ further_reading: text: 'Instrument your container with the sidecar approach' --- -To instrument your Google Cloud Run containers with Datadog, choose one of two options: - -{{% google-cloud-run-container-options %}} - -- [**In-process**][1]: Wraps your application container with the Datadog Agent. Choose this option for a simpler setup, lower cost overhead, and direct log piping. +You have two options for instrumenting your Cloud Run containers with Datadog: +- [**In-process**][1]: Wraps your application container with the Datadog Agent. Choose this option for a simpler setup, lower cost overhead, and direct log piping. - [**Sidecar**][2]: Deploys the Datadog Agent in a separate container alongside your app container. Choose this option if you have multiple containers in a single service, if you prefer strict isolation of the Datadog Agent, or if you have performance-sensitive workloads. ## Comparison: in-process versus sidecar instrumentation @@ -32,11 +29,25 @@ To instrument your Google Cloud Run containers with Datadog, choose one of two o | Logging | Direct stdout/stderr access. | Shared volume + log library routing to a log file. Uncaught errors require extra handling, since they are not automatically handled by your logging library. | | Failure isolation | In rare cases, Datadog Agent bugs can affect your app. | Datadog Agent faults are isolated. | | Observing multiple containers | Not supported | Supported | +## Installation + +{{< programming-lang-wrapper langs="In-Process,Sidecar" >}} + +{{< programming-lang lang="In-Process" >}} +[//]: # (TODO temp) +{{< partial name="serverless/getting-started-languages.html" >}} +{{< /programming-lang >}} + +{{< programming-lang lang="Sidecar" >}} +[//]: # (TODO temp) +{{< partial name="serverless/getting-started-languages.html" >}} +{{< /programming-lang >}} +{{< /programming-lang-wrapper >}} ## Further reading {{< partial name="whats-next/whats-next.html" >}} [1]: /serverless/google_cloud_run/containers_in_process -[2]: /serverless/google_cloud_run/containers_sidecar \ No newline at end of file +[2]: /serverless/google_cloud_run/containers_sidecar diff --git a/layouts/shortcodes/google-cloud-run-container-options.html b/layouts/shortcodes/google-cloud-run-container-options.html deleted file mode 100644 index e78d49c229ed2..0000000000000 --- a/layouts/shortcodes/google-cloud-run-container-options.html +++ /dev/null @@ -1,21 +0,0 @@ -
- -
-
From 9980e701126c1a987b586d984581e819adf07e77 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 12:14:47 -0400 Subject: [PATCH 02/52] create empty pages for each in-process language --- .../serverless/google_cloud_run/containers.md | 8 +-- .../google_cloud_run/in_process/dotnet.md | 1 + .../google_cloud_run/in_process/go.md | 2 + .../google_cloud_run/in_process/java.md | 1 + .../google_cloud_run/in_process/nodejs.md | 1 + .../google_cloud_run/in_process/php.md | 1 + .../google_cloud_run/in_process/python.md | 1 + .../google_cloud_run/in_process/ruby.md | 1 + .../serverless/in-process-languages.html | 57 +++++++++++++++++++ .../serverless/sidecar-languages.html | 57 +++++++++++++++++++ 10 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 content/en/serverless/google_cloud_run/in_process/dotnet.md create mode 100644 content/en/serverless/google_cloud_run/in_process/go.md create mode 100644 content/en/serverless/google_cloud_run/in_process/java.md create mode 100644 content/en/serverless/google_cloud_run/in_process/nodejs.md create mode 100644 content/en/serverless/google_cloud_run/in_process/php.md create mode 100644 content/en/serverless/google_cloud_run/in_process/python.md create mode 100644 content/en/serverless/google_cloud_run/in_process/ruby.md create mode 100644 layouts/partials/serverless/in-process-languages.html create mode 100644 layouts/partials/serverless/sidecar-languages.html diff --git a/content/en/serverless/google_cloud_run/containers.md b/content/en/serverless/google_cloud_run/containers.md index c3cd8ca0b2e65..6867223271895 100644 --- a/content/en/serverless/google_cloud_run/containers.md +++ b/content/en/serverless/google_cloud_run/containers.md @@ -34,13 +34,13 @@ You have two options for instrumenting your Cloud Run containers with Datadog: {{< programming-lang-wrapper langs="In-Process,Sidecar" >}} {{< programming-lang lang="In-Process" >}} -[//]: # (TODO temp) -{{< partial name="serverless/getting-started-languages.html" >}} +Choose a language to instrument in-process. +{{< partial name="serverless/in-process-languages.html" >}} {{< /programming-lang >}} {{< programming-lang lang="Sidecar" >}} -[//]: # (TODO temp) -{{< partial name="serverless/getting-started-languages.html" >}} +Choose a language to instrument via sidecar. +{{< partial name="serverless/sidecar-languages.html" >}} {{< /programming-lang >}} {{< /programming-lang-wrapper >}} diff --git a/content/en/serverless/google_cloud_run/in_process/dotnet.md b/content/en/serverless/google_cloud_run/in_process/dotnet.md new file mode 100644 index 0000000000000..484898525f44a --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/dotnet.md @@ -0,0 +1 @@ +## .NET diff --git a/content/en/serverless/google_cloud_run/in_process/go.md b/content/en/serverless/google_cloud_run/in_process/go.md new file mode 100644 index 0000000000000..f45dc9f6b71fd --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/go.md @@ -0,0 +1,2 @@ +## Go + diff --git a/content/en/serverless/google_cloud_run/in_process/java.md b/content/en/serverless/google_cloud_run/in_process/java.md new file mode 100644 index 0000000000000..41910f049db3b --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/java.md @@ -0,0 +1 @@ +## Java diff --git a/content/en/serverless/google_cloud_run/in_process/nodejs.md b/content/en/serverless/google_cloud_run/in_process/nodejs.md new file mode 100644 index 0000000000000..1b0024ba03422 --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/nodejs.md @@ -0,0 +1 @@ +## Nodejs diff --git a/content/en/serverless/google_cloud_run/in_process/php.md b/content/en/serverless/google_cloud_run/in_process/php.md new file mode 100644 index 0000000000000..eb703107e03b9 --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/php.md @@ -0,0 +1 @@ +## PHP diff --git a/content/en/serverless/google_cloud_run/in_process/python.md b/content/en/serverless/google_cloud_run/in_process/python.md new file mode 100644 index 0000000000000..c1faeb00630f8 --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/python.md @@ -0,0 +1 @@ +## Python diff --git a/content/en/serverless/google_cloud_run/in_process/ruby.md b/content/en/serverless/google_cloud_run/in_process/ruby.md new file mode 100644 index 0000000000000..337bd7435c7a7 --- /dev/null +++ b/content/en/serverless/google_cloud_run/in_process/ruby.md @@ -0,0 +1 @@ +## Ruby diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html new file mode 100644 index 0000000000000..65ccf35c21df6 --- /dev/null +++ b/layouts/partials/serverless/in-process-languages.html @@ -0,0 +1,57 @@ +{{ $dot := . }} + +
diff --git a/layouts/partials/serverless/sidecar-languages.html b/layouts/partials/serverless/sidecar-languages.html new file mode 100644 index 0000000000000..20b1f67e95120 --- /dev/null +++ b/layouts/partials/serverless/sidecar-languages.html @@ -0,0 +1,57 @@ +{{ $dot := . }} + +
From b3562b8dabd71c706cb60744f451c381f869505f Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 12:26:28 -0400 Subject: [PATCH 03/52] fill out nodejs in-process --- .../google_cloud_run/in_process/nodejs.md | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/in_process/nodejs.md b/content/en/serverless/google_cloud_run/in_process/nodejs.md index 1b0024ba03422..0f55f18f31e17 100644 --- a/content/en/serverless/google_cloud_run/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/in_process/nodejs.md @@ -1 +1,54 @@ -## Nodejs +--- +title: Instrumenting a Node.js Cloud Run Container In-Process +further_reading: +- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started' + tag: 'Documentation' + text: 'Tracing Node.js Applications' +--- + +## 1. Install the Tracer + +In your main application, add the `dd-trace-js` library. + +```shell +$ npm install dd-trace --save +``` + +Add the following environment variable to your main app: `ENV NODE_OPTIONS=“--require dd-trace/init”`. This specifies that the dd-trace/init module is required when the Node.js process starts. + +Finally, add this to your application code to initialize the tracer: +```javascript +const tracer = require('dd-trace').init({ + logInjection: true, +}); +``` + +For more information, see [Tracing Node.js applications](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started). + +## 2. Install Serverless-Init + +{{% svl-init-nodejs %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: +```javascript +const tracer = require('dd-trace').init({ + logInjection: true, +}); +const { createLogger, format, transports } = require('winston'); + +const logger = createLogger({ + level: 'info', + exitOnError: false, + format: format.json(), + transports: [ + new transports.File({ filename: `/shared-volume/logs/app.log` }), + new transports.Console() + ], +}); + +logger.info(`Hello world!`); +``` From e5a83d81d2c40eb93012a795f0f75c28f63b10d3 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 12:51:19 -0400 Subject: [PATCH 04/52] fix layout --- layouts/partials/serverless/in-process-languages.html | 2 +- layouts/partials/serverless/sidecar-languages.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html index 65ccf35c21df6..220809a54261e 100644 --- a/layouts/partials/serverless/in-process-languages.html +++ b/layouts/partials/serverless/in-process-languages.html @@ -1,7 +1,7 @@ {{ $dot := . }}
-
+
diff --git a/layouts/partials/serverless/sidecar-languages.html b/layouts/partials/serverless/sidecar-languages.html index 20b1f67e95120..447b5fa57c2e5 100644 --- a/layouts/partials/serverless/sidecar-languages.html +++ b/layouts/partials/serverless/sidecar-languages.html @@ -1,7 +1,7 @@ {{ $dot := . }}
-
+
From a92a8663917448f24d146d5afa2a88fdf27cea2a Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 13:16:09 -0400 Subject: [PATCH 05/52] fix layout --- layouts/partials/serverless/in-process-languages.html | 3 ++- layouts/partials/serverless/sidecar-languages.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html index 220809a54261e..83528c7e87182 100644 --- a/layouts/partials/serverless/in-process-languages.html +++ b/layouts/partials/serverless/in-process-languages.html @@ -1,7 +1,7 @@ {{ $dot := . }}
-
+
+
diff --git a/layouts/partials/serverless/sidecar-languages.html b/layouts/partials/serverless/sidecar-languages.html index 447b5fa57c2e5..8461770f04656 100644 --- a/layouts/partials/serverless/sidecar-languages.html +++ b/layouts/partials/serverless/sidecar-languages.html @@ -1,7 +1,7 @@ {{ $dot := . }}
-
+
+
From 3b2860051bf15332573371f253e4fc350a6e760d Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 13:30:20 -0400 Subject: [PATCH 06/52] cleanup nodejs page; fix links --- .../dotnet.md | 0 .../go.md | 0 .../java.md | 0 .../container_in_process/nodejs.md | 108 ++++++++++++++++++ .../php.md | 0 .../python.md | 0 .../ruby.md | 0 .../google_cloud_run/in_process/nodejs.md | 54 --------- .../serverless/in-process-languages.html | 14 +-- 9 files changed, 115 insertions(+), 61 deletions(-) rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/dotnet.md (100%) rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/go.md (100%) rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/java.md (100%) create mode 100644 content/en/serverless/google_cloud_run/container_in_process/nodejs.md rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/php.md (100%) rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/python.md (100%) rename content/en/serverless/google_cloud_run/{in_process => container_in_process}/ruby.md (100%) delete mode 100644 content/en/serverless/google_cloud_run/in_process/nodejs.md diff --git a/content/en/serverless/google_cloud_run/in_process/dotnet.md b/content/en/serverless/google_cloud_run/container_in_process/dotnet.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/dotnet.md rename to content/en/serverless/google_cloud_run/container_in_process/dotnet.md diff --git a/content/en/serverless/google_cloud_run/in_process/go.md b/content/en/serverless/google_cloud_run/container_in_process/go.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/go.md rename to content/en/serverless/google_cloud_run/container_in_process/go.md diff --git a/content/en/serverless/google_cloud_run/in_process/java.md b/content/en/serverless/google_cloud_run/container_in_process/java.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/java.md rename to content/en/serverless/google_cloud_run/container_in_process/java.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/nodejs.md b/content/en/serverless/google_cloud_run/container_in_process/nodejs.md new file mode 100644 index 0000000000000..ba0295ba85002 --- /dev/null +++ b/content/en/serverless/google_cloud_run/container_in_process/nodejs.md @@ -0,0 +1,108 @@ +--- +title: Instrumenting a Node.js Cloud Run Container In-Process +further_reading: +- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started' + tag: 'Documentation' + text: 'Tracing Node.js Applications' +--- + +## 1. Install the Tracer + +In your main application, add the `dd-trace-js` library. + +```shell +npm install dd-trace --save +``` + +Then, add this to your application code to initialize the tracer: +```javascript +const tracer = require('dd-trace').init({ + logInjection: true, +}); +``` + +For more information, see [Tracing Node.js applications](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started). + +## 2. Install Serverless-Init + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +ENV NODE_OPTIONS="--require dd-trace/init" +ENV DD_SERVICE=datadog-demo-run-nodejs +ENV DD_ENV=datadog-demo +ENV DD_VERSION=1 +ENTRYPOINT ["/app/datadog-init"] +CMD ["/nodejs/bin/node", "/path/to/your/app.js"] +``` + +#### Explanation + +1. Copy the Datadog `serverless-init` into your Docker image. + + ```dockerfile + COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init + ``` + +2. Specify that the `dd-trace/init` module is required when the Node.js process starts. + + ```dockerfile + ENV NODE_OPTIONS="--require dd-trace/init" + ``` + +3. (Optional) Add Datadog tags. + + ```dockerfile + ENV DD_SERVICE=datadog-demo-run-nodejs + ENV DD_ENV=datadog-demo + ENV DD_VERSION=1 + ``` + +4. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. + **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). + + ```dockerfile + ENTRYPOINT ["/app/datadog-init"] + ``` + +5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. + ```dockerfile + CMD ["node", "/path/to/your/app.js"] + ``` + +#### Alternative configuration {#alt-node} +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +RUN npm install --prefix /dd_tracer/node dd-trace --save +ENV DD_SERVICE=datadog-demo-run-nodejs +ENV DD_ENV=datadog-demo +ENV DD_VERSION=1 +CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] +``` + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: +```javascript +const tracer = require('dd-trace').init({ + logInjection: true, +}); +const { createLogger, format, transports } = require('winston'); + +const logger = createLogger({ + level: 'info', + exitOnError: false, + format: format.json(), + transports: [ + new transports.File({ filename: `/shared-volume/logs/app.log` }), + new transports.Console() + ], +}); + +logger.info(`Hello world!`); +``` diff --git a/content/en/serverless/google_cloud_run/in_process/php.md b/content/en/serverless/google_cloud_run/container_in_process/php.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/php.md rename to content/en/serverless/google_cloud_run/container_in_process/php.md diff --git a/content/en/serverless/google_cloud_run/in_process/python.md b/content/en/serverless/google_cloud_run/container_in_process/python.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/python.md rename to content/en/serverless/google_cloud_run/container_in_process/python.md diff --git a/content/en/serverless/google_cloud_run/in_process/ruby.md b/content/en/serverless/google_cloud_run/container_in_process/ruby.md similarity index 100% rename from content/en/serverless/google_cloud_run/in_process/ruby.md rename to content/en/serverless/google_cloud_run/container_in_process/ruby.md diff --git a/content/en/serverless/google_cloud_run/in_process/nodejs.md b/content/en/serverless/google_cloud_run/in_process/nodejs.md deleted file mode 100644 index 0f55f18f31e17..0000000000000 --- a/content/en/serverless/google_cloud_run/in_process/nodejs.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: Instrumenting a Node.js Cloud Run Container In-Process -further_reading: -- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started' - tag: 'Documentation' - text: 'Tracing Node.js Applications' ---- - -## 1. Install the Tracer - -In your main application, add the `dd-trace-js` library. - -```shell -$ npm install dd-trace --save -``` - -Add the following environment variable to your main app: `ENV NODE_OPTIONS=“--require dd-trace/init”`. This specifies that the dd-trace/init module is required when the Node.js process starts. - -Finally, add this to your application code to initialize the tracer: -```javascript -const tracer = require('dd-trace').init({ - logInjection: true, -}); -``` - -For more information, see [Tracing Node.js applications](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started). - -## 2. Install Serverless-Init - -{{% svl-init-nodejs %}} - -## 3. Setup Logs - -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. - -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: -```javascript -const tracer = require('dd-trace').init({ - logInjection: true, -}); -const { createLogger, format, transports } = require('winston'); - -const logger = createLogger({ - level: 'info', - exitOnError: false, - format: format.json(), - transports: [ - new transports.File({ filename: `/shared-volume/logs/app.log` }), - new transports.Console() - ], -}); - -logger.info(`Hello world!`); -``` diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html index 83528c7e87182..f689e9fa27684 100644 --- a/layouts/partials/serverless/in-process-languages.html +++ b/layouts/partials/serverless/in-process-languages.html @@ -3,21 +3,21 @@
- +
{{ partial "img.html" (dict "root" . "src" "integrations_logos/php.png" "class" "img-fluid" "alt" "PHP" "width" "400") }}
From e71bead97e7e33eb9b593ad6bbd55f37c917da4b Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 13:42:33 -0400 Subject: [PATCH 07/52] reorganize files --- .../{containers.md => containers/_index.md} | 8 ++++---- .../in_process/_index.md} | 0 .../in_process}/dotnet.md | 0 .../in_process}/go.md | 0 .../in_process}/java.md | 0 .../in_process}/nodejs.md | 0 .../in_process}/php.md | 0 .../in_process}/python.md | 0 .../in_process}/ruby.md | 0 .../sidecar/_index.md} | 0 .../partials/serverless/in-process-languages.html | 14 +++++++------- layouts/partials/serverless/sidecar-languages.html | 14 +++++++------- 12 files changed, 18 insertions(+), 18 deletions(-) rename content/en/serverless/google_cloud_run/{containers.md => containers/_index.md} (94%) rename content/en/serverless/google_cloud_run/{containers_in_process.md => containers/in_process/_index.md} (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/dotnet.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/go.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/java.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/nodejs.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/php.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/python.md (100%) rename content/en/serverless/google_cloud_run/{container_in_process => containers/in_process}/ruby.md (100%) rename content/en/serverless/google_cloud_run/{containers_sidecar.md => containers/sidecar/_index.md} (100%) diff --git a/content/en/serverless/google_cloud_run/containers.md b/content/en/serverless/google_cloud_run/containers/_index.md similarity index 94% rename from content/en/serverless/google_cloud_run/containers.md rename to content/en/serverless/google_cloud_run/containers/_index.md index 6867223271895..3950ed9564d56 100644 --- a/content/en/serverless/google_cloud_run/containers.md +++ b/content/en/serverless/google_cloud_run/containers/_index.md @@ -7,10 +7,10 @@ further_reading: - link: 'https://www.datadoghq.com/blog/collect-traces-logs-from-cloud-run-with-datadog/' tag: 'Blog' text: 'Collect traces, logs, and custom metrics from Cloud Run services' - - link: "/serverless/google_cloud_run/containers_in_process/" + - link: "/serverless/google_cloud_run/containers/in_process/" tag: 'Documentation' text: 'Instrument your container with the in-process approach' - - link: "/serverless/google_cloud_run/containers_sidecar/" + - link: "/serverless/google_cloud_run/containers/sidecar/" tag: 'Documentation' text: 'Instrument your container with the sidecar approach' --- @@ -49,5 +49,5 @@ Choose a language to instrument via sidecar. {{< partial name="whats-next/whats-next.html" >}} -[1]: /serverless/google_cloud_run/containers_in_process -[2]: /serverless/google_cloud_run/containers_sidecar +[1]: /serverless/google_cloud_run/containers/in_process +[2]: /serverless/google_cloud_run/containers/sidecar diff --git a/content/en/serverless/google_cloud_run/containers_in_process.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md similarity index 100% rename from content/en/serverless/google_cloud_run/containers_in_process.md rename to content/en/serverless/google_cloud_run/containers/in_process/_index.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/dotnet.md rename to content/en/serverless/google_cloud_run/containers/in_process/dotnet.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/go.md rename to content/en/serverless/google_cloud_run/containers/in_process/go.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/java.md rename to content/en/serverless/google_cloud_run/containers/in_process/java.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/nodejs.md rename to content/en/serverless/google_cloud_run/containers/in_process/nodejs.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/php.md rename to content/en/serverless/google_cloud_run/containers/in_process/php.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/python.md rename to content/en/serverless/google_cloud_run/containers/in_process/python.md diff --git a/content/en/serverless/google_cloud_run/container_in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md similarity index 100% rename from content/en/serverless/google_cloud_run/container_in_process/ruby.md rename to content/en/serverless/google_cloud_run/containers/in_process/ruby.md diff --git a/content/en/serverless/google_cloud_run/containers_sidecar.md b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md similarity index 100% rename from content/en/serverless/google_cloud_run/containers_sidecar.md rename to content/en/serverless/google_cloud_run/containers/sidecar/_index.md diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html index f689e9fa27684..83528c7e87182 100644 --- a/layouts/partials/serverless/in-process-languages.html +++ b/layouts/partials/serverless/in-process-languages.html @@ -3,21 +3,21 @@
- +
{{ partial "img.html" (dict "root" . "src" "integrations_logos/php.png" "class" "img-fluid" "alt" "PHP" "width" "400") }}
diff --git a/layouts/partials/serverless/sidecar-languages.html b/layouts/partials/serverless/sidecar-languages.html index 8461770f04656..cdcafb98894fa 100644 --- a/layouts/partials/serverless/sidecar-languages.html +++ b/layouts/partials/serverless/sidecar-languages.html @@ -3,21 +3,21 @@
- +
{{ partial "img.html" (dict "root" . "src" "integrations_logos/php.png" "class" "img-fluid" "alt" "PHP" "width" "400") }}
From 6cf507380e7afc42d1330eb8b7f9fe309b47264c Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 14:33:02 -0400 Subject: [PATCH 08/52] add configuration section --- .../containers/in_process/nodejs.md | 30 ++++++++-------- layouts/shortcodes/gcr-configure-env-vars.md | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 layouts/shortcodes/gcr-configure-env-vars.md diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index ba0295ba85002..6ccb2da6738cd 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -1,7 +1,7 @@ --- title: Instrumenting a Node.js Cloud Run Container In-Process further_reading: -- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started' +- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/' tag: 'Documentation' text: 'Tracing Node.js Applications' --- @@ -21,7 +21,7 @@ const tracer = require('dd-trace').init({ }); ``` -For more information, see [Tracing Node.js applications](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started). +For more information, see [Tracing Node.js applications][1]. ## 2. Install Serverless-Init @@ -30,9 +30,6 @@ Add the following instructions and arguments to your Dockerfile. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init ENV NODE_OPTIONS="--require dd-trace/init" -ENV DD_SERVICE=datadog-demo-run-nodejs -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 ENTRYPOINT ["/app/datadog-init"] CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ``` @@ -51,22 +48,14 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ENV NODE_OPTIONS="--require dd-trace/init" ``` -3. (Optional) Add Datadog tags. - - ```dockerfile - ENV DD_SERVICE=datadog-demo-run-nodejs - ENV DD_ENV=datadog-demo - ENV DD_VERSION=1 - ``` - -4. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. +3. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). ```dockerfile ENTRYPOINT ["/app/datadog-init"] ``` -5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. +4. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. ```dockerfile CMD ["node", "/path/to/your/app.js"] ``` @@ -99,10 +88,19 @@ const logger = createLogger({ exitOnError: false, format: format.json(), transports: [ - new transports.File({ filename: `/shared-volume/logs/app.log` }), new transports.Console() ], }); logger.info(`Hello world!`); ``` + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ diff --git a/layouts/shortcodes/gcr-configure-env-vars.md b/layouts/shortcodes/gcr-configure-env-vars.md new file mode 100644 index 0000000000000..fac60b4ec3405 --- /dev/null +++ b/layouts/shortcodes/gcr-configure-env-vars.md @@ -0,0 +1,34 @@ +After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: + +- `DD_API_KEY`: Datadog API key, used to send data to your Datadog account. It should be configured as a Google Cloud Secret for privacy and safety. +- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. Your site is: {{< region-param key="dd_site" code="true" >}}. + +For more environment variables and their function, see [Environment Variables](#environment-variables). + +The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. + +```shell +gcloud run deploy + --image=gcr.io// \ + --port=8080 \ + --update-env-vars=DD_API_KEY=$DD_API_KEY \ + --update-env-vars=DD_SITE=$DD_SITE \ +``` + +### Environment variables + +| Variable | Description | +| -------- | ----------- | +| `DD_API_KEY` | [Datadog API key][1] - **Required**| +| `DD_SITE` | [Datadog site][2] - **Required** | +| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | +| `DD_SERVICE` | See [Unified Service Tagging][3]. | +| `DD_VERSION` | See [Unified Service Tagging][3]. | +| `DD_ENV` | See [Unified Service Tagging][3]. | +| `DD_SOURCE` | See [Unified Service Tagging][3]. | +| `DD_TAGS` | See [Unified Service Tagging][3]. | + + +[1]: /account_management/api-app-keys/#api-keys +[2]: /getting_started/site/ +[3]: /getting_started/tagging/unified_service_tagging/ From c1241d7cec1786781214c07016b92fdae8131559 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 15:03:32 -0400 Subject: [PATCH 09/52] update tab structure --- .../containers/in_process/_index.md | 195 +----------------- .../containers/in_process/dotnet.md | 7 + .../containers/in_process/go.md | 7 + .../containers/in_process/java.md | 7 + .../containers/in_process/nodejs.md | 3 + .../containers/in_process/php.md | 7 + .../containers/in_process/python.md | 7 + .../containers/in_process/ruby.md | 7 + ...v-vars.md => gcr-configure-env-vars.en.md} | 6 +- 9 files changed, 50 insertions(+), 196 deletions(-) rename layouts/shortcodes/{gcr-configure-env-vars.md => gcr-configure-env-vars.en.md} (90%) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index 270f3a75960f9..1b86052603e27 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -1,195 +1,4 @@ --- title: Instrumenting Google Cloud Run Containers In-Process -further_reading: - -- link: 'https://www.datadoghq.com/blog/collect-traces-logs-from-cloud-run-with-datadog/' - tag: 'Blog' - text: 'Collect traces, logs, and custom metrics from Cloud Run services' - ---- - -## Overview - -Google Cloud Run is a fully managed serverless platform for deploying and scaling container-based applications. - -This page provides instructions for instrumenting your Google Cloud Run containers with the Datadog Agent, which enables tracing, custom metrics, and direct log collection. - -
- -
-Have you set up your Google Cloud integration? Datadog recommends setting up the integration, which collects metrics and logs from Google Cloud services, before proceeding on to instrumentation. Remember to add the cloud asset viewer role to your service account and enable the Cloud Asset Inventory API in Google Cloud. -
- -### Prerequisites - -Make sure you have a [Datadog API key][7] and are using a programming language [supported by a Datadog tracing library][2]. - -## Instrument your application - -Datadog publishes new releases of the `serverless-init` container image to Google’s gcr.io, AWS’s ECR, and on Docker Hub: - -| dockerhub.io | gcr.io | public.ecr.aws | -| ------------ | ------ | -------------- | -| datadog/serverless-init | gcr.io/datadoghq/serverless-init | public.ecr.aws/datadog/serverless-init | - -Images are tagged based on semantic versioning, with each new version receiving three relevant tags: - -* `1`, `1-alpine`: use these to track the latest minor releases, without breaking changes -* `1.x.x`, `1.x.x-alpine`: use these to pin to a precise version of the library -* `latest`, `latest-alpine`: use these to follow the latest version release, which may include breaking changes - -## How `serverless-init` works - -The `serverless-init` application wraps your process and executes it as a subprocess. It starts a DogStatsD listener for metrics and a Trace Agent listener for traces. It collects logs by wrapping the stdout/stderr streams of your application. After bootstrapping, serverless-init then launches your command as a subprocess. - -To get full instrumentation, ensure you are calling `datadog-init` as the first command that runs inside your Docker container. You can do this through by setting it as the entrypoint, or by setting it as the first argument in CMD. - -{{< programming-lang-wrapper langs="nodejs,python,java,go,dotnet,ruby,php" >}} -{{< programming-lang lang="nodejs" >}} - -{{% svl-init-nodejs %}} - -{{< /programming-lang >}} -{{< programming-lang lang="python" >}} - -{{% svl-init-python %}} - -{{< /programming-lang >}} -{{< programming-lang lang="java" >}} - -{{% svl-init-java %}} - -{{< /programming-lang >}} -{{< programming-lang lang="go" >}} - -{{% svl-init-go %}} - -{{< /programming-lang >}} -{{< programming-lang lang="dotnet" >}} - -{{% svl-init-dotnet %}} - -{{< /programming-lang >}} -{{< programming-lang lang="ruby" >}} - -{{% svl-init-ruby %}} - -{{< /programming-lang >}} -{{< programming-lang lang="php" >}} - -{{% svl-init-php %}} - -{{< /programming-lang >}} -{{< /programming-lang-wrapper >}} - -### Buildpack - -
Buildpack instrumentation is deprecated.
- -[`Pack Buildpacks`][3] provide a convenient way to package your container without using a Dockerfile. - -First, manually install your tracer: -- [Node.JS][14] -- [Python][13] -- [Java][15] -- [Go][12] -- [.NET][18] -- [Ruby][16] -- [PHP][17] - -Then, build your application by running the following command: - -```shell -pack build --builder=gcr.io/buildpacks/builder \ ---buildpack from=builder \ ---buildpack datadog/serverless-buildpack:latest \ -gcr.io// -``` - -**Note**: Buildpack instrumentation is not compatible with Alpine images. - -## Configure your application - -After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: -- `DD_API_KEY`: Datadog API key, used to send data to your Datadog account. It should be configured as a [Google Cloud Secret][11] for privacy and safety. -- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. Your site is: {{< region-param key="dd_site" code="true" >}}. - -For more environment variables and their function, see [Environment Variables](#environment-variables). - -The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. - -``` -shell -gcloud run deploy --image=gcr.io// \ - --port=8080 \ - --update-env-vars=DD_API_KEY=$DD_API_KEY \ - --update-env-vars=DD_SITE=$DD_SITE \ -``` - -See [all arguments and flags for `gcloud run deploy`][26]. - -## Results - -After the deployment is completed, your metrics and traces are sent to Datadog. In Datadog, navigate to **Infrastructure > Serverless** to see your serverless metrics and traces. - -## Additional configurations - -- **Advanced tracing:** The Datadog Agent already provides some basic tracing for popular frameworks. Follow the [advanced tracing guide][2] for more information. - -- **Logs:** If you use the [Google Cloud integration][1], your logs are already being collected. Alternatively, you can set the `DD_LOGS_ENABLED` environment variable to `true` to capture application logs through the serverless instrumentation directly. - -- **Custom metrics:** You can submit custom metrics using a [DogStatsD client][4]. For monitoring Cloud Run and other serverless applications, use [distribution][9] metrics. Distributions provide `avg`, `sum`, `max`, `min`, and `count` aggregations by default. On the Metric Summary page, you can enable percentile aggregations (p50, p75, p90, p95, p99) and also manage tags. To monitor a distribution for a gauge metric type, use `avg` for both the [time and space aggregations][11]. To monitor a distribution for a count metric type, use `sum` for both the time and space aggregations. - -### Environment variables - -| Variable | Description | -| -------- | ----------- | -|`DD_API_KEY`| [Datadog API key][7] - **Required**| -| `DD_SITE` | [Datadog site][5] - **Required** | -| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | -| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java][19], [Node][20], [.NET][21], and [PHP][22]. See additional docs for [Python][23], [Go][24], and [Ruby][25]. | -| `DD_SERVICE` | See [Unified Service Tagging][6]. | -| `DD_VERSION` | See [Unified Service Tagging][6]. | -| `DD_ENV` | See [Unified Service Tagging][6]. | -| `DD_SOURCE` | See [Unified Service Tagging][6]. | -| `DD_TAGS` | See [Unified Service Tagging][6]. | - -## Troubleshooting - -This integration depends on your runtime having a full SSL implementation. If you are using a slim image, you may need to add the following command to your Dockerfile to include certificates. - -``` -RUN apt-get update && apt-get install -y ca-certificates -``` - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - - -[1]: /integrations/google_cloud_platform/#log-collection -[2]: /tracing/trace_collection/#for-setup-instructions-select-your-language -[3]: https://buildpacks.io/docs/tools/pack/ -[4]: /metrics/custom_metrics/dogstatsd_metrics_submission/ -[5]: /getting_started/site/ -[6]: /getting_started/tagging/unified_service_tagging/ -[7]: /account_management/api-app-keys/#api-keys -[8]: https://github.com/DataDog/crpb/tree/main -[9]: /metrics/distributions/ -[10]: /metrics/#time-and-space-aggregation -[11]: https://cloud.google.com/run/docs/configuring/secrets -[12]: /tracing/trace_collection/library_config/go/ -[13]: /tracing/trace_collection/dd_libraries/python/?tab=containers#instrument-your-application -[14]: /tracing/trace_collection/dd_libraries/nodejs/?tab=containers#instrument-your-application -[15]: /tracing/trace_collection/dd_libraries/java/?tab=containers#instrument-your-application -[16]: /tracing/trace_collection/dd_libraries/ruby/?tab=containers#instrument-your-application -[17]: /tracing/trace_collection/dd_libraries/php/?tab=containers#install-the-extension -[18]: /tracing/trace_collection/dd_libraries/dotnet-core/?tab=linux#custom-instrumentation -[19]: /tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2 -[20]: /tracing/other_telemetry/connect_logs_and_traces/nodejs -[21]: /tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog -[22]: /tracing/other_telemetry/connect_logs_and_traces/php -[23]: /tracing/other_telemetry/connect_logs_and_traces/python -[24]: /tracing/other_telemetry/connect_logs_and_traces/go -[25]: /tracing/other_telemetry/connect_logs_and_traces/ruby -[26]: https://cloud.google.com/sdk/gcloud/reference/run/deploy +type: multi-code-lang +--- \ No newline at end of file diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 484898525f44a..f64729fbb4095 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -1 +1,8 @@ +--- +title: Instrumenting a .NET Cloud Run Container In-Process +code_lang: dotnet +type: multi-code-lang +code_lang_weight: 60 +--- + ## .NET diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index f45dc9f6b71fd..43476248b9c1c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -1,2 +1,9 @@ +--- +title: Instrumenting a Go Cloud Run Container In-Process +code_lang: go +type: multi-code-lang +code_lang_weight: 30 +--- + ## Go diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index 41910f049db3b..3f4755477aea3 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -1 +1,8 @@ +--- +title: Instrumenting a Java Cloud Run Container In-Process +code_lang: java +type: multi-code-lang +code_lang_weight: 40 +--- + ## Java diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 6ccb2da6738cd..6bd3769c56c9c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -1,5 +1,8 @@ --- title: Instrumenting a Node.js Cloud Run Container In-Process +code_lang: nodejs +type: multi-code-lang +code_lang_weight: 20 further_reading: - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/' tag: 'Documentation' diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index eb703107e03b9..32391e7598e7d 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -1 +1,8 @@ +--- +title: Instrumenting a PHP Cloud Run Container In-Process +code_lang: php +type: multi-code-lang +code_lang_weight: 70 +--- + ## PHP diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index c1faeb00630f8..1d71fce46b4b5 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -1 +1,8 @@ +--- +title: Instrumenting a Python Cloud Run Container In-Process +code_lang: python +type: multi-code-lang +code_lang_weight: 10 +--- + ## Python diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index 337bd7435c7a7..893de2b01f9d5 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -1 +1,8 @@ +--- +title: Instrumenting a Ruby Cloud Run Container In-Process +code_lang: ruby +type: multi-code-lang +code_lang_weight: 50 +--- + ## Ruby diff --git a/layouts/shortcodes/gcr-configure-env-vars.md b/layouts/shortcodes/gcr-configure-env-vars.en.md similarity index 90% rename from layouts/shortcodes/gcr-configure-env-vars.md rename to layouts/shortcodes/gcr-configure-env-vars.en.md index fac60b4ec3405..2156d3717752a 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -1,15 +1,15 @@ After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: - `DD_API_KEY`: Datadog API key, used to send data to your Datadog account. It should be configured as a Google Cloud Secret for privacy and safety. -- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. Your site is: {{< region-param key="dd_site" code="true" >}}. +- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. For more environment variables and their function, see [Environment Variables](#environment-variables). The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. ```shell -gcloud run deploy - --image=gcr.io// \ +gcloud run deploy <APP_NAME> + --image=gcr.io/<YOUR_PROJECT>/<APP_NAME> \ --port=8080 \ --update-env-vars=DD_API_KEY=$DD_API_KEY \ --update-env-vars=DD_SITE=$DD_SITE \ From ed939e0179479e8997c2397a65485b768455b494 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 16:52:32 -0400 Subject: [PATCH 10/52] add python instructions --- .../containers/in_process/nodejs.md | 5 +- .../containers/in_process/python.md | 89 ++++++++++++++++++- .../shortcodes/gcr-configure-env-vars.en.md | 8 ++ 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 6bd3769c56c9c..95c3d37692992 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -68,10 +68,7 @@ If you already have an entrypoint defined inside your Dockerfile, you can instea ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -RUN npm install --prefix /dd_tracer/node dd-trace --save -ENV DD_SERVICE=datadog-demo-run-nodejs -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 +RUN npm install --prefix /dd_tracer/node dd-trace --save CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] ``` diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 1d71fce46b4b5..f7bb65acdd360 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -5,4 +5,91 @@ type: multi-code-lang code_lang_weight: 10 --- -## Python +## 1. Install the Tracer + +Install the tracer in your Dockerfile: + +```Dockerfile +RUN pip install --target /dd_tracer/python/ ddtrace +``` + +For more information, see [Tracing Python applications][1]. + +## 2. Install Serverless-Init + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +#### Explanation + +1. Copy the Datadog `serverless-init` into your Docker image. + + ```dockerfile + COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init + ``` + +2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. + **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-python). + + ```dockerfile + ENTRYPOINT ["/app/datadog-init"] + ``` + +3. Execute your binary application wrapped in the tracer. Adapt this line to your needs. + ```dockerfile + CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] + ``` + +#### Alternative configuration {#alt-python} +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +We also recommend the following environment variables: +- `ENV PYTHONUNBUFFERED=1`: Ensure Python outputs appear immediately in container logs instead of being buffered. +- `ENV DD_SOURCE=python`: Enable Datadog log parsing. For more information, see [Correlating Python Logs and Traces][2]. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: +```python +import structlog + +def tracer_injection(logger, log_method, event_dict): + event_dict.update(tracer.get_log_correlation_context()) + return event_dict + +structlog.configure( + processors=[ + tracer_injection, + structlog.processors.EventRenamer("msg"), + structlog.processors.JSONRenderer() + ], + logger_factory=structlog.WriteLoggerFactory(file=sys.stdout), +) + +logger = structlog.get_logger() + +logger.info("Hello world!") +``` + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/python +[2]: /tracing/other_telemetry/connect_logs_and_traces/python/ diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 2156d3717752a..2ab4c0e60d83d 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -22,6 +22,7 @@ gcloud run deploy <APP_NAME> | `DD_API_KEY` | [Datadog API key][1] - **Required**| | `DD_SITE` | [Datadog site][2] - **Required** | | `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | +| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java][4], [Node.js][5], [.NET][6], and [PHP][7]. See additional docs for [Python][8], [Go][9], and [Ruby][10]. | | `DD_SERVICE` | See [Unified Service Tagging][3]. | | `DD_VERSION` | See [Unified Service Tagging][3]. | | `DD_ENV` | See [Unified Service Tagging][3]. | @@ -32,3 +33,10 @@ gcloud run deploy <APP_NAME> [1]: /account_management/api-app-keys/#api-keys [2]: /getting_started/site/ [3]: /getting_started/tagging/unified_service_tagging/ +[4]: /tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2 +[5]: /tracing/other_telemetry/connect_logs_and_traces/nodejs +[6]: /tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog +[7]: /tracing/other_telemetry/connect_logs_and_traces/php +[8]: /tracing/other_telemetry/connect_logs_and_traces/python +[9]: /tracing/other_telemetry/connect_logs_and_traces/go +[10]: /tracing/other_telemetry/connect_logs_and_traces/ruby From 46c3aa50645e73ef55243092d19d85f156469682 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 16:54:34 -0400 Subject: [PATCH 11/52] remove empty page --- .../google_cloud_run/containers/in_process/_index.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 content/en/serverless/google_cloud_run/containers/in_process/_index.md diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md deleted file mode 100644 index 1b86052603e27..0000000000000 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Instrumenting Google Cloud Run Containers In-Process -type: multi-code-lang ---- \ No newline at end of file From 9093187c082ef725fc8524a463bfb57511834181 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 16:58:34 -0400 Subject: [PATCH 12/52] make explanation and alternative configuration collapsible --- .../google_cloud_run/containers/in_process/nodejs.md | 7 +++++-- .../google_cloud_run/containers/in_process/python.md | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 95c3d37692992..6b2f0ca5b8bad 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -37,7 +37,7 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ``` -#### Explanation +{{< collapse "Explanation" >}} 1. Copy the Datadog `serverless-init` into your Docker image. @@ -63,7 +63,9 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] CMD ["node", "/path/to/your/app.js"] ``` -#### Alternative configuration {#alt-node} +{{< /collapse >}} + +{{< collapse "Alternative configuration" >}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile @@ -71,6 +73,7 @@ COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init RUN npm install --prefix /dd_tracer/node dd-trace --save CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] ``` +{{< /collapse >}} ## 3. Setup Logs diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index f7bb65acdd360..c819fcac04f10 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -25,7 +25,7 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -#### Explanation +{{< collapse "Explanation" >}} 1. Copy the Datadog `serverless-init` into your Docker image. @@ -45,13 +45,16 @@ CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py" CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -#### Alternative configuration {#alt-python} +{{< /collapse >}} + +{{< collapse "Alternative configuration" >}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` +{{< /collapse >}} ## 3. Setup Logs From bf988931e19861e7cfe436c7d6506658b7e18926 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 17:05:03 -0400 Subject: [PATCH 13/52] fix `gcloud run deploy` shell --- layouts/shortcodes/gcr-configure-env-vars.en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 2ab4c0e60d83d..25a73d1e7620b 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -8,8 +8,8 @@ For more environment variables and their function, see [Environment Variables](# The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. ```shell -gcloud run deploy <APP_NAME> - --image=gcr.io/<YOUR_PROJECT>/<APP_NAME> \ +gcloud run deploy + --image=gcr.io// \ --port=8080 \ --update-env-vars=DD_API_KEY=$DD_API_KEY \ --update-env-vars=DD_SITE=$DD_SITE \ From 574a44e219ec79f48916500dcd8783e67344f6ba Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 17:23:30 -0400 Subject: [PATCH 14/52] fix expandable content --- .../google_cloud_run/containers/in_process/nodejs.md | 12 ++++++++---- .../google_cloud_run/containers/in_process/python.md | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 6b2f0ca5b8bad..1fd6af0da4720 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -37,7 +37,8 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ``` -{{< collapse "Explanation" >}} +
+Explanation 1. Copy the Datadog `serverless-init` into your Docker image. @@ -63,9 +64,11 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] CMD ["node", "/path/to/your/app.js"] ``` -{{< /collapse >}} +
+ +
+Alternative configuration -{{< collapse "Alternative configuration" >}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile @@ -73,7 +76,8 @@ COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init RUN npm install --prefix /dd_tracer/node dd-trace --save CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] ``` -{{< /collapse >}} + +
## 3. Setup Logs diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index c819fcac04f10..c7e986924989f 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -25,7 +25,8 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -{{< collapse "Explanation" >}} +
+Explanation 1. Copy the Datadog `serverless-init` into your Docker image. @@ -45,16 +46,19 @@ CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py" CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -{{< /collapse >}} +
+ +
+Alternative configuration -{{< collapse "Alternative configuration" >}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -{{< /collapse >}} + +
## 3. Setup Logs From be52fa59341e803eeb4f83f1da003cf0b03ab0d5 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 17:28:56 -0400 Subject: [PATCH 15/52] fix languages tabs at top --- .../google_cloud_run/containers/_index.md | 21 ++----- .../containers/in_process/_index.md | 11 ++++ .../serverless/sidecar-languages.html | 58 ------------------- .../google-cloud-run-container-options.html | 21 +++++++ 4 files changed, 36 insertions(+), 75 deletions(-) create mode 100644 content/en/serverless/google_cloud_run/containers/in_process/_index.md delete mode 100644 layouts/partials/serverless/sidecar-languages.html create mode 100644 layouts/shortcodes/google-cloud-run-container-options.html diff --git a/content/en/serverless/google_cloud_run/containers/_index.md b/content/en/serverless/google_cloud_run/containers/_index.md index 3950ed9564d56..75eb9768098f7 100644 --- a/content/en/serverless/google_cloud_run/containers/_index.md +++ b/content/en/serverless/google_cloud_run/containers/_index.md @@ -15,7 +15,10 @@ further_reading: text: 'Instrument your container with the sidecar approach' --- -You have two options for instrumenting your Cloud Run containers with Datadog: +To instrument your Google Cloud Run containers with Datadog, choose one of two options: + +{{% google-cloud-run-container-options %}} + - [**In-process**][1]: Wraps your application container with the Datadog Agent. Choose this option for a simpler setup, lower cost overhead, and direct log piping. - [**Sidecar**][2]: Deploys the Datadog Agent in a separate container alongside your app container. Choose this option if you have multiple containers in a single service, if you prefer strict isolation of the Datadog Agent, or if you have performance-sensitive workloads. @@ -29,22 +32,6 @@ You have two options for instrumenting your Cloud Run containers with Datadog: | Logging | Direct stdout/stderr access. | Shared volume + log library routing to a log file. Uncaught errors require extra handling, since they are not automatically handled by your logging library. | | Failure isolation | In rare cases, Datadog Agent bugs can affect your app. | Datadog Agent faults are isolated. | | Observing multiple containers | Not supported | Supported | -## Installation - -{{< programming-lang-wrapper langs="In-Process,Sidecar" >}} - -{{< programming-lang lang="In-Process" >}} -Choose a language to instrument in-process. -{{< partial name="serverless/in-process-languages.html" >}} -{{< /programming-lang >}} - -{{< programming-lang lang="Sidecar" >}} -Choose a language to instrument via sidecar. -{{< partial name="serverless/sidecar-languages.html" >}} -{{< /programming-lang >}} - -{{< /programming-lang-wrapper >}} - ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md new file mode 100644 index 0000000000000..b97057ab7edd7 --- /dev/null +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -0,0 +1,11 @@ +--- +title: Instrumenting Google Cloud Run Containers In-Process +type: multi-code-lang +aliases: + - /serverless/google_cloud_run/containers/in_process/ +redirect: /serverless/google_cloud_run/containers/in_process/python/ +--- + +Instrument your application using one of the following guides: + +{{< partial name="serverless/in-process-languages.html" >}} diff --git a/layouts/partials/serverless/sidecar-languages.html b/layouts/partials/serverless/sidecar-languages.html deleted file mode 100644 index cdcafb98894fa..0000000000000 --- a/layouts/partials/serverless/sidecar-languages.html +++ /dev/null @@ -1,58 +0,0 @@ -{{ $dot := . }} - -
diff --git a/layouts/shortcodes/google-cloud-run-container-options.html b/layouts/shortcodes/google-cloud-run-container-options.html new file mode 100644 index 0000000000000..ec6c4025d80d3 --- /dev/null +++ b/layouts/shortcodes/google-cloud-run-container-options.html @@ -0,0 +1,21 @@ + +
From eee4c20029315ba90007aa39b0a7cffc6d00075f Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 17:52:24 -0400 Subject: [PATCH 16/52] update collapsible --- content/en/serverless/google_cloud_run/containers/_index.md | 2 +- .../serverless/google_cloud_run/containers/sidecar/_index.md | 2 +- layouts/shortcodes/google-cloud-run-container-options.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/_index.md b/content/en/serverless/google_cloud_run/containers/_index.md index 75eb9768098f7..8434c62081173 100644 --- a/content/en/serverless/google_cloud_run/containers/_index.md +++ b/content/en/serverless/google_cloud_run/containers/_index.md @@ -1,5 +1,5 @@ --- -title: Choosing an Instrumentation Method for Google Cloud Run Containers +title: Choosing an Instrumentation Method further_reading: - link: "/integrations/google-cloud-run/" tag: "Documentation" diff --git a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md index 7f2f83b69e595..2c510eb95c951 100644 --- a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md +++ b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md @@ -16,7 +16,7 @@ Google Cloud Run is a fully managed serverless platform for deploying and scalin This page provides instructions for instrumenting your Google Cloud Run containers with the Datadog Agent, which enables tracing, custom metrics, and direct log collection. The Datadog Agent runs in a sidecar container. -
To instrument your Google Cloud Run applications with an in-process approach, see Instrument Google Cloud Run In-Process.
+
To instrument your Google Cloud Run applications with an in-process approach, see Instrument Google Cloud Run In-Process.
Have you set up your Google Cloud integration? Datadog recommends setting up the integration, which collects metrics and logs from Google Cloud services, before proceeding on to instrumentation. Remember to add the cloud asset viewer role to your service account and enable the Cloud Asset Inventory API in Google Cloud. diff --git a/layouts/shortcodes/google-cloud-run-container-options.html b/layouts/shortcodes/google-cloud-run-container-options.html index ec6c4025d80d3..7fb999d5228ad 100644 --- a/layouts/shortcodes/google-cloud-run-container-options.html +++ b/layouts/shortcodes/google-cloud-run-container-options.html @@ -2,14 +2,14 @@
- +
Sidecar
From c66b10e7fb808d418d60b6f6b83b476c64279df1 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 18:27:10 -0400 Subject: [PATCH 17/52] fix links; update collapsible --- .../containers/in_process/nodejs.md | 10 +++---- .../containers/in_process/python.md | 10 +++---- .../shortcodes/gcr-configure-env-vars.en.md | 28 ++++++------------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 1fd6af0da4720..08967d3c86f75 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -37,8 +37,7 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ``` -
-Explanation +{{% collapse-content title="Explanation" level="h4" %}} 1. Copy the Datadog `serverless-init` into your Docker image. @@ -64,10 +63,9 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] CMD ["node", "/path/to/your/app.js"] ``` -
+{{% /collapse-content %}} -
-Alternative configuration +{{% collapse-content title="Alternative configuration" level="h4" id="alt-node" %}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. @@ -77,7 +75,7 @@ RUN npm install --prefix /dd_tracer/node dd-trace --save CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] ``` -
+{{% /collapse-content %}} ## 3. Setup Logs diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index c7e986924989f..1c3687dc658d1 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -25,8 +25,7 @@ ENTRYPOINT ["/app/datadog-init"] CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -
-Explanation +{{% collapse-content title="Explanation" level="h4" %}} 1. Copy the Datadog `serverless-init` into your Docker image. @@ -46,10 +45,9 @@ CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py" CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -
+{{% /collapse-content %}} -
-Alternative configuration +{{% collapse-content title="Alternative configuration" level="h4" id="alt-python" %}} If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. @@ -58,7 +56,7 @@ COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` -
+{{% /collapse-content %}} ## 3. Setup Logs diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 25a73d1e7620b..509c101af47f5 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -19,24 +19,12 @@ gcloud run deploy | Variable | Description | | -------- | ----------- | -| `DD_API_KEY` | [Datadog API key][1] - **Required**| -| `DD_SITE` | [Datadog site][2] - **Required** | +| `DD_API_KEY` | [Datadog API key](/account_management/api-app-keys/#api-keys) - **Required**| +| `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | | `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | -| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java][4], [Node.js][5], [.NET][6], and [PHP][7]. See additional docs for [Python][8], [Go][9], and [Ruby][10]. | -| `DD_SERVICE` | See [Unified Service Tagging][3]. | -| `DD_VERSION` | See [Unified Service Tagging][3]. | -| `DD_ENV` | See [Unified Service Tagging][3]. | -| `DD_SOURCE` | See [Unified Service Tagging][3]. | -| `DD_TAGS` | See [Unified Service Tagging][3]. | - - -[1]: /account_management/api-app-keys/#api-keys -[2]: /getting_started/site/ -[3]: /getting_started/tagging/unified_service_tagging/ -[4]: /tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2 -[5]: /tracing/other_telemetry/connect_logs_and_traces/nodejs -[6]: /tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog -[7]: /tracing/other_telemetry/connect_logs_and_traces/php -[8]: /tracing/other_telemetry/connect_logs_and_traces/python -[9]: /tracing/other_telemetry/connect_logs_and_traces/go -[10]: /tracing/other_telemetry/connect_logs_and_traces/ruby +| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java](/tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2), [Node.js](/tracing/other_telemetry/connect_logs_and_traces/nodejs), [.NET](/tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog), and [PHP](/tracing/other_telemetry/connect_logs_and_traces/php). See additional docs for [Python](/tracing/other_telemetry/connect_logs_and_traces/python), [Go](/tracing/other_telemetry/connect_logs_and_traces/go), and [Ruby](/tracing/other_telemetry/connect_logs_and_traces/ruby). | +| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_SOURCE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_TAGS` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | From 8c83b3ed27613962080a51568f2fae4201972ebf Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 18:29:10 -0400 Subject: [PATCH 18/52] nits --- .../google_cloud_run/containers/in_process/_index.md | 2 +- .../google_cloud_run/containers/in_process/python.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index b97057ab7edd7..b49a334aacd41 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -1,5 +1,5 @@ --- -title: Instrumenting Google Cloud Run Containers In-Process +title: Instrumenting Containers In-Process type: multi-code-lang aliases: - /serverless/google_cloud_run/containers/in_process/ diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 1c3687dc658d1..29c8e1808f4e7 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -3,6 +3,13 @@ title: Instrumenting a Python Cloud Run Container In-Process code_lang: python type: multi-code-lang code_lang_weight: 10 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/python/' + tag: 'Documentation' + text: 'Tracing Python Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/python/' + tag: 'Documentation' + text: 'Correlating Python Logs and Traces' --- ## 1. Install the Tracer From 2bd7ec9956d9321e27638e92e1a99343b9d4127f Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 28 Jul 2025 19:13:22 -0400 Subject: [PATCH 19/52] add more information to "Alternative configuration" --- .../google_cloud_run/containers/in_process/nodejs.md | 11 +++++++++-- .../google_cloud_run/containers/in_process/python.md | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 08967d3c86f75..809be9afcb568 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -70,11 +70,18 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -RUN npm install --prefix /dd_tracer/node dd-trace --save CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] ``` +If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "/nodejs/bin/node", "/path/to/your/app.js"] +``` + +As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. + {{% /collapse-content %}} ## 3. Setup Logs diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 29c8e1808f4e7..19bfc5cfd19c5 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -59,10 +59,18 @@ CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py" If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] ``` +If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. + {{% /collapse-content %}} ## 3. Setup Logs From 32c23343bbc7d38b53a21f488237d0312e9d7b72 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Tue, 29 Jul 2025 11:04:29 -0400 Subject: [PATCH 20/52] Update description for `DD_SOURCE` and `DD_TAGS`; make `COPY` explanation more clear; add more logs information; clarify that `winston` and `structlog` are external packages --- .../google_cloud_run/containers/in_process/nodejs.md | 7 +++++-- .../google_cloud_run/containers/in_process/python.md | 8 +++++--- layouts/shortcodes/gcr-configure-env-vars.en.md | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 809be9afcb568..49aa458d85254 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -39,7 +39,7 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] {{% collapse-content title="Explanation" level="h4" %}} -1. Copy the Datadog `serverless-init` into your Docker image. +1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init @@ -88,7 +88,7 @@ As long as your command to run is passed as an argument to datadog-init, you wil To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: ```javascript const tracer = require('dd-trace').init({ logInjection: true, @@ -107,6 +107,8 @@ const logger = createLogger({ logger.info(`Hello world!`); ``` +For more information, see [Correlating Node.js Logs and Traces][2]. + ## 4. Configure your application {{% gcr-configure-env-vars %}} @@ -116,3 +118,4 @@ logger.info(`Hello world!`); {{< partial name="whats-next/whats-next.html" >}} [1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ +[2]: tracing/other_telemetry/connect_logs_and_traces/nodejs/ diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 19bfc5cfd19c5..6afc070454116 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -34,7 +34,7 @@ CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py" {{% collapse-content title="Explanation" level="h4" %}} -1. Copy the Datadog `serverless-init` into your Docker image. +1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init @@ -79,9 +79,9 @@ To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This all We also recommend the following environment variables: - `ENV PYTHONUNBUFFERED=1`: Ensure Python outputs appear immediately in container logs instead of being buffered. -- `ENV DD_SOURCE=python`: Enable Datadog log parsing. For more information, see [Correlating Python Logs and Traces][2]. +- `ENV DD_SOURCE=python`: Enable advanced Datadog log parsing. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example: +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `structlog`: ```python import structlog @@ -103,6 +103,8 @@ logger = structlog.get_logger() logger.info("Hello world!") ``` +For more information, see [Correlating Python Logs and Traces][2]. + ## 4. Configure your application {{% gcr-configure-env-vars %}} diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 509c101af47f5..17f6a79983c33 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -23,8 +23,8 @@ gcloud run deploy | `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | | `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | | `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java](/tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2), [Node.js](/tracing/other_telemetry/connect_logs_and_traces/nodejs), [.NET](/tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog), and [PHP](/tracing/other_telemetry/connect_logs_and_traces/php). See additional docs for [Python](/tracing/other_telemetry/connect_logs_and_traces/python), [Go](/tracing/other_telemetry/connect_logs_and_traces/go), and [Ruby](/tracing/other_telemetry/connect_logs_and_traces/ruby). | -| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_SOURCE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_TAGS` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_SOURCE` | Set the log source to enable a [Log Pipeline](/logs/log_configuration/pipelines) for advanced parsing. Set to your runtime language (`python`, `nodejs`, `go`, `csharp`, `java`, `ruby`, `php`) to automatically apply language-specific parsing rules, or use your custom pipeline. Defaults to `cloudrun`. | +| `DD_TAGS` | Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (e.g. `key1:value1,key2:value2`). | From 996c4793200ab7d841a1c3408762451bde832da1 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Tue, 29 Jul 2025 11:07:14 -0400 Subject: [PATCH 21/52] Move `NODE_OPTIONS` to tracer installation instructions --- .../containers/in_process/nodejs.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 49aa458d85254..8aeb964de5e21 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -24,6 +24,11 @@ const tracer = require('dd-trace').init({ }); ``` +Finally, set the following environment variable to specify that the `dd-trace/init` module is required when the Node.js process starts: +```dockerfile +ENV NODE_OPTIONS="--require dd-trace/init" +``` + For more information, see [Tracing Node.js applications][1]. ## 2. Install Serverless-Init @@ -32,7 +37,6 @@ Add the following instructions and arguments to your Dockerfile. ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -ENV NODE_OPTIONS="--require dd-trace/init" ENTRYPOINT ["/app/datadog-init"] CMD ["/nodejs/bin/node", "/path/to/your/app.js"] ``` @@ -45,20 +49,14 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"] COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init ``` -2. Specify that the `dd-trace/init` module is required when the Node.js process starts. - - ```dockerfile - ENV NODE_OPTIONS="--require dd-trace/init" - ``` - -3. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. +2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). ```dockerfile ENTRYPOINT ["/app/datadog-init"] ``` -4. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. +3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. ```dockerfile CMD ["node", "/path/to/your/app.js"] ``` From bb695fc8a495b254639421a7b425b20655fc2462 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Tue, 29 Jul 2025 12:39:21 -0400 Subject: [PATCH 22/52] clarify DD_SITE --- layouts/shortcodes/gcr-configure-env-vars.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 17f6a79983c33..351727dabb68a 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -1,7 +1,7 @@ After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: - `DD_API_KEY`: Datadog API key, used to send data to your Datadog account. It should be configured as a Google Cloud Secret for privacy and safety. -- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. +- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. See valid [Datadog Sites](https://docs.datadoghq.com/getting_started/site/#access-the-datadog-site). For more environment variables and their function, see [Environment Variables](#environment-variables). From 962038f90a5afc02be6ed462f0269313814be9c3 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Tue, 29 Jul 2025 15:53:55 -0400 Subject: [PATCH 23/52] fill in `go.md` --- .../containers/in_process/go.md | 110 +++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 43476248b9c1c..709e6df7f0cb4 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -3,7 +3,115 @@ title: Instrumenting a Go Cloud Run Container In-Process code_lang: go type: multi-code-lang code_lang_weight: 30 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/' + tag: 'Documentation' + text: 'Tracing Go Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/go/' + tag: 'Documentation' + text: 'Correlating Go Logs and Traces' --- -## Go +## 1. Install the Tracer +In your main application, add `dd-trace-go`. + +```shell +go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer +``` + +Then, add this to your application code to initialize the tracer: +```go +tracer.Start() +defer tracer.Stop() +``` + +Additionally, you can add additional packages: +```shell +# Enable Profiling +go get github.com/DataDog/dd-trace-go/v2/profiler + +# Patch /net/http +go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 +``` + +For more information, see [Tracing Go Applications][1] and the [Tracer README][2]. + +## 2. Install Serverless-Init + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["./your-binary"] +``` + +{{% collapse-content title="Explanation" level="h4" %}} + +1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. + + ```dockerfile + COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init + ``` + +2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. + **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). + + ```dockerfile + ENTRYPOINT ["/app/datadog-init"] + ``` + +3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. + ```dockerfile + CMD ["./your-binary"] + ``` + +{{% /collapse-content %}} + +{{% collapse-content title="Alternative configuration" level="h4" id="alt-node" %}} + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] +``` + +If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "./your-binary"] +``` + +As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. + +{{% /collapse-content %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +We also recommend setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `logrus`: +```go +logrus.SetFormatter(&logrus.JSONFormatter{}) +logrus.AddHook(&dd_logrus.DDContextLogHook{}) + +logrus.WithContext(ctx).Info("Hello World!") +``` + +For more information, see [Correlating Go Logs and Traces][3]. + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/ +[2]: https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing +[3]: /tracing/other_telemetry/connect_logs_and_traces/go/ From d006de59aeae01d4a78b18b37446baae2f0cfe6b Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Tue, 29 Jul 2025 16:20:45 -0400 Subject: [PATCH 24/52] nits go.md --- .../serverless/google_cloud_run/containers/in_process/go.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 709e6df7f0cb4..39b5455c700c9 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -14,7 +14,7 @@ further_reading: ## 1. Install the Tracer -In your main application, add `dd-trace-go`. +In your main application, add the tracing library from `dd-trace-go`. ```shell go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer @@ -26,7 +26,7 @@ tracer.Start() defer tracer.Stop() ``` -Additionally, you can add additional packages: +You can also add additional packages: ```shell # Enable Profiling go get github.com/DataDog/dd-trace-go/v2/profiler @@ -74,7 +74,7 @@ CMD ["./your-binary"] If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile -CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] +CMD ["/app/datadog-init", "./your-binary"] ``` If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. From a2f274d8ee951246266a847d600c56c2d3a36102 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 10:27:44 -0400 Subject: [PATCH 25/52] try using hugo shortcodes to simplify step 2 --- .../containers/in_process/python.md | 49 +------------------ .../gcr-install-serverless-init.en.md | 48 ++++++++++++++++++ 2 files changed, 49 insertions(+), 48 deletions(-) create mode 100644 layouts/shortcodes/gcr-install-serverless-init.en.md diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 6afc070454116..186f26db76c60 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -24,54 +24,7 @@ For more information, see [Tracing Python applications][1]. ## 2. Install Serverless-Init -Add the following instructions and arguments to your Dockerfile. - -```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -ENTRYPOINT ["/app/datadog-init"] -CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] -``` - -{{% collapse-content title="Explanation" level="h4" %}} - -1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. - - ```dockerfile - COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init - ``` - -2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. - **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-python). - - ```dockerfile - ENTRYPOINT ["/app/datadog-init"] - ``` - -3. Execute your binary application wrapped in the tracer. Adapt this line to your needs. - ```dockerfile - CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] - ``` - -{{% /collapse-content %}} - -{{% collapse-content title="Alternative configuration" level="h4" id="alt-python" %}} - -If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. - -```dockerfile -CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] -``` - -If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. - -```dockerfile -ENTRYPOINT ["/app/datadog-init"] -CMD ["/your_entrypoint.sh", "/dd_tracer/python/bin/ddtrace-run", "python", "path/to/your/python/app.py"] -``` - -As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. - -{{% /collapse-content %}} +{{% gcr-install-serverless-init cmd="\"/dd_tracer/python/bin/ddtrace-run\", \"python\", \"path/to/your/python/app.py\"" %}} ## 3. Setup Logs diff --git a/layouts/shortcodes/gcr-install-serverless-init.en.md b/layouts/shortcodes/gcr-install-serverless-init.en.md new file mode 100644 index 0000000000000..a6c3b81775d08 --- /dev/null +++ b/layouts/shortcodes/gcr-install-serverless-init.en.md @@ -0,0 +1,48 @@ +Add the following instructions and arguments to your Dockerfile. + +```dockerfile +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD [{{ .Get "cmd" }}] +``` + +{{% collapse-content title="Explanation" level="h4" %}} + +1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. + + ```dockerfile + COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init + ``` + +2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. + **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt). + + ```dockerfile + ENTRYPOINT ["/app/datadog-init"] + ``` + +3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. + ```dockerfile + CMD [{{ .Get "cmd" }}] + ``` + +{{% /collapse-content %}} + +{{% collapse-content title="Alternative configuration" level="h4" id="alt" %}} + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", {{ .Get "cmd" }}] +``` + +If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", {{ .Get "cmd" }}] +``` + +As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. + +{{% /collapse-content %}} From 4365633e2cb0df4d14ba0533fcc96802bbf7d661 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 10:46:51 -0400 Subject: [PATCH 26/52] try to fix shortcode --- ...all-serverless-init.en.md => gcr-install-serverless-init.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename layouts/shortcodes/{gcr-install-serverless-init.en.md => gcr-install-serverless-init.html} (100%) diff --git a/layouts/shortcodes/gcr-install-serverless-init.en.md b/layouts/shortcodes/gcr-install-serverless-init.html similarity index 100% rename from layouts/shortcodes/gcr-install-serverless-init.en.md rename to layouts/shortcodes/gcr-install-serverless-init.html From 6e6723250d5fe86855641c424e781d88606eb272 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 10:53:15 -0400 Subject: [PATCH 27/52] Reorder languages --- .../containers/in_process/dotnet.md | 2 +- .../google_cloud_run/containers/in_process/ruby.md | 2 +- .../partials/serverless/in-process-languages.html | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index f64729fbb4095..2f1b77c05f04a 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -2,7 +2,7 @@ title: Instrumenting a .NET Cloud Run Container In-Process code_lang: dotnet type: multi-code-lang -code_lang_weight: 60 +code_lang_weight: 50 --- ## .NET diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index 893de2b01f9d5..b745f66c52223 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -2,7 +2,7 @@ title: Instrumenting a Ruby Cloud Run Container In-Process code_lang: ruby type: multi-code-lang -code_lang_weight: 50 +code_lang_weight: 60 --- ## Ruby diff --git a/layouts/partials/serverless/in-process-languages.html b/layouts/partials/serverless/in-process-languages.html index 83528c7e87182..2d717c0a92c2a 100644 --- a/layouts/partials/serverless/in-process-languages.html +++ b/layouts/partials/serverless/in-process-languages.html @@ -31,13 +31,6 @@
- +
From b80aec109a88eddeb13815af47e048f7646b8f72 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 13:16:41 -0400 Subject: [PATCH 28/52] Fix nested shortcode --- .../gcr-install-serverless-init.html | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index a6c3b81775d08..c558b066ba929 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -6,7 +6,21 @@ CMD [{{ .Get "cmd" }}] ``` -{{% collapse-content title="Explanation" level="h4" %}} + +
+ +
1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. @@ -26,9 +40,23 @@ CMD [{{ .Get "cmd" }}] ``` -{{% /collapse-content %}} +
+
-{{% collapse-content title="Alternative configuration" level="h4" id="alt" %}} +
+ +
If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. @@ -45,4 +73,5 @@ As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. -{{% /collapse-content %}} +
+
From a4b77f22fbc16f81870c12891c7eaa88e2f250b5 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 13:56:34 -0400 Subject: [PATCH 29/52] fix escaped quotes --- layouts/shortcodes/gcr-install-serverless-init.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index c558b066ba929..9e80b9413302f 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -3,7 +3,7 @@ ```dockerfile COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init ENTRYPOINT ["/app/datadog-init"] -CMD [{{ .Get "cmd" }}] +CMD [{{ .Get "cmd" | safeHTML }}] ``` @@ -37,7 +37,7 @@

Explanation

3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. ```dockerfile - CMD [{{ .Get "cmd" }}] + CMD [{{ .Get "cmd" | safeHTML }}] ```
@@ -61,14 +61,14 @@

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile -CMD ["/app/datadog-init", {{ .Get "cmd" }}] +CMD ["/app/datadog-init", {{ .Get "cmd" | safeHTML }}] ``` If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. ```dockerfile ENTRYPOINT ["/app/datadog-init"] -CMD ["/your_entrypoint.sh", {{ .Get "cmd" }}] +CMD ["/your_entrypoint.sh", {{ .Get "cmd" | safeHTML }}] ``` As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. From 908c6608d83070e88aee0e08276644ad9228c699 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 14:20:02 -0400 Subject: [PATCH 30/52] update go and nodejs to use shortcode --- .../containers/in_process/go.md | 49 +------------------ .../containers/in_process/nodejs.md | 49 +------------------ 2 files changed, 2 insertions(+), 96 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 39b5455c700c9..1bff209160426 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -39,54 +39,7 @@ For more information, see [Tracing Go Applications][1] and the [Tracer README][2 ## 2. Install Serverless-Init -Add the following instructions and arguments to your Dockerfile. - -```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -ENTRYPOINT ["/app/datadog-init"] -CMD ["./your-binary"] -``` - -{{% collapse-content title="Explanation" level="h4" %}} - -1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. - - ```dockerfile - COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init - ``` - -2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. - **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). - - ```dockerfile - ENTRYPOINT ["/app/datadog-init"] - ``` - -3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. - ```dockerfile - CMD ["./your-binary"] - ``` - -{{% /collapse-content %}} - -{{% collapse-content title="Alternative configuration" level="h4" id="alt-node" %}} - -If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. - -```dockerfile -CMD ["/app/datadog-init", "./your-binary"] -``` - -If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. - -```dockerfile -ENTRYPOINT ["/app/datadog-init"] -CMD ["/your_entrypoint.sh", "./your-binary"] -``` - -As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. - -{{% /collapse-content %}} +{{% gcr-install-serverless-init cmd="./your-binary" %}} ## 3. Setup Logs diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 8aeb964de5e21..705b6392b51f7 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -33,54 +33,7 @@ For more information, see [Tracing Node.js applications][1]. ## 2. Install Serverless-Init -Add the following instructions and arguments to your Dockerfile. - -```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -ENTRYPOINT ["/app/datadog-init"] -CMD ["/nodejs/bin/node", "/path/to/your/app.js"] -``` - -{{% collapse-content title="Explanation" level="h4" %}} - -1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. - - ```dockerfile - COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init - ``` - -2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. - **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node). - - ```dockerfile - ENTRYPOINT ["/app/datadog-init"] - ``` - -3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. - ```dockerfile - CMD ["node", "/path/to/your/app.js"] - ``` - -{{% /collapse-content %}} - -{{% collapse-content title="Alternative configuration" level="h4" id="alt-node" %}} - -If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. - -```dockerfile -CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] -``` - -If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. - -```dockerfile -ENTRYPOINT ["/app/datadog-init"] -CMD ["/your_entrypoint.sh", "/nodejs/bin/node", "/path/to/your/app.js"] -``` - -As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. - -{{% /collapse-content %}} +{{% gcr-install-serverless-init cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}} ## 3. Setup Logs From a64a11d4cf3404882a3d1d4380e89576376938bd Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 14:33:50 -0400 Subject: [PATCH 31/52] implement java.md --- .../containers/in_process/java.md | 72 ++++++++++++++++++- .../containers/in_process/nodejs.md | 2 +- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index 3f4755477aea3..f4f30f4cd0a60 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -3,6 +3,76 @@ title: Instrumenting a Java Cloud Run Container In-Process code_lang: java type: multi-code-lang code_lang_weight: 40 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/' + tag: 'Documentation' + text: 'Tracing Java Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/java/' + tag: 'Documentation' + text: 'Correlating Java Logs and Traces' --- -## Java +## 1. Install the Tracer + +Add the Java tracer agent to your Dockerfile: + +```dockerfile +ADD 'https://dtdg.co/latest-java-tracer' agent.jar +ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" +``` + +Then, add the tracer artifacts. + +Maven: +```xml + + com.datadoghq + dd-trace-api + DD_TRACE_JAVA_VERSION_HERE + +``` + +Gradle: +```groovy +implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' +``` + +Finally, add the `@Trace` annotation on any method you want to trace. + +For more information, see [Tracing Java Applications][1]. + +## 2. Install Serverless-Init + +{{% gcr-install-serverless-init cmd="\"./mvnw\", \"spring-boot:run\"" %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: +```java +private static final Logger logger = LogManager.getLogger(App.class); +logger.info("Hello World!"); +``` +`resources/log4j2.xml`: +```xml + + + + + + +``` + +For more information, see [Correlating Java Logs and Traces][2]. + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/java/ +[2]: /tracing/other_telemetry/connect_logs_and_traces/java/ diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 705b6392b51f7..ad8a6ab789f99 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -69,4 +69,4 @@ For more information, see [Correlating Node.js Logs and Traces][2]. {{< partial name="whats-next/whats-next.html" >}} [1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ -[2]: tracing/other_telemetry/connect_logs_and_traces/nodejs/ +[2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ From 8109198b6be8daf3e9c9fb2d04cdee595fb3fa2c Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 14:50:32 -0400 Subject: [PATCH 32/52] nits --- .../serverless/google_cloud_run/containers/in_process/java.md | 2 +- layouts/shortcodes/gcr-install-serverless-init.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index f4f30f4cd0a60..58104ca5f6a2b 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -37,7 +37,7 @@ Gradle: implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' ``` -Finally, add the `@Trace` annotation on any method you want to trace. +Finally, add the `@Trace` annotation to any method you want to trace. For more information, see [Tracing Java Applications][1]. diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index 9e80b9413302f..0fdbba1a5f61d 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -75,3 +75,4 @@

Alternative configuration

+
From 749aa7d320e4e69e39d1c0f1a4f1225f80a579cf Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 16:07:50 -0400 Subject: [PATCH 33/52] implement dotnet.md --- .../containers/in_process/dotnet.md | 57 ++++++++++++++++++- .../containers/in_process/nodejs.md | 3 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 2f1b77c05f04a..cef92eb705b27 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -5,4 +5,59 @@ type: multi-code-lang code_lang_weight: 50 --- -## .NET +## 1. Install the Tracer + +Install the tracer in your Dockerfile. Note that GitHub requests are rate limited, so pass a Github token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret][1] `--secret id=github-token,env=GITHUB_TOKEN`. + +For linux/amd64, include: +```Dockerfile +RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \ + chmod +x /app/dotnet.sh && /app/dotnet.sh \ +``` + +For alpine builds, configure your Dockerfile like so: + +```Dockerfile +# For arm64 use datadog-dotnet-apm-2.57.0.arm64.tar.gz +# For alpine use datadog-dotnet-apm-2.57.0-musl.tar.gz +ARG TRACER_VERSION +ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm-${TRACER_VERSION}.tar.gz /tmp/datadog-dotnet-apm.tar.gz + +RUN mkdir -p /dd_tracer/dotnet/ && tar -xzvf /tmp/datadog-dotnet-apm.tar.gz -C /dd_tracer/dotnet/ && rm /tmp/datadog-dotnet-apm.tar.gz +``` + +For more information, see [Tracing .NET applications][2]. + +## 2. Install Serverless-Init + +{{% gcr-install-serverless-init cmd="\"dotnet\", \"dotnet.dll\"" %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: +```csharp +using Serilog; + +builder.Host.UseSerilog((context, config) => +{ + config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)); +}); + +logger.LogInformation("Hello World!"); +``` + +For more information, see [Correlating .NET Logs and Traces][3]. + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: https://docs.docker.com/build/building/secrets/ +[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux +[3]: /tracing/other_telemetry/connect_logs_and_traces/dotnet/ diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index ad8a6ab789f99..f78f07dbad83c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -7,6 +7,9 @@ further_reading: - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/' tag: 'Documentation' text: 'Tracing Node.js Applications' +- link: '/tracing/other_telemetry/connect_logs_and_traces/nodejs/' + tag: 'Documentation' + text: 'Correlating Node.js Logs and Traces' --- ## 1. Install the Tracer From e40d1ffd41d4b6eaf1986cf4890357fb981f0ec7 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 16:08:57 -0400 Subject: [PATCH 34/52] nits --- .../serverless/google_cloud_run/containers/in_process/dotnet.md | 2 ++ .../serverless/google_cloud_run/containers/in_process/java.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index cef92eb705b27..9e637062259cf 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -36,6 +36,8 @@ For more information, see [Tracing .NET applications][2]. To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. +We also recommend setting the environment variable `DD_SOURCE=csharp` to enable advanced Datadog log parsing. + If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: ```csharp using Serilog; diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index 58104ca5f6a2b..ffea0136e4aee 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -49,6 +49,8 @@ For more information, see [Tracing Java Applications][1]. To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. +We also recommend setting the environment variable `DD_SOURCE=java` to enable advanced Datadog log parsing. + If you want multiline logs to be preserved in a single log message, we recommend writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: ```java private static final Logger logger = LogManager.getLogger(App.class); From ac753daba2828d4b09e498e6e06ead3e0e72fa4b Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Wed, 30 Jul 2025 16:54:55 -0400 Subject: [PATCH 35/52] implement ruby.md --- .../containers/in_process/dotnet.md | 7 +++ .../containers/in_process/ruby.md | 50 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 9e637062259cf..72db80a49c1f7 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -3,6 +3,13 @@ title: Instrumenting a .NET Cloud Run Container In-Process code_lang: dotnet type: multi-code-lang code_lang_weight: 50 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux' + tag: 'Documentation' + text: 'Tracing .NET Core Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/dotnet/' + tag: 'Documentation' + text: 'Correlating .NET Logs and Traces' --- ## 1. Install the Tracer diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index b745f66c52223..f2e03288e5f9c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -3,6 +3,54 @@ title: Instrumenting a Ruby Cloud Run Container In-Process code_lang: ruby type: multi-code-lang code_lang_weight: 60 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/' + tag: 'Documentation' + text: 'Tracing Ruby Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/ruby/' + tag: 'Documentation' + text: 'Correlating Ruby Logs and Traces' --- -## Ruby +## 1. Install the Tracer + +Manually install the Ruby tracer by adding the `datadog` gem to your Gemfile: +```gemfile +source 'https://rubygems.org' +gem 'datadog' +``` + +See [Tracing Ruby applications][1] for additional information on how to configure the tracer. + +## 2. Install Serverless-Init + +{{% gcr-install-serverless-init cmd="\"rails\", \"server\", \"-b\", \"0.0.0.0\"" %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +We also recommend setting the environment variable `DD_SOURCE=ruby` to enable advanced Datadog log parsing. + +To enable log/trace correlation, you will need to include `Datadog::Tracing.log_correlation` in your log format. For example: +```ruby +logger = Logger.new(STDOUT) +logger.formatter = proc do |severity, datetime, progname, msg| + "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" +end + +logger.info "Hello world!" +``` + +For more information, see [Correlating Ruby Logs and Traces][2]. + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#instrument-your-application +[2]: /tracing/other_telemetry/connect_logs_and_traces/ruby/ From 4c621cc71c27d340cb1d11406bbd983ea4545976 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 10:38:51 -0400 Subject: [PATCH 36/52] implement php.md --- .../containers/in_process/php.md | 50 ++++++++++++++++++- .../containers/in_process/ruby.md | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 32391e7598e7d..73c994e9c257d 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -3,6 +3,54 @@ title: Instrumenting a PHP Cloud Run Container In-Process code_lang: php type: multi-code-lang code_lang_weight: 70 +further_reading: + - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/' + tag: 'Documentation' + text: 'Tracing PHP Applications' + - link: '/tracing/other_telemetry/connect_logs_and_traces/php/' + tag: 'Documentation' + text: 'Correlating PHP Logs and Traces' --- -## PHP +## 1. Install the Tracer + +Install the tracer in your Dockerfile: + +```Dockerfile +RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php +RUN php datadog-setup.php --php-bin=all +``` + +When running the `datadog-setup.php` script, you can also enable appsec and profiling via the `--enable-appsec` and `--enable-profiling` flags. + +If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: + +```shell +apk add libgcc +``` + +For more information, see [Tracing PHP applications][1]. + +## 2. Install Serverless-Init + +{{% gcr-install-serverless-init cmd="\"apache2-foreground\"" %}} + +## 3. Setup Logs + +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + +We also recommend setting the environment variable `DD_SOURCE=php` to enable advanced Datadog log parsing. + +For more information, see [Correlating PHP Logs and Traces][2]. + +## 4. Configure your application + +{{% gcr-configure-env-vars %}} + +## Further reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/php/ +[2]: /tracing/other_telemetry/connect_logs_and_traces/php/ + diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index f2e03288e5f9c..da0cc67e8e881 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -20,7 +20,7 @@ source 'https://rubygems.org' gem 'datadog' ``` -See [Tracing Ruby applications][1] for additional information on how to configure the tracer. +See [Tracing Ruby applications][1] for additional information on how to configure the tracer and enable auto instrumentation. ## 2. Install Serverless-Init From 8175816cbf2a3d975ea70a96d56ed6fbe7147521 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 11:12:38 -0400 Subject: [PATCH 37/52] add troubleshooting instructions --- .../google_cloud_run/containers/in_process/dotnet.md | 4 ++++ .../serverless/google_cloud_run/containers/in_process/go.md | 4 ++++ .../google_cloud_run/containers/in_process/java.md | 4 ++++ .../google_cloud_run/containers/in_process/nodejs.md | 4 ++++ .../serverless/google_cloud_run/containers/in_process/php.md | 4 ++++ .../google_cloud_run/containers/in_process/python.md | 4 ++++ .../google_cloud_run/containers/in_process/ruby.md | 4 ++++ layouts/shortcodes/gcr-troubleshooting.en.md | 5 +++++ 8 files changed, 33 insertions(+) create mode 100644 layouts/shortcodes/gcr-troubleshooting.en.md diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 72db80a49c1f7..00dc97dab23c9 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -63,6 +63,10 @@ For more information, see [Correlating .NET Logs and Traces][3]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 1bff209160426..6b90c1365ef40 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -61,6 +61,10 @@ For more information, see [Correlating Go Logs and Traces][3]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index ffea0136e4aee..edda9e6474b56 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -72,6 +72,10 @@ For more information, see [Correlating Java Logs and Traces][2]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index f78f07dbad83c..02ab5fd49406c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -67,6 +67,10 @@ For more information, see [Correlating Node.js Logs and Traces][2]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 73c994e9c257d..41f2c1fc7aca2 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -47,6 +47,10 @@ For more information, see [Correlating PHP Logs and Traces][2]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 186f26db76c60..5693bebfa3d15 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -62,6 +62,10 @@ For more information, see [Correlating Python Logs and Traces][2]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index da0cc67e8e881..3c9a0c6ba40ae 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -48,6 +48,10 @@ For more information, see [Correlating Ruby Logs and Traces][2]. {{% gcr-configure-env-vars %}} +## Troubleshooting + +{{% gcr-troubleshooting %}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/layouts/shortcodes/gcr-troubleshooting.en.md b/layouts/shortcodes/gcr-troubleshooting.en.md new file mode 100644 index 0000000000000..8bd9b0a57b5f5 --- /dev/null +++ b/layouts/shortcodes/gcr-troubleshooting.en.md @@ -0,0 +1,5 @@ +This integration depends on your runtime having a full SSL implementation. If you are using a slim image, you may need to add the following command to your Dockerfile to include certificates. + +```dockerfile +RUN apt-get update && apt-get install -y ca-certificates +``` From 8260220a94727427e9aa96088e765cc401820475 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 11:12:48 -0400 Subject: [PATCH 38/52] add google cloud integration setup --- .../google_cloud_run/containers/in_process/_index.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index b49a334aacd41..ef55dd68f0194 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -6,6 +6,10 @@ aliases: redirect: /serverless/google_cloud_run/containers/in_process/python/ --- -Instrument your application using one of the following guides: +First, set up the [Google Cloud Integration][1] to collect metrics and logs from Google Cloud services. Remember to add the `cloud asset viewer` role to your service account and enable the Cloud Asset Inventory API in Google Cloud. + +Then, instrument your application using one of the following guides: {{< partial name="serverless/in-process-languages.html" >}} + +[1] /integrations/google-cloud-platform/ From 31843f293df32bc3f2d1b9929023a999e62f4005 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 11:13:04 -0400 Subject: [PATCH 39/52] add more info about serverless-init image and tags --- .../gcr-install-serverless-init.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index 0fdbba1a5f61d..10a6b337f4be7 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -1,7 +1,19 @@ +Datadog publishes new releases of the `serverless-init` container image to Google’s gcr.io, AWS’s ECR, and on Docker Hub: + +| hub.docker.com | gcr.io | public.ecr.aws | +| ---- | ---- | ---- | +| datadog/serverless-init | gcr.io/datadoghq/serverless-init | public.ecr.aws/datadog/serverless-init | + +Images are tagged based on semantic versioning, with each new version receiving three relevant tags: + +- `1`, `1-alpine`: use these to track the latest minor releases, without breaking changes +- `1.x.x`, `1.x.x-alpine`: use these to pin to a precise version of the library +- `latest`, `latest-alpine`: use these to follow the latest version release, which may include breaking changes + Add the following instructions and arguments to your Dockerfile. ```dockerfile -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init +COPY --from=datadog/serverless-init:YOUR-TAG /datadog-init /app/datadog-init ENTRYPOINT ["/app/datadog-init"] CMD [{{ .Get "cmd" | safeHTML }}] ``` @@ -22,10 +34,10 @@

Explanation

-1. Install `serverless-init`, and stay on the latest major version with the `:1` tag. Alternatively, you can pin to a specific version tag or use `:latest`. +1. Install `serverless-init`. ```dockerfile - COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init + COPY --from=datadog/serverless-init:YOUR-TAG /datadog-init /app/datadog-init ``` 2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. From 82cc8f9e95cda3dcc95a507c58a3e3748761b85e Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 11:27:42 -0400 Subject: [PATCH 40/52] fix markdown link --- .../serverless/google_cloud_run/containers/in_process/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index ef55dd68f0194..e5761a007daf4 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -12,4 +12,4 @@ Then, instrument your application using one of the following guides: {{< partial name="serverless/in-process-languages.html" >}} -[1] /integrations/google-cloud-platform/ +[1]: /integrations/google-cloud-platform/ From 356b524d59f3a90fb71f8f76a2e628d5f91d4e62 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 12:53:50 -0400 Subject: [PATCH 41/52] add aliases for old paths --- content/en/serverless/google_cloud_run/containers/_index.md | 2 ++ .../google_cloud_run/containers/in_process/_index.md | 3 +-- .../serverless/google_cloud_run/containers/sidecar/_index.md | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/_index.md b/content/en/serverless/google_cloud_run/containers/_index.md index 8434c62081173..47b736587e28a 100644 --- a/content/en/serverless/google_cloud_run/containers/_index.md +++ b/content/en/serverless/google_cloud_run/containers/_index.md @@ -32,6 +32,8 @@ To instrument your Google Cloud Run containers with Datadog, choose one of two o | Logging | Direct stdout/stderr access. | Shared volume + log library routing to a log file. Uncaught errors require extra handling, since they are not automatically handled by your logging library. | | Failure isolation | In rare cases, Datadog Agent bugs can affect your app. | Datadog Agent faults are isolated. | | Observing multiple containers | Not supported | Supported | + + ## Further reading {{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index e5761a007daf4..c4367fd455214 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -2,8 +2,7 @@ title: Instrumenting Containers In-Process type: multi-code-lang aliases: - - /serverless/google_cloud_run/containers/in_process/ -redirect: /serverless/google_cloud_run/containers/in_process/python/ + - /serverless/google_cloud_run/containers_in_process/ --- First, set up the [Google Cloud Integration][1] to collect metrics and logs from Google Cloud services. Remember to add the `cloud asset viewer` role to your service account and enable the Cloud Asset Inventory API in Google Cloud. diff --git a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md index b16500f99240d..c81621f5dfa32 100644 --- a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md +++ b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md @@ -1,5 +1,7 @@ --- title: Instrumenting Google Cloud Run Containers with Sidecar +aliases: + - /serverless/google_cloud_run/containers_sidecar/ further_reading: - link: 'https://www.datadoghq.com/blog/instrument-cloud-run-with-datadog-sidecar/' tag: 'Blog' @@ -873,5 +875,5 @@ $statsd->increment('page.views', 1, array('environment'=>'dev')); [11]: /tracing/other_telemetry/connect_logs_and_traces/go [12]: /tracing/other_telemetry/connect_logs_and_traces/ruby [13]: /getting_started/tagging/unified_service_tagging/ -[14]: /serverless/google_cloud_run/containers_in_process +[14]: /serverless/google_cloud_run/containers/in_process [15]: https://cloud.google.com/run/docs/configuring/services/labels From 622bcecf297db4b2494dbac2a574b72ddb13b6ff Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 13:00:45 -0400 Subject: [PATCH 42/52] add `DD_SOURCE=nodejs` recommendation --- .../serverless/google_cloud_run/containers/in_process/nodejs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 02ab5fd49406c..5934cbbd44c8c 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -42,6 +42,8 @@ For more information, see [Tracing Node.js applications][1]. To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. +We also recommend setting the environment variable `DD_SOURCE=nodejs` to enable advanced Datadog log parsing. + If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: ```javascript const tracer = require('dd-trace').init({ From 472be8510bb29286e89da64b91d13502c129d74f Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 13:02:59 -0400 Subject: [PATCH 43/52] update titles --- content/en/serverless/google_cloud_run/containers/_index.md | 2 +- .../serverless/google_cloud_run/containers/in_process/_index.md | 2 +- .../en/serverless/google_cloud_run/containers/sidecar/_index.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/_index.md b/content/en/serverless/google_cloud_run/containers/_index.md index 47b736587e28a..7283618146cdf 100644 --- a/content/en/serverless/google_cloud_run/containers/_index.md +++ b/content/en/serverless/google_cloud_run/containers/_index.md @@ -1,5 +1,5 @@ --- -title: Choosing an Instrumentation Method +title: Choosing an Instrumentation Method for Containers further_reading: - link: "/integrations/google-cloud-run/" tag: "Documentation" diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index c4367fd455214..4001886db71d0 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -1,5 +1,5 @@ --- -title: Instrumenting Containers In-Process +title: In-Process Instrumentation type: multi-code-lang aliases: - /serverless/google_cloud_run/containers_in_process/ diff --git a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md index c81621f5dfa32..785e22af0a617 100644 --- a/content/en/serverless/google_cloud_run/containers/sidecar/_index.md +++ b/content/en/serverless/google_cloud_run/containers/sidecar/_index.md @@ -1,5 +1,5 @@ --- -title: Instrumenting Google Cloud Run Containers with Sidecar +title: Sidecar Instrumentation aliases: - /serverless/google_cloud_run/containers_sidecar/ further_reading: From 4a09b8c3be8a186792d41022a49c3558465592e3 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 14:09:06 -0400 Subject: [PATCH 44/52] Add software catalog troubleshooting and mark required env vars as recommended --- layouts/shortcodes/gcr-configure-env-vars.en.md | 6 +++--- layouts/shortcodes/gcr-troubleshooting.en.md | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.md index 351727dabb68a..b521f3199760a 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.md @@ -23,8 +23,8 @@ gcloud run deploy | `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | | `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | | `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java](/tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2), [Node.js](/tracing/other_telemetry/connect_logs_and_traces/nodejs), [.NET](/tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog), and [PHP](/tracing/other_telemetry/connect_logs_and_traces/php). See additional docs for [Python](/tracing/other_telemetry/connect_logs_and_traces/python), [Go](/tracing/other_telemetry/connect_logs_and_traces/go), and [Ruby](/tracing/other_telemetry/connect_logs_and_traces/ruby). | -| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | -| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). | +| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | +| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | +| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | | `DD_SOURCE` | Set the log source to enable a [Log Pipeline](/logs/log_configuration/pipelines) for advanced parsing. Set to your runtime language (`python`, `nodejs`, `go`, `csharp`, `java`, `ruby`, `php`) to automatically apply language-specific parsing rules, or use your custom pipeline. Defaults to `cloudrun`. | | `DD_TAGS` | Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (e.g. `key1:value1,key2:value2`). | diff --git a/layouts/shortcodes/gcr-troubleshooting.en.md b/layouts/shortcodes/gcr-troubleshooting.en.md index 8bd9b0a57b5f5..65b12a0fcb997 100644 --- a/layouts/shortcodes/gcr-troubleshooting.en.md +++ b/layouts/shortcodes/gcr-troubleshooting.en.md @@ -3,3 +3,5 @@ This integration depends on your runtime having a full SSL implementation. If yo ```dockerfile RUN apt-get update && apt-get install -y ca-certificates ``` + +To have your Cloud Run services appear in the [software catalog][/internal_developer_portal/software_catalog/], you will need to set the `DD_SERVICE`, `DD_VERSION`, and `DD_ENV` environment variables. From 1c12c60086b7063e65c13834ae4c41b9c73169ac Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 14:57:00 -0400 Subject: [PATCH 45/52] fix link --- layouts/shortcodes/gcr-troubleshooting.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/gcr-troubleshooting.en.md b/layouts/shortcodes/gcr-troubleshooting.en.md index 65b12a0fcb997..443344b8b686d 100644 --- a/layouts/shortcodes/gcr-troubleshooting.en.md +++ b/layouts/shortcodes/gcr-troubleshooting.en.md @@ -4,4 +4,4 @@ This integration depends on your runtime having a full SSL implementation. If yo RUN apt-get update && apt-get install -y ca-certificates ``` -To have your Cloud Run services appear in the [software catalog][/internal_developer_portal/software_catalog/], you will need to set the `DD_SERVICE`, `DD_VERSION`, and `DD_ENV` environment variables. +To have your Cloud Run services appear in the [software catalog](/internal_developer_portal/software_catalog/), you will need to set the `DD_SERVICE`, `DD_VERSION`, and `DD_ENV` environment variables. From 3d819e619b548770c764dd2d75cce6346d877ced Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Thu, 31 Jul 2025 16:25:38 -0400 Subject: [PATCH 46/52] optimize PHP dockerfile by combining RUN instructions --- .../serverless/google_cloud_run/containers/in_process/php.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 41f2c1fc7aca2..168e9e28c95a3 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -17,8 +17,8 @@ further_reading: Install the tracer in your Dockerfile: ```Dockerfile -RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php -RUN php datadog-setup.php --php-bin=all +RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ + && php datadog-setup.php --php-bin=all ``` When running the `datadog-setup.php` script, you can also enable appsec and profiling via the `--enable-appsec` and `--enable-profiling` flags. From cb81da25a70e81f33b860352980d0d68d7d6c89a Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 4 Aug 2025 09:40:41 -0400 Subject: [PATCH 47/52] nits --- .../containers/in_process/_index.md | 2 +- .../containers/in_process/dotnet.md | 2 +- .../gcr-install-serverless-init.html | 40 ++----------------- 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/_index.md b/content/en/serverless/google_cloud_run/containers/in_process/_index.md index 4001886db71d0..ea21b8f8a3cd3 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/_index.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/_index.md @@ -5,7 +5,7 @@ aliases: - /serverless/google_cloud_run/containers_in_process/ --- -First, set up the [Google Cloud Integration][1] to collect metrics and logs from Google Cloud services. Remember to add the `cloud asset viewer` role to your service account and enable the Cloud Asset Inventory API in Google Cloud. +First, set up the **[Google Cloud Integration][1]** to collect metrics and logs from Google Cloud services. Remember to add the `cloud asset viewer` role to your service account and enable the Cloud Asset Inventory API in Google Cloud. Then, instrument your application using one of the following guides: diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 00dc97dab23c9..df0beb174451b 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -19,7 +19,7 @@ Install the tracer in your Dockerfile. Note that GitHub requests are rate limite For linux/amd64, include: ```Dockerfile RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \ - chmod +x /app/dotnet.sh && /app/dotnet.sh \ + chmod +x /app/dotnet.sh && /app/dotnet.sh ``` For alpine builds, configure your Dockerfile like so: diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index 10a6b337f4be7..0abd6c4ea6a58 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -13,49 +13,13 @@ Add the following instructions and arguments to your Dockerfile. ```dockerfile -COPY --from=datadog/serverless-init:YOUR-TAG /datadog-init /app/datadog-init +COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init ENTRYPOINT ["/app/datadog-init"] CMD [{{ .Get "cmd" | safeHTML }}] ```
- -
- -1. Install `serverless-init`. - - ```dockerfile - COPY --from=datadog/serverless-init:YOUR-TAG /datadog-init /app/datadog-init - ``` - -2. Change the entrypoint to wrap your application in the Datadog `serverless-init` process. - **Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt). - - ```dockerfile - ENTRYPOINT ["/app/datadog-init"] - ``` - -3. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs. - ```dockerfile - CMD [{{ .Get "cmd" | safeHTML }}] - ``` - -
-
- -
+We expect `serverless-init` to be the top-level application with the test of your app's command line passed in for `serverless-init` to execute. + If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. ```dockerfile From 59cc524045d1ddbb47783772271bd09429aa44c7 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 4 Aug 2025 09:49:04 -0400 Subject: [PATCH 48/52] Only show relevant language docs in configure env vars table --- .../google_cloud_run/containers/in_process/dotnet.md | 2 +- .../serverless/google_cloud_run/containers/in_process/go.md | 2 +- .../google_cloud_run/containers/in_process/java.md | 2 +- .../google_cloud_run/containers/in_process/nodejs.md | 2 +- .../serverless/google_cloud_run/containers/in_process/php.md | 2 +- .../google_cloud_run/containers/in_process/python.md | 2 +- .../google_cloud_run/containers/in_process/ruby.md | 2 +- ...nfigure-env-vars.en.md => gcr-configure-env-vars.en.html} | 5 +++-- 8 files changed, 10 insertions(+), 9 deletions(-) rename layouts/shortcodes/{gcr-configure-env-vars.en.md => gcr-configure-env-vars.en.html} (69%) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index df0beb174451b..18b8ec77c7320 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -61,7 +61,7 @@ For more information, see [Correlating .NET Logs and Traces][3]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="csharp" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 6b90c1365ef40..e4a89590ffb6a 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -59,7 +59,7 @@ For more information, see [Correlating Go Logs and Traces][3]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="go" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index edda9e6474b56..4528eede6aed6 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -70,7 +70,7 @@ For more information, see [Correlating Java Logs and Traces][2]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="java" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 5934cbbd44c8c..7f2d1d109ca15 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -67,7 +67,7 @@ For more information, see [Correlating Node.js Logs and Traces][2]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="nodejs" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 168e9e28c95a3..072aefbc7ea65 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -45,7 +45,7 @@ For more information, see [Correlating PHP Logs and Traces][2]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="php" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 5693bebfa3d15..992fe55fa4d87 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -60,7 +60,7 @@ For more information, see [Correlating Python Logs and Traces][2]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="python" %}} ## Troubleshooting diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index 3c9a0c6ba40ae..1c7fa130ba39a 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -46,7 +46,7 @@ For more information, see [Correlating Ruby Logs and Traces][2]. ## 4. Configure your application -{{% gcr-configure-env-vars %}} +{{% gcr-configure-env-vars language="ruby" %}} ## Troubleshooting diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.md b/layouts/shortcodes/gcr-configure-env-vars.en.html similarity index 69% rename from layouts/shortcodes/gcr-configure-env-vars.en.md rename to layouts/shortcodes/gcr-configure-env-vars.en.html index b521f3199760a..ce8c348a06ddb 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.md +++ b/layouts/shortcodes/gcr-configure-env-vars.en.html @@ -22,9 +22,10 @@ | `DD_API_KEY` | [Datadog API key](/account_management/api-app-keys/#api-keys) - **Required**| | `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | | `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | -| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers in [Java](/tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2), [Node.js](/tracing/other_telemetry/connect_logs_and_traces/nodejs), [.NET](/tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog), and [PHP](/tracing/other_telemetry/connect_logs_and_traces/php). See additional docs for [Python](/tracing/other_telemetry/connect_logs_and_traces/python), [Go](/tracing/other_telemetry/connect_logs_and_traces/go), and [Ruby](/tracing/other_telemetry/connect_logs_and_traces/ruby). | +{{ if in (slice "java" "nodejs" "csharp" "php") (.Get "language") }}| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers. See [Correlate Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/) for more information. | +{{ end }} | `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | | `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | | `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | -| `DD_SOURCE` | Set the log source to enable a [Log Pipeline](/logs/log_configuration/pipelines) for advanced parsing. Set to your runtime language (`python`, `nodejs`, `go`, `csharp`, `java`, `ruby`, `php`) to automatically apply language-specific parsing rules, or use your custom pipeline. Defaults to `cloudrun`. | +| `DD_SOURCE` | Set the log source to enable a [Log Pipeline](/logs/log_configuration/pipelines) for advanced parsing. To automatically apply language-specific parsing rules, set to `{{ .Get "language" }}`, or use your custom pipeline. Defaults to `cloudrun`. | | `DD_TAGS` | Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (e.g. `key1:value1,key2:value2`). | From 1302b666b04177ef37957a7d8322b4bbf87fa177 Mon Sep 17 00:00:00 2001 From: Nicholas Hulston Date: Mon, 4 Aug 2025 10:07:19 -0400 Subject: [PATCH 49/52] fix table --- layouts/shortcodes/gcr-configure-env-vars.en.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.html b/layouts/shortcodes/gcr-configure-env-vars.en.html index ce8c348a06ddb..4ac063fd3e25b 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.html +++ b/layouts/shortcodes/gcr-configure-env-vars.en.html @@ -21,9 +21,8 @@ | -------- | ----------- | | `DD_API_KEY` | [Datadog API key](/account_management/api-app-keys/#api-keys) - **Required**| | `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | -| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. | -{{ if in (slice "java" "nodejs" "csharp" "php") (.Get "language") }}| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers. See [Correlate Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/) for more information. | -{{ end }} +| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. |{{ if in (slice "java" "nodejs" "csharp" "php") (.Get "language") }} +| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers. See [Correlate Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/) for more information. |{{ end }} | `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | | `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | | `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | From c3cf8b0d98d89288feb931047e3dfe43a45952b2 Mon Sep 17 00:00:00 2001 From: cecilia saixue watt Date: Wed, 6 Aug 2025 12:08:19 -0700 Subject: [PATCH 50/52] formatting --- .../containers/in_process/dotnet.md | 46 +++++++------- .../containers/in_process/go.md | 49 +++++++-------- .../containers/in_process/java.md | 61 ++++++++++--------- .../containers/in_process/nodejs.md | 45 +++++++------- .../containers/in_process/php.md | 33 +++++----- .../containers/in_process/python.md | 35 ++++++----- .../containers/in_process/ruby.md | 31 +++++----- .../shortcodes/gcr-configure-env-vars.en.html | 52 +++++++++------- .../gcr-install-serverless-init.html | 8 +-- layouts/shortcodes/gcr-troubleshooting.en.md | 6 +- 10 files changed, 192 insertions(+), 174 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 18b8ec77c7320..31fe11ea7da30 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -12,41 +12,45 @@ further_reading: text: 'Correlating .NET Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer** in your Dockerfile. -Install the tracer in your Dockerfile. Note that GitHub requests are rate limited, so pass a Github token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret][1] `--secret id=github-token,env=GITHUB_TOKEN`. + Because GitHub requests are rate limited, you must pass a GitHub token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret][1] `--secret id=github-token,env=GITHUB_TOKEN`. -For linux/amd64, include: -```Dockerfile + {{< tabs >}} + {{% tab "Linux/AMD64" %}} +{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \ chmod +x /app/dotnet.sh && /app/dotnet.sh -``` +{{< /code-block >}} + {{% /tab %}} -For alpine builds, configure your Dockerfile like so: - -```Dockerfile -# For arm64 use datadog-dotnet-apm-2.57.0.arm64.tar.gz + {{% tab "Alpine" %}} +{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} # For alpine use datadog-dotnet-apm-2.57.0-musl.tar.gz ARG TRACER_VERSION ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm-${TRACER_VERSION}.tar.gz /tmp/datadog-dotnet-apm.tar.gz RUN mkdir -p /dd_tracer/dotnet/ && tar -xzvf /tmp/datadog-dotnet-apm.tar.gz -C /dd_tracer/dotnet/ && rm /tmp/datadog-dotnet-apm.tar.gz -``` +{{< /code-block >}} + {{% /tab %}} + {{< /tabs >}} + + For more information, see [Tracing .NET applications][2]. -For more information, see [Tracing .NET applications][2]. +2. **Install serverless-init**. -## 2. Install Serverless-Init + {{% gcr-install-serverless-init cmd="\"dotnet\", \"dotnet.dll\"" %}} -{{% gcr-install-serverless-init cmd="\"dotnet\", \"dotnet.dll\"" %}} +3. **Set up logs**. -## 3. Setup Logs + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + Datadog also recommends setting the environment variable `DD_SOURCE=csharp` to enable advanced Datadog log parsing. -We also recommend setting the environment variable `DD_SOURCE=csharp` to enable advanced Datadog log parsing. + If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: -```csharp + {{< code-block lang="csharp" disable_copy="false" >}} using Serilog; builder.Host.UseSerilog((context, config) => @@ -55,11 +59,11 @@ builder.Host.UseSerilog((context, config) => }); logger.LogInformation("Hello World!"); -``` +{{< /code-block >}} -For more information, see [Correlating .NET Logs and Traces][3]. + For more information, see [Correlating .NET Logs and Traces][3]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="csharp" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index e4a89590ffb6a..54958af65caf0 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -12,52 +12,53 @@ further_reading: text: 'Correlating Go Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer**. -In your main application, add the tracing library from `dd-trace-go`. + 1. In your main application, add the tracing library from `dd-trace-go`. -```shell + {{< code-block lang="shell" disable_copy="false" >}} go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer -``` +{{< /code-block >}} -Then, add this to your application code to initialize the tracer: -```go + 2. Add the following to your application code to initialize the tracer: + {{< code-block lang="go" disable_copy="false" >}} tracer.Start() defer tracer.Stop() -``` +{{< /code-block >}} -You can also add additional packages: -```shell + You can also add additional packages: + {{< code-block lang="shell" disable_copy="false" >}} # Enable Profiling go get github.com/DataDog/dd-trace-go/v2/profiler # Patch /net/http go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 -``` +{{< /code-block >}} -For more information, see [Tracing Go Applications][1] and the [Tracer README][2]. + For more information, see [Tracing Go Applications][1] and the [Tracer README][2]. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="./your-binary" %}} + {{% gcr-install-serverless-init cmd="./your-binary" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing. + Datadog also recommends setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `logrus`: -```go -logrus.SetFormatter(&logrus.JSONFormatter{}) -logrus.AddHook(&dd_logrus.DDContextLogHook{}) + If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `logrus`: + ```go + logrus.SetFormatter(&logrus.JSONFormatter{}) + logrus.AddHook(&dd_logrus.DDContextLogHook{}) -logrus.WithContext(ctx).Info("Hello World!") -``` + logrus.WithContext(ctx).Info("Hello World!") + ``` -For more information, see [Correlating Go Logs and Traces][3]. + For more information, see [Correlating Go Logs and Traces][3]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="go" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index 4528eede6aed6..2e756ac431c15 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -12,63 +12,68 @@ further_reading: text: 'Correlating Java Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer**. -Add the Java tracer agent to your Dockerfile: + 1. Add the Datadog Java tracer to your Dockerfile: -```dockerfile + {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} ADD 'https://dtdg.co/latest-java-tracer' agent.jar ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" -``` +{{< /code-block >}} -Then, add the tracer artifacts. - -Maven: -```xml + 2. Add the tracer artifacts. + {{< tabs >}} + {{% tab "Maven" %}} +{{< code-block lang="xml" disable_copy="false" >}} com.datadoghq dd-trace-api DD_TRACE_JAVA_VERSION_HERE -``` - -Gradle: -```groovy +{{< /code-block >}} + {{% /tab %}} + + {{% tab "Gradle" %}} +{{< code-block lang="groovy" disable_copy="false" >}} implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' -``` +{{< /code-block >}} + {{% /tab %}} + {{< /tabs >}} -Finally, add the `@Trace` annotation to any method you want to trace. + 3. Add the `@Trace` annotation to any method you want to trace. -For more information, see [Tracing Java Applications][1]. + For more information, see [Tracing Java Applications][1]. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="\"./mvnw\", \"spring-boot:run\"" %}} + {{% gcr-install-serverless-init cmd="\"./mvnw\", \"spring-boot:run\"" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend setting the environment variable `DD_SOURCE=java` to enable advanced Datadog log parsing. + Datadog also recommends setting the environment variable `DD_SOURCE=java` to enable advanced Datadog log parsing. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: -```java + If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: + + {{< code-block lang="java" disable_copy="false" >}} private static final Logger logger = LogManager.getLogger(App.class); logger.info("Hello World!"); -``` -`resources/log4j2.xml`: -```xml +{{< /code-block >}} + + {{< code-block lang="xml" filename="resources/log4j2.xml" disable_copy="false" >}} -``` +{{< /code-block >}} -For more information, see [Correlating Java Logs and Traces][2]. + For more information, see [Correlating Java Logs and Traces][2]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="java" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 7f2d1d109ca15..84e248f7f655f 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -12,40 +12,41 @@ further_reading: text: 'Correlating Node.js Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer**. -In your main application, add the `dd-trace-js` library. - -```shell + 1. In your main application, add `dd-trace-js`. + + {{< code-block lang="shell" disable_copy="false" >}} npm install dd-trace --save -``` +{{< /code-block >}} -Then, add this to your application code to initialize the tracer: -```javascript + 2. Add the following to your application code to initialize the tracer: + {{< code-block lang="javascript" disable_copy="false" >}} const tracer = require('dd-trace').init({ logInjection: true, }); -``` +{{< /code-block >}} -Finally, set the following environment variable to specify that the `dd-trace/init` module is required when the Node.js process starts: -```dockerfile + 3. Set the following environment variable to specify that the `dd-trace/init` module is required when the Node.js process starts: + {{< code-block lang="dockerfile" disable_copy="false" >}} ENV NODE_OPTIONS="--require dd-trace/init" -``` +{{< /code-block >}} -For more information, see [Tracing Node.js applications][1]. + For more information, see [Tracing Node.js applications][1]. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}} + {{% gcr-install-serverless-init cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend setting the environment variable `DD_SOURCE=nodejs` to enable advanced Datadog log parsing. + Datadog also recommends setting the environment variable `DD_SOURCE=nodejs` to enable advanced Datadog log parsing. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: -```javascript + If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: + {{< code-block lang="javascript" disable_copy="false" >}} const tracer = require('dd-trace').init({ logInjection: true, }); @@ -61,11 +62,11 @@ const logger = createLogger({ }); logger.info(`Hello world!`); -``` +{{< /code-block >}} -For more information, see [Correlating Node.js Logs and Traces][2]. + For more information, see [Correlating Node.js Logs and Traces][2]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="nodejs" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 072aefbc7ea65..94612642849a4 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -12,38 +12,37 @@ further_reading: text: 'Correlating PHP Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer** in your Dockerfile. -Install the tracer in your Dockerfile: - -```Dockerfile + {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ && php datadog-setup.php --php-bin=all -``` +{{< /code-block >}} -When running the `datadog-setup.php` script, you can also enable appsec and profiling via the `--enable-appsec` and `--enable-profiling` flags. + When running the `datadog-setup.php` script, you can also enable appsec and profiling via the `--enable-appsec` and `--enable-profiling` flags. -If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: + If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: -```shell + {{< code-block lang="shell" disable_copy="false" >}} apk add libgcc -``` +{{< /code-block >}} -For more information, see [Tracing PHP applications][1]. + For more information, see [Tracing PHP applications][1]. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="\"apache2-foreground\"" %}} + {{% gcr-install-serverless-init cmd="\"apache2-foreground\"" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend setting the environment variable `DD_SOURCE=php` to enable advanced Datadog log parsing. + Datadog also recommends setting the environment variable `DD_SOURCE=php` to enable advanced Datadog log parsing. -For more information, see [Correlating PHP Logs and Traces][2]. + For more information, see [Correlating PHP Logs and Traces][2]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="php" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 992fe55fa4d87..5aa5618be2076 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -12,30 +12,29 @@ further_reading: text: 'Correlating Python Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install a Datadog tracer** in your Dockerfile. -Install the tracer in your Dockerfile: - -```Dockerfile + {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} RUN pip install --target /dd_tracer/python/ ddtrace -``` +{{< /code-block >}} -For more information, see [Tracing Python applications][1]. + For more information, see [Tracing Python applications][1]. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="\"/dd_tracer/python/bin/ddtrace-run\", \"python\", \"path/to/your/python/app.py\"" %}} + {{% gcr-install-serverless-init cmd="\"/dd_tracer/python/bin/ddtrace-run\", \"python\", \"path/to/your/python/app.py\"" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend the following environment variables: -- `ENV PYTHONUNBUFFERED=1`: Ensure Python outputs appear immediately in container logs instead of being buffered. -- `ENV DD_SOURCE=python`: Enable advanced Datadog log parsing. + Datadog also recommends the following environment variables: + - `ENV PYTHONUNBUFFERED=1`: Ensure Python outputs appear immediately in container logs instead of being buffered. + - `ENV DD_SOURCE=python`: Enable advanced Datadog log parsing. -If you want multiline logs to be preserved in a single log message, we recommend writing your logs in JSON format. For example, you can use a third-party logging library such as `structlog`: -```python + If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `structlog`: + {{< code-block lang="python" disable_copy="false" >}} import structlog def tracer_injection(logger, log_method, event_dict): @@ -54,11 +53,11 @@ structlog.configure( logger = structlog.get_logger() logger.info("Hello world!") -``` +{{< /code-block >}} -For more information, see [Correlating Python Logs and Traces][2]. + For more information, see [Correlating Python Logs and Traces][2]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="python" %}} diff --git a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md index 1c7fa130ba39a..4bf54d5c3f02a 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/ruby.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/ruby.md @@ -12,39 +12,40 @@ further_reading: text: 'Correlating Ruby Logs and Traces' --- -## 1. Install the Tracer +## Setup +1. **Install the Datadog Ruby tracer**. -Manually install the Ruby tracer by adding the `datadog` gem to your Gemfile: -```gemfile + Add the `datadog` gem to your Gemfile: + {{< code-block lang="gemfile" disable_copy="false" >}} source 'https://rubygems.org' gem 'datadog' -``` +{{< /code-block >}} -See [Tracing Ruby applications][1] for additional information on how to configure the tracer and enable auto instrumentation. + See [Tracing Ruby applications][1] for additional information on how to configure the tracer and enable auto instrumentation. -## 2. Install Serverless-Init +2. **Install serverless-init**. -{{% gcr-install-serverless-init cmd="\"rails\", \"server\", \"-b\", \"0.0.0.0\"" %}} + {{% gcr-install-serverless-init cmd="\"rails\", \"server\", \"-b\", \"0.0.0.0\"" %}} -## 3. Setup Logs +3. **Set up logs**. -To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows serverless-init to read logs from stdout and stderr. + To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. -We also recommend setting the environment variable `DD_SOURCE=ruby` to enable advanced Datadog log parsing. + Datadog also recommends setting the environment variable `DD_SOURCE=ruby` to enable advanced Datadog log parsing. -To enable log/trace correlation, you will need to include `Datadog::Tracing.log_correlation` in your log format. For example: -```ruby + To enable log-trace correlation, you need to include `Datadog::Tracing.log_correlation` in your log format. For example: + {{< code-block lang="ruby" disable_copy="false" >}} logger = Logger.new(STDOUT) logger.formatter = proc do |severity, datetime, progname, msg| "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" end logger.info "Hello world!" -``` +{{< /code-block >}} -For more information, see [Correlating Ruby Logs and Traces][2]. + For more information, see [Correlating Ruby Logs and Traces][2]. -## 4. Configure your application +4. **Configure your application**. {{% gcr-configure-env-vars language="ruby" %}} diff --git a/layouts/shortcodes/gcr-configure-env-vars.en.html b/layouts/shortcodes/gcr-configure-env-vars.en.html index 4ac063fd3e25b..0473983767dfb 100644 --- a/layouts/shortcodes/gcr-configure-env-vars.en.html +++ b/layouts/shortcodes/gcr-configure-env-vars.en.html @@ -1,30 +1,36 @@ -After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: + After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent: -- `DD_API_KEY`: Datadog API key, used to send data to your Datadog account. It should be configured as a Google Cloud Secret for privacy and safety. -- `DD_SITE`: Datadog endpoint and website. Select your site on the right side of this page. See valid [Datadog Sites](https://docs.datadoghq.com/getting_started/site/#access-the-datadog-site). + - `DD_API_KEY`: Your [Datadog API key][1001], used to send data to your Datadog account. For privacy and safety, configure this API key as a Google Cloud Secret. + - `DD_SITE`: Your [Datadog site][1002]. For example, `datadoghq.com`. -For more environment variables and their function, see [Environment Variables](#environment-variables). + For more environment variables, see the [Environment variables](#environment-variables) section on this page. -The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. + The following command deploys the service and allows any external connection to reach it. In this example, your service listening is set to port 8080. Ensure that this port number matches the exposed port inside of your Dockerfile. -```shell -gcloud run deploy - --image=gcr.io// \ - --port=8080 \ - --update-env-vars=DD_API_KEY=$DD_API_KEY \ - --update-env-vars=DD_SITE=$DD_SITE \ -``` + ```shell + gcloud run deploy + --image=gcr.io// \ + --port=8080 \ + --update-env-vars=DD_API_KEY=$DD_API_KEY \ + --update-env-vars=DD_SITE=$DD_SITE \ + ``` ### Environment variables -| Variable | Description | -| -------- | ----------- | -| `DD_API_KEY` | [Datadog API key](/account_management/api-app-keys/#api-keys) - **Required**| -| `DD_SITE` | [Datadog site](/getting_started/site/) - **Required** | -| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. |{{ if in (slice "java" "nodejs" "csharp" "php") (.Get "language") }} -| `DD_LOGS_INJECTION`| When true, enrich all logs with trace data for supported loggers. See [Correlate Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/) for more information. |{{ end }} -| `DD_SERVICE` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | -| `DD_VERSION` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | -| `DD_ENV` | See [Unified Service Tagging](/getting_started/tagging/unified_service_tagging/). **Recommended** | -| `DD_SOURCE` | Set the log source to enable a [Log Pipeline](/logs/log_configuration/pipelines) for advanced parsing. To automatically apply language-specific parsing rules, set to `{{ .Get "language" }}`, or use your custom pipeline. Defaults to `cloudrun`. | -| `DD_TAGS` | Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (e.g. `key1:value1,key2:value2`). | +| Variable | Description | +| ------------------- | ----------- | +| `DD_API_KEY` | [Datadog API key][1001] - **Required**| +| `DD_SITE` | [Datadog site][1002] - **Required** | +| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. |{{ if in (slice "java" "nodejs" "csharp" "php") (.Get "language") }} +| `DD_LOGS_INJECTION` | When true, enrich all logs with trace data for supported loggers. See [Correlate Logs and Traces][1003] for more information. |{{ end }} +| `DD_SERVICE` | See [Unified Service Tagging][1004]. **Recommended** | +| `DD_VERSION` | See [Unified Service Tagging][1004]. **Recommended** | +| `DD_ENV` | See [Unified Service Tagging][1004]. **Recommended** | +| `DD_SOURCE` | Set the log source to enable a [Log Pipeline][1005] for advanced parsing. To automatically apply language-specific parsing rules, set to `{{ .Get "language" }}`, or use your custom pipeline. Defaults to `cloudrun`. | +| `DD_TAGS` | Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (for example: `key1:value1,key2:value2`). | + +[1001]: https://app.datadoghq.com/organization-settings/api-keys +[1002]: /getting_started/site/ +[1003]: /tracing/other_telemetry/connect_logs_and_traces/ +[1004]: /getting_started/tagging/unified_service_tagging/ +[1005]: /logs/log_configuration/pipelines \ No newline at end of file diff --git a/layouts/shortcodes/gcr-install-serverless-init.html b/layouts/shortcodes/gcr-install-serverless-init.html index 0abd6c4ea6a58..de4dbba31f29d 100644 --- a/layouts/shortcodes/gcr-install-serverless-init.html +++ b/layouts/shortcodes/gcr-install-serverless-init.html @@ -1,4 +1,4 @@ -Datadog publishes new releases of the `serverless-init` container image to Google’s gcr.io, AWS’s ECR, and on Docker Hub: +Datadog publishes new releases of the `serverless-init` container image to Google's gcr.io, AWS's ECR, and on Docker Hub: | hub.docker.com | gcr.io | public.ecr.aws | | ---- | ---- | ---- | @@ -34,7 +34,7 @@

Alternative configuration

-We expect `serverless-init` to be the top-level application with the test of your app's command line passed in for `serverless-init` to execute. +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. @@ -42,14 +42,14 @@

Alternative configuration

CMD ["/app/datadog-init", {{ .Get "cmd" | safeHTML }}] ``` -If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. ```dockerfile ENTRYPOINT ["/app/datadog-init"] CMD ["/your_entrypoint.sh", {{ .Get "cmd" | safeHTML }}] ``` -As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation. +As long as your command to run is passed as an argument to `datadog-init`, you will receive full instrumentation.
diff --git a/layouts/shortcodes/gcr-troubleshooting.en.md b/layouts/shortcodes/gcr-troubleshooting.en.md index 443344b8b686d..323c73517342b 100644 --- a/layouts/shortcodes/gcr-troubleshooting.en.md +++ b/layouts/shortcodes/gcr-troubleshooting.en.md @@ -1,7 +1,9 @@ -This integration depends on your runtime having a full SSL implementation. If you are using a slim image, you may need to add the following command to your Dockerfile to include certificates. +This integration depends on your runtime having a full SSL implementation. If you are using a slim image, you may need to add the following command to your Dockerfile to include certificates: ```dockerfile RUN apt-get update && apt-get install -y ca-certificates ``` -To have your Cloud Run services appear in the [software catalog](/internal_developer_portal/software_catalog/), you will need to set the `DD_SERVICE`, `DD_VERSION`, and `DD_ENV` environment variables. +To have your Cloud Run services appear in the [software catalog][2001], you must set the `DD_SERVICE`, `DD_VERSION`, and `DD_ENV` environment variables. + +[2001]: /internal_developer_portal/software_catalog/ \ No newline at end of file From 56c509fe8467f095e235c4029c98cabf4a8e73f8 Mon Sep 17 00:00:00 2001 From: cecilia saixue watt Date: Wed, 6 Aug 2025 12:43:18 -0700 Subject: [PATCH 51/52] install the tracer --- .../serverless/google_cloud_run/containers/in_process/dotnet.md | 2 +- .../en/serverless/google_cloud_run/containers/in_process/go.md | 2 +- .../serverless/google_cloud_run/containers/in_process/java.md | 2 +- .../serverless/google_cloud_run/containers/in_process/nodejs.md | 2 +- .../en/serverless/google_cloud_run/containers/in_process/php.md | 2 +- .../serverless/google_cloud_run/containers/in_process/python.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md index 31fe11ea7da30..b74e0d73131d4 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/dotnet.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer** in your Dockerfile. +1. **Install the Datadog .NET tracer** in your Dockerfile. Because GitHub requests are rate limited, you must pass a GitHub token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret][1] `--secret id=github-token,env=GITHUB_TOKEN`. diff --git a/content/en/serverless/google_cloud_run/containers/in_process/go.md b/content/en/serverless/google_cloud_run/containers/in_process/go.md index 54958af65caf0..6e9ca2c710b59 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/go.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/go.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer**. +1. **Install the Datadog Go tracer**. 1. In your main application, add the tracing library from `dd-trace-go`. diff --git a/content/en/serverless/google_cloud_run/containers/in_process/java.md b/content/en/serverless/google_cloud_run/containers/in_process/java.md index 2e756ac431c15..047b08e060ea1 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/java.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/java.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer**. +1. **Install the Datadog Java tracer**. 1. Add the Datadog Java tracer to your Dockerfile: diff --git a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md index 84e248f7f655f..f7b33408215b6 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/nodejs.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer**. +1. **Install the Datadog Node.js tracer**. 1. In your main application, add `dd-trace-js`. diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 94612642849a4..200f5d7971863 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer** in your Dockerfile. +1. **Install the Datadog PHP tracer** in your Dockerfile. {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ diff --git a/content/en/serverless/google_cloud_run/containers/in_process/python.md b/content/en/serverless/google_cloud_run/containers/in_process/python.md index 5aa5618be2076..8a10f1fccd598 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/python.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/python.md @@ -13,7 +13,7 @@ further_reading: --- ## Setup -1. **Install a Datadog tracer** in your Dockerfile. +1. **Install the Datadog Python tracer** in your Dockerfile. {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} RUN pip install --target /dd_tracer/python/ ddtrace From ff23e05488b0d44648bb39c2752754c3a3d6db68 Mon Sep 17 00:00:00 2001 From: cecilia saixue watt Date: Wed, 6 Aug 2025 13:39:38 -0700 Subject: [PATCH 52/52] small edit --- .../en/serverless/google_cloud_run/containers/in_process/php.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/google_cloud_run/containers/in_process/php.md b/content/en/serverless/google_cloud_run/containers/in_process/php.md index 200f5d7971863..5a1bbc5e8a58d 100644 --- a/content/en/serverless/google_cloud_run/containers/in_process/php.md +++ b/content/en/serverless/google_cloud_run/containers/in_process/php.md @@ -20,7 +20,7 @@ RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/da && php datadog-setup.php --php-bin=all {{< /code-block >}} - When running the `datadog-setup.php` script, you can also enable appsec and profiling via the `--enable-appsec` and `--enable-profiling` flags. + When running the `datadog-setup.php` script, you can also enable Application Security and Profiling by using the `--enable-appsec` and `--enable-profiling` flags, respectively. If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: