-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Cloud Run] Split up In-Process docs #30742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 48 commits
be6fbd9
9980e70
b3562b8
e5a83d8
a92a866
3b28600
e71bead
6cf5073
c1241d7
ed939e0
46c3aa5
9093187
bf98893
574a44e
be52fa5
eee4c20
c66b10e
8c83b3e
2bd7ec9
75cccfe
32c2334
996c479
bb695fc
962038f
d006de5
a2f274d
4365633
6e67232
b80aec1
a4b77f2
908c660
a64a11d
8109198
749aa7d
e40d1ff
ac753da
4c621cc
8175816
8260220
31843f2
82cc8f9
356b524
46578e6
622bcec
472be85
4a09b8c
1c12c60
3d819e6
cb81da2
59cc524
1302b66
c3cf8b0
56c509f
ff23e05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: In-Process Instrumentation | ||
type: multi-code-lang | ||
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. | ||
nhulston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Then, instrument your application using one of the following guides: | ||
|
||
{{< partial name="serverless/in-process-languages.html" >}} | ||
|
||
[1]: /integrations/google-cloud-platform/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have public sample apps we can link to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we decided not to link to sample apps? I will ask Piyali There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay got confirmation, we can link them! |
||
|
||
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 \ | ||
nhulston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
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. | ||
|
||
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; | ||
|
||
builder.Host.UseSerilog((context, config) => | ||
{ | ||
config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)); | ||
}); | ||
|
||
logger.LogInformation("Hello World!"); | ||
apiarian-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
For more information, see [Correlating .NET Logs and Traces][3]. | ||
|
||
## 4. Configure your application | ||
|
||
{{% gcr-configure-env-vars %}} | ||
|
||
## Troubleshooting | ||
|
||
{{% gcr-troubleshooting %}} | ||
|
||
## 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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
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' | ||
--- | ||
|
||
## 1. Install the Tracer | ||
|
||
In your main application, add the tracing library from `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() | ||
``` | ||
|
||
You can also 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 | ||
|
||
{{% gcr-install-serverless-init cmd="./your-binary" %}} | ||
|
||
## 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 %}} | ||
|
||
## Troubleshooting | ||
|
||
{{% gcr-troubleshooting %}} | ||
|
||
## 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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
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' | ||
--- | ||
|
||
## 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 | ||
<dependency> | ||
<groupId>com.datadoghq</groupId> | ||
<artifactId>dd-trace-api</artifactId> | ||
<version>DD_TRACE_JAVA_VERSION_HERE</version> | ||
</dependency> | ||
``` | ||
|
||
Gradle: | ||
```groovy | ||
implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' | ||
``` | ||
|
||
Finally, add the `@Trace` annotation to 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. | ||
|
||
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); | ||
logger.info("Hello World!"); | ||
``` | ||
`resources/log4j2.xml`: | ||
```xml | ||
<Configuration> | ||
<Appenders> | ||
<Console name="Console"><JsonLayout compact="true" eventEol="true" properties="true"/></Console> | ||
</Appenders> | ||
<Loggers><Root level="info"><AppenderRef ref="Console"/></Root></Loggers> | ||
</Configuration> | ||
``` | ||
|
||
For more information, see [Correlating Java Logs and Traces][2]. | ||
|
||
## 4. Configure your application | ||
|
||
{{% gcr-configure-env-vars %}} | ||
|
||
## Troubleshooting | ||
|
||
{{% gcr-troubleshooting %}} | ||
|
||
## 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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
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' | ||
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 | ||
|
||
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, | ||
}); | ||
``` | ||
|
||
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 | ||
|
||
{{% gcr-install-serverless-init cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}} | ||
|
||
## 3. Setup Logs | ||
nhulston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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({ | ||
logInjection: true, | ||
}); | ||
const { createLogger, format, transports } = require('winston'); | ||
|
||
const logger = createLogger({ | ||
level: 'info', | ||
exitOnError: false, | ||
format: format.json(), | ||
transports: [ | ||
new transports.Console() | ||
], | ||
}); | ||
|
||
logger.info(`Hello world!`); | ||
``` | ||
|
||
For more information, see [Correlating Node.js Logs and Traces][2]. | ||
|
||
## 4. Configure your application | ||
|
||
{{% gcr-configure-env-vars %}} | ||
|
||
## Troubleshooting | ||
|
||
{{% gcr-troubleshooting %}} | ||
|
||
## Further reading | ||
|
||
{{< 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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including "Google Cloud Run" in each subpage was getting very redundant; here's what it looks like now: