- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`Install the Datadog .NET tracer.
Add the Datadog.Trace.Bundle
NuGet package to your application.
Set the following environment variables to enable automatic instrumentation:
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
CORECLR_PROFILER_PATH=/workspace/datadog/linux-x64/Datadog.Trace.ClrProfiler.Native.so
DD_DOTNET_TRACER_HOME=/workspace/datadog
For more information, see Tracing .NET applications.
Install serverless-init as a sidecar.
Install the Datadog CLI client
npm install -g @datadog/datadog-ci
Install the gcloud CLI and authenticate with gcloud auth login
.
Configure the Datadog site and Datadog API key, and define the service name to use in Datadog.
export DATADOG_SITE="<DATADOG_SITE>"
export DD_API_KEY="<DD_API_KEY>"
export DD_SERVICE="<SERVICE_NAME>"
If you are new to Datadog serverless monitoring, launch the Datadog CLI in interactive mode to guide your first installation for a quick start.
datadog-ci cloud-run instrument -i
To permanently install Datadog for your production applications, run the instrument
command in your CI/CD pipelines after your normal deployment. You can specify multiple services to instrument by passing multiple --service
flags.
datadog-ci cloud-run instrument --project <GCP-PROJECT-ID> --service <CLOUD-RUN-SERVICE-NAME> --region <GCP-REGION>
Additional parameters can be found in the CLI documentation.
After deploying your Cloud Run app, you can manually modify your app’s settings to enable Datadog monitoring.
Create a Volume with In-Memory
volume type.
Add a new container with image URL: gcr.io/datadoghq/serverless-init:latest
.
Add the volume mount to every container in your application. Choose a path such as /shared-volume
, and remember it for the next step. For example:
Add the following environment variables to your serverless-init
sidecar container:
DD_SERVICE
: A name for your service. For example, gcr-sidecar-test
.DD_ENV
: A name for your environment. For example, dev
.DD_SERVERLESS_LOG_PATH
: Your log path. For example, /shared-volume/logs/*.log
. The path must begin with the mount path you defined in the previous step.DD_API_KEY
: Your Datadog API key.FUNCTION_TARGET
: The entry point of your function. For example, Main
.For a list of all environment variables, including additional tags, see Environment variables.
Set up logs.
In the previous step, you created a shared volume. You may have also set the DD_SERVERLESS_LOG_PATH
environment variable, which defaults to /shared-volume/logs/app.log
.
In this step, configure your logging library to write logs to the file set in DD_SERVERLESS_LOG_PATH
. In .NET, Datadog recommends writing logs in JSON format. For example, you can use a third-party logging library such as Serilog
:
using Serilog;
const string LOG_FILE = "/shared-volume/logs/app.log";
builder.Host.UseSerilog((context, config) =>
{
// Ensure the directory exists
Directory.CreateDirectory(Path.GetDirectoryName(LOG_FILE)!);
config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true))
.WriteTo.File(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true), LOG_FILE);
});
logger.LogInformation("Hello World!");
Datadog recommends setting the environment variables DD_LOGS_INJECTION=true
(in your main container) and DD_SOURCE=csharp
(in your sidecar container) to enable advanced Datadog log parsing.
For more information, see Correlating .NET Logs and Traces.
Add a service label in Google Cloud. In your Cloud Run service’s info panel, add a label with the following key and value:
Key | Value |
---|---|
service | The name of your service. Matches the value provided as the DD_SERVICE environment variable. |
See Configure labels for services in the Cloud Run documentation for instructions.
Send custom metrics.
To send custom metrics, install the DogStatsD client and view code examples. In Serverless Monitoring, only the distribution metric type is supported.
Unless specified otherwise, all environment variables below should be set in the sidecar container. Only environment variables used to configure the tracer should be set in your main application container.
Variable | Description |
---|---|
DD_API_KEY | Datadog API key - Required |
DD_SITE | Datadog site - Required |
DD_SERVERLESS_LOG_PATH | The path where the sidecar should tail logs from. Defaults to /shared-volume/logs/app.log . |
DD_LOGS_INJECTION | When true, enrich all logs with trace data for supported loggers. See Correlate Logs and Traces for more information. Set in your main application container, not the sidecar container. |
DD_SERVICE | See Unified Service Tagging. Set in all containers. Recommended |
DD_VERSION | See Unified Service Tagging. Recommended |
DD_ENV | See Unified Service Tagging. Recommended |
DD_SOURCE | Set the log source to enable a Log Pipeline for advanced parsing. To automatically apply language-specific parsing rules, set to csharp , 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 ). |
FUNCTION_TARGET | Required for correct tagging. The entry point of your function. For example, Main . You can also find FUNCTION_TARGET on the source tab inside Google console: Function entry point . |
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
To have your Cloud Run services appear in the software catalog, you must set the DD_SERVICE
, DD_VERSION
, and DD_ENV
environment variables.