Skip to content

Commit afa621c

Browse files
nhulstoncswatt
andauthored
[Cloud Run] Split up In-Process docs (#30742)
* update containers overview page with tabs * create empty pages for each in-process language * fill out nodejs in-process * fix layout * fix layout * cleanup nodejs page; fix links * reorganize files * add configuration section * update tab structure * add python instructions * remove empty page * make explanation and alternative configuration collapsible * fix `gcloud run deploy` shell * fix expandable content * fix languages tabs at top * update collapsible * fix links; update collapsible * nits * add more information to "Alternative configuration" * 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 * Move `NODE_OPTIONS` to tracer installation instructions * clarify DD_SITE * fill in `go.md` * nits go.md * try using hugo shortcodes to simplify step 2 * try to fix shortcode * Reorder languages * Fix nested shortcode * fix escaped quotes * update go and nodejs to use shortcode * implement java.md * nits * implement dotnet.md * nits * implement ruby.md * implement php.md * add troubleshooting instructions * add google cloud integration setup * add more info about serverless-init image and tags * fix markdown link * add aliases for old paths * add `DD_SOURCE=nodejs` recommendation * update titles * Add software catalog troubleshooting and mark required env vars as recommended * fix link * optimize PHP dockerfile by combining RUN instructions * nits * Only show relevant language docs in configure env vars table * fix table * formatting * install the tracer * small edit --------- Co-authored-by: cecilia saixue watt <[email protected]>
1 parent 461addd commit afa621c

File tree

16 files changed

+720
-221
lines changed

16 files changed

+720
-221
lines changed

content/en/serverless/google_cloud_run/containers.md renamed to content/en/serverless/google_cloud_run/containers/_index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: Choosing an Instrumentation Method for Google Cloud Run Containers
2+
title: Choosing an Instrumentation Method for Containers
33
further_reading:
44
- link: "/integrations/google-cloud-run/"
55
tag: "Documentation"
66
text: "Google Cloud Run Integration"
77
- link: 'https://www.datadoghq.com/blog/collect-traces-logs-from-cloud-run-with-datadog/'
88
tag: 'Blog'
99
text: 'Collect traces, logs, and custom metrics from Cloud Run services'
10-
- link: "/serverless/google_cloud_run/containers_in_process/"
10+
- link: "/serverless/google_cloud_run/containers/in_process/"
1111
tag: 'Documentation'
1212
text: 'Instrument your container with the in-process approach'
13-
- link: "/serverless/google_cloud_run/containers_sidecar/"
13+
- link: "/serverless/google_cloud_run/containers/sidecar/"
1414
tag: 'Documentation'
1515
text: 'Instrument your container with the sidecar approach'
1616
---
@@ -19,7 +19,7 @@ To instrument your Google Cloud Run containers with Datadog, choose one of two o
1919

2020
{{% google-cloud-run-container-options %}}
2121

22-
- [**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.
22+
- [**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.
2323
- [**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.
2424

2525
## Comparison: in-process versus sidecar instrumentation
@@ -38,5 +38,5 @@ To instrument your Google Cloud Run containers with Datadog, choose one of two o
3838

3939
{{< partial name="whats-next/whats-next.html" >}}
4040

41-
[1]: /serverless/google_cloud_run/containers_in_process
42-
[2]: /serverless/google_cloud_run/containers_sidecar
41+
[1]: /serverless/google_cloud_run/containers/in_process
42+
[2]: /serverless/google_cloud_run/containers/sidecar
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: In-Process Instrumentation
3+
type: multi-code-lang
4+
aliases:
5+
- /serverless/google_cloud_run/containers_in_process/
6+
---
7+
8+
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.
9+
10+
Then, instrument your application using one of the following guides:
11+
12+
{{< partial name="serverless/in-process-languages.html" >}}
13+
14+
[1]: /integrations/google-cloud-platform/
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Instrumenting a .NET Cloud Run Container In-Process
3+
code_lang: dotnet
4+
type: multi-code-lang
5+
code_lang_weight: 50
6+
further_reading:
7+
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux'
8+
tag: 'Documentation'
9+
text: 'Tracing .NET Core Applications'
10+
- link: '/tracing/other_telemetry/connect_logs_and_traces/dotnet/'
11+
tag: 'Documentation'
12+
text: 'Correlating .NET Logs and Traces'
13+
---
14+
15+
## Setup
16+
1. **Install the Datadog .NET tracer** in your Dockerfile.
17+
18+
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`.
19+
20+
{{< tabs >}}
21+
{{% tab "Linux/AMD64" %}}
22+
{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}}
23+
RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \
24+
chmod +x /app/dotnet.sh && /app/dotnet.sh
25+
{{< /code-block >}}
26+
{{% /tab %}}
27+
28+
{{% tab "Alpine" %}}
29+
{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}}
30+
# For alpine use datadog-dotnet-apm-2.57.0-musl.tar.gz
31+
ARG TRACER_VERSION
32+
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
33+
34+
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
35+
{{< /code-block >}}
36+
{{% /tab %}}
37+
{{< /tabs >}}
38+
39+
For more information, see [Tracing .NET applications][2].
40+
41+
2. **Install serverless-init**.
42+
43+
{{% gcr-install-serverless-init cmd="\"dotnet\", \"dotnet.dll\"" %}}
44+
45+
3. **Set up logs**.
46+
47+
To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr.
48+
49+
Datadog also recommends setting the environment variable `DD_SOURCE=csharp` to enable advanced Datadog log parsing.
50+
51+
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`:
52+
53+
{{< code-block lang="csharp" disable_copy="false" >}}
54+
using Serilog;
55+
56+
builder.Host.UseSerilog((context, config) =>
57+
{
58+
config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true));
59+
});
60+
61+
logger.LogInformation("Hello World!");
62+
{{< /code-block >}}
63+
64+
For more information, see [Correlating .NET Logs and Traces][3].
65+
66+
4. **Configure your application**.
67+
68+
{{% gcr-configure-env-vars language="csharp" %}}
69+
70+
## Troubleshooting
71+
72+
{{% gcr-troubleshooting %}}
73+
74+
## Further reading
75+
76+
{{< partial name="whats-next/whats-next.html" >}}
77+
78+
[1]: https://docs.docker.com/build/building/secrets/
79+
[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux
80+
[3]: /tracing/other_telemetry/connect_logs_and_traces/dotnet/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Instrumenting a Go Cloud Run Container In-Process
3+
code_lang: go
4+
type: multi-code-lang
5+
code_lang_weight: 30
6+
further_reading:
7+
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/'
8+
tag: 'Documentation'
9+
text: 'Tracing Go Applications'
10+
- link: '/tracing/other_telemetry/connect_logs_and_traces/go/'
11+
tag: 'Documentation'
12+
text: 'Correlating Go Logs and Traces'
13+
---
14+
15+
## Setup
16+
1. **Install the Datadog Go tracer**.
17+
18+
1. In your main application, add the tracing library from `dd-trace-go`.
19+
20+
{{< code-block lang="shell" disable_copy="false" >}}
21+
go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer
22+
{{< /code-block >}}
23+
24+
2. Add the following to your application code to initialize the tracer:
25+
{{< code-block lang="go" disable_copy="false" >}}
26+
tracer.Start()
27+
defer tracer.Stop()
28+
{{< /code-block >}}
29+
30+
You can also add additional packages:
31+
{{< code-block lang="shell" disable_copy="false" >}}
32+
# Enable Profiling
33+
go get github.com/DataDog/dd-trace-go/v2/profiler
34+
35+
# Patch /net/http
36+
go get github.com/DataDog/dd-trace-go/contrib/net/http/v2
37+
{{< /code-block >}}
38+
39+
For more information, see [Tracing Go Applications][1] and the [Tracer README][2].
40+
41+
2. **Install serverless-init**.
42+
43+
{{% gcr-install-serverless-init cmd="./your-binary" %}}
44+
45+
3. **Set up logs**.
46+
47+
To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr.
48+
49+
Datadog also recommends setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing.
50+
51+
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`:
52+
```go
53+
logrus.SetFormatter(&logrus.JSONFormatter{})
54+
logrus.AddHook(&dd_logrus.DDContextLogHook{})
55+
56+
logrus.WithContext(ctx).Info("Hello World!")
57+
```
58+
59+
For more information, see [Correlating Go Logs and Traces][3].
60+
61+
4. **Configure your application**.
62+
63+
{{% gcr-configure-env-vars language="go" %}}
64+
65+
## Troubleshooting
66+
67+
{{% gcr-troubleshooting %}}
68+
69+
## Further reading
70+
71+
{{< partial name="whats-next/whats-next.html" >}}
72+
73+
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/
74+
[2]: https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing
75+
[3]: /tracing/other_telemetry/connect_logs_and_traces/go/
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Instrumenting a Java Cloud Run Container In-Process
3+
code_lang: java
4+
type: multi-code-lang
5+
code_lang_weight: 40
6+
further_reading:
7+
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/'
8+
tag: 'Documentation'
9+
text: 'Tracing Java Applications'
10+
- link: '/tracing/other_telemetry/connect_logs_and_traces/java/'
11+
tag: 'Documentation'
12+
text: 'Correlating Java Logs and Traces'
13+
---
14+
15+
## Setup
16+
1. **Install the Datadog Java tracer**.
17+
18+
1. Add the Datadog Java tracer to your Dockerfile:
19+
20+
{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}}
21+
ADD 'https://dtdg.co/latest-java-tracer' agent.jar
22+
ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar"
23+
{{< /code-block >}}
24+
25+
2. Add the tracer artifacts.
26+
{{< tabs >}}
27+
{{% tab "Maven" %}}
28+
{{< code-block lang="xml" disable_copy="false" >}}
29+
<dependency>
30+
<groupId>com.datadoghq</groupId>
31+
<artifactId>dd-trace-api</artifactId>
32+
<version>DD_TRACE_JAVA_VERSION_HERE</version>
33+
</dependency>
34+
{{< /code-block >}}
35+
{{% /tab %}}
36+
37+
{{% tab "Gradle" %}}
38+
{{< code-block lang="groovy" disable_copy="false" >}}
39+
implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE'
40+
{{< /code-block >}}
41+
{{% /tab %}}
42+
{{< /tabs >}}
43+
44+
3. Add the `@Trace` annotation to any method you want to trace.
45+
46+
For more information, see [Tracing Java Applications][1].
47+
48+
2. **Install serverless-init**.
49+
50+
{{% gcr-install-serverless-init cmd="\"./mvnw\", \"spring-boot:run\"" %}}
51+
52+
3. **Set up logs**.
53+
54+
To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr.
55+
56+
Datadog also recommends setting the environment variable `DD_SOURCE=java` to enable advanced Datadog log parsing.
57+
58+
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`:
59+
60+
{{< code-block lang="java" disable_copy="false" >}}
61+
private static final Logger logger = LogManager.getLogger(App.class);
62+
logger.info("Hello World!");
63+
{{< /code-block >}}
64+
65+
{{< code-block lang="xml" filename="resources/log4j2.xml" disable_copy="false" >}}
66+
<Configuration>
67+
<Appenders>
68+
<Console name="Console"><JsonLayout compact="true" eventEol="true" properties="true"/></Console>
69+
</Appenders>
70+
<Loggers><Root level="info"><AppenderRef ref="Console"/></Root></Loggers>
71+
</Configuration>
72+
{{< /code-block >}}
73+
74+
For more information, see [Correlating Java Logs and Traces][2].
75+
76+
4. **Configure your application**.
77+
78+
{{% gcr-configure-env-vars language="java" %}}
79+
80+
## Troubleshooting
81+
82+
{{% gcr-troubleshooting %}}
83+
84+
## Further reading
85+
86+
{{< partial name="whats-next/whats-next.html" >}}
87+
88+
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/java/
89+
[2]: /tracing/other_telemetry/connect_logs_and_traces/java/
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Instrumenting a Node.js Cloud Run Container In-Process
3+
code_lang: nodejs
4+
type: multi-code-lang
5+
code_lang_weight: 20
6+
further_reading:
7+
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/'
8+
tag: 'Documentation'
9+
text: 'Tracing Node.js Applications'
10+
- link: '/tracing/other_telemetry/connect_logs_and_traces/nodejs/'
11+
tag: 'Documentation'
12+
text: 'Correlating Node.js Logs and Traces'
13+
---
14+
15+
## Setup
16+
1. **Install the Datadog Node.js tracer**.
17+
18+
1. In your main application, add `dd-trace-js`.
19+
20+
{{< code-block lang="shell" disable_copy="false" >}}
21+
npm install dd-trace --save
22+
{{< /code-block >}}
23+
24+
2. Add the following to your application code to initialize the tracer:
25+
{{< code-block lang="javascript" disable_copy="false" >}}
26+
const tracer = require('dd-trace').init({
27+
logInjection: true,
28+
});
29+
{{< /code-block >}}
30+
31+
3. Set the following environment variable to specify that the `dd-trace/init` module is required when the Node.js process starts:
32+
{{< code-block lang="dockerfile" disable_copy="false" >}}
33+
ENV NODE_OPTIONS="--require dd-trace/init"
34+
{{< /code-block >}}
35+
36+
For more information, see [Tracing Node.js applications][1].
37+
38+
2. **Install serverless-init**.
39+
40+
{{% gcr-install-serverless-init cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}}
41+
42+
3. **Set up logs**.
43+
44+
To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr.
45+
46+
Datadog also recommends setting the environment variable `DD_SOURCE=nodejs` to enable advanced Datadog log parsing.
47+
48+
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`:
49+
{{< code-block lang="javascript" disable_copy="false" >}}
50+
const tracer = require('dd-trace').init({
51+
logInjection: true,
52+
});
53+
const { createLogger, format, transports } = require('winston');
54+
55+
const logger = createLogger({
56+
level: 'info',
57+
exitOnError: false,
58+
format: format.json(),
59+
transports: [
60+
new transports.Console()
61+
],
62+
});
63+
64+
logger.info(`Hello world!`);
65+
{{< /code-block >}}
66+
67+
For more information, see [Correlating Node.js Logs and Traces][2].
68+
69+
4. **Configure your application**.
70+
71+
{{% gcr-configure-env-vars language="nodejs" %}}
72+
73+
## Troubleshooting
74+
75+
{{% gcr-troubleshooting %}}
76+
77+
## Further reading
78+
79+
{{< partial name="whats-next/whats-next.html" >}}
80+
81+
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/
82+
[2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/

0 commit comments

Comments
 (0)