Skip to content

Commit 6cf5073

Browse files
committed
add configuration section
1 parent e71bead commit 6cf5073

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

content/en/serverless/google_cloud_run/containers/in_process/nodejs.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Instrumenting a Node.js Cloud Run Container In-Process
33
further_reading:
4-
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started'
4+
- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/'
55
tag: 'Documentation'
66
text: 'Tracing Node.js Applications'
77
---
@@ -21,7 +21,7 @@ const tracer = require('dd-trace').init({
2121
});
2222
```
2323

24-
For more information, see [Tracing Node.js applications](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started).
24+
For more information, see [Tracing Node.js applications][1].
2525

2626
## 2. Install Serverless-Init
2727

@@ -30,9 +30,6 @@ Add the following instructions and arguments to your Dockerfile.
3030
```dockerfile
3131
COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
3232
ENV NODE_OPTIONS="--require dd-trace/init"
33-
ENV DD_SERVICE=datadog-demo-run-nodejs
34-
ENV DD_ENV=datadog-demo
35-
ENV DD_VERSION=1
3633
ENTRYPOINT ["/app/datadog-init"]
3734
CMD ["/nodejs/bin/node", "/path/to/your/app.js"]
3835
```
@@ -51,22 +48,14 @@ CMD ["/nodejs/bin/node", "/path/to/your/app.js"]
5148
ENV NODE_OPTIONS="--require dd-trace/init"
5249
```
5350

54-
3. (Optional) Add Datadog tags.
55-
56-
```dockerfile
57-
ENV DD_SERVICE=datadog-demo-run-nodejs
58-
ENV DD_ENV=datadog-demo
59-
ENV DD_VERSION=1
60-
```
61-
62-
4. Change the entrypoint to wrap your application in the Datadog `serverless-init` process.
51+
3. Change the entrypoint to wrap your application in the Datadog `serverless-init` process.
6352
**Note**: If you already have an entrypoint defined inside your Dockerfile, see the [alternative configuration](#alt-node).
6453

6554
```dockerfile
6655
ENTRYPOINT ["/app/datadog-init"]
6756
```
6857

69-
5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.
58+
4. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.
7059
```dockerfile
7160
CMD ["node", "/path/to/your/app.js"]
7261
```
@@ -99,10 +88,19 @@ const logger = createLogger({
9988
exitOnError: false,
10089
format: format.json(),
10190
transports: [
102-
new transports.File({ filename: `/shared-volume/logs/app.log` }),
10391
new transports.Console()
10492
],
10593
});
10694

10795
logger.info(`Hello world!`);
10896
```
97+
98+
## 4. Configure your application
99+
100+
{{% gcr-configure-env-vars %}}
101+
102+
## Further reading
103+
104+
{{< partial name="whats-next/whats-next.html" >}}
105+
106+
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
After the container is built and pushed to your registry, set the required environment variables for the Datadog Agent:
2+
3+
- `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.
4+
- `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" >}}.
5+
6+
For more environment variables and their function, see [Environment Variables](#environment-variables).
7+
8+
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.
9+
10+
```shell
11+
gcloud run deploy <APP_NAME>
12+
--image=gcr.io/<YOUR_PROJECT>/<APP_NAME> \
13+
--port=8080 \
14+
--update-env-vars=DD_API_KEY=$DD_API_KEY \
15+
--update-env-vars=DD_SITE=$DD_SITE \
16+
```
17+
18+
### Environment variables
19+
20+
| Variable | Description |
21+
| -------- | ----------- |
22+
| `DD_API_KEY` | [Datadog API key][1] - **Required**|
23+
| `DD_SITE` | [Datadog site][2] - **Required** |
24+
| `DD_LOGS_ENABLED` | When true, send logs (stdout and stderr) to Datadog. Defaults to false. |
25+
| `DD_SERVICE` | See [Unified Service Tagging][3]. |
26+
| `DD_VERSION` | See [Unified Service Tagging][3]. |
27+
| `DD_ENV` | See [Unified Service Tagging][3]. |
28+
| `DD_SOURCE` | See [Unified Service Tagging][3]. |
29+
| `DD_TAGS` | See [Unified Service Tagging][3]. |
30+
31+
32+
[1]: /account_management/api-app-keys/#api-keys
33+
[2]: /getting_started/site/
34+
[3]: /getting_started/tagging/unified_service_tagging/

0 commit comments

Comments
 (0)