- 필수 기능
- 시작하기
- 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 Go tracer.
In your main application, add the tracing library from dd-trace-go
.
go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer
Add the following to your application code to initialize the tracer:
tracer.Start()
defer tracer.Stop()
You can also add additional packages:
# 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 and the Tracer README.
Install serverless-init.
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 changes1.x.x
, 1.x.x-alpine
: use these to pin to a precise version of the librarylatest
, latest-alpine
: use these to follow the latest version release, which may include breaking changesAdd the following instructions and arguments to your Dockerfile.
COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENTRYPOINT ["/app/datadog-init"]
CMD [./your-binary]
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.
CMD ["/app/datadog-init", ./your-binary]
If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments.
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.
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.
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, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as logrus
:
logrus.SetFormatter(&logrus.JSONFormatter{})
logrus.AddHook(&dd_logrus.DDContextLogHook{})
logrus.WithContext(ctx).Info("Hello World!")
For more information, see Correlating Go Logs and Traces.
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
: Your Datadog API key, 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. For example, datadoghq.com
.For more environment variables, see the 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.
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 \
Finally, 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.
Variable | Description |
---|---|
DD_API_KEY | Datadog API key - Required |
DD_SITE | Datadog site - Required |
DD_LOGS_ENABLED | When true, send logs (stdout and stderr) to Datadog. Defaults to false. |
DD_SERVICE | See Unified Service Tagging. 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 go , 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 ). |
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.
추가 유용한 문서, 링크 및 기사: