- Essentials
- In The App
- Infrastructure
- Application Performance
- Log Management
- Security Platform
- UX Monitoring
- Administration
After you set up the tracing library with your code, configure the Agent to collect APM data, and activate the Go integration, optionally configure the tracing library as desired.
Datadog recommends using DD_ENV
, DD_SERVICE
, and DD_VERSION
to set env
, service
, and version
for your services.
Read the Unified Service Tagging documentation for recommendations on how to configure these environment variables. These variables are available for versions 1.24.0+ of the Go tracer.
You may also elect to provide env
, service
, and version
through the tracer’s API:
package main
import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
func main() {
tracer.Start(
tracer.WithEnv("prod"),
tracer.WithService("test-go"),
tracer.WithServiceVersion("abc123"),
)
// When the tracer is stopped, it will flush everything it has to the Datadog Agent before quitting.
// Make sure this line stays in your main function.
defer tracer.Stop()
}
The Go tracer supports additional environment variables and functions for configuration. See all available options in the configuration documentation.
DD_VERSION
1.2.3
, 6c44da20
, 2020.02.13
DD_SERVICE
DD_ENV
DD_AGENT_HOST
localhost
DD_DOGSTATSD_PORT
8125
DD_TRACE_SAMPLING_RULES
nil
"sample_rate"
. The "name"
and "service"
fields are optional. The "sample_rate"
value must be between 0.0
and 1.0
(inclusive). Rules are applied in configured order to determine the trace’s sample rate.
For more information, see Ingestion Mechanisms.'[{"sample_rate": 0.2}]'
'[{"service": "a.*", "name": "b", "sample_rate": 0.1}, {"sample_rate": 0.2}]'
DD_TRACE_SAMPLE_RATE
DD_TRACE_RATE_LIMIT
DD_TAGS
layer:api,team:intake
or layer:api team:intake
DD_TRACE_STARTUP_LOGS
true
DD_TRACE_DEBUG
false
DD_TRACE_ENABLED
true
DD_SERVICE_MAPPING
null
mysql:mysql-service-name,postgres:postgres-service-name
, mysql:mysql-service-name postgres:postgres-service-name
.The APM environment name may be configured in the Agent or using the WithEnv start option of the tracer.
The Datadog APM tracer supports B3 headers extraction and injection for distributed tracing.
Distributed headers injection and extraction is controlled by
configuring injection/extraction styles. Two styles are
supported: Datadog
and B3
.
Configure injection styles using the environment variable
DD_PROPAGATION_STYLE_INJECT=Datadog,B3
Configure extraction styles using the environment variable
DD_PROPAGATION_STYLE_EXTRACT=Datadog,B3
The values of these environment variables are comma separated lists of
header styles that are enabled for injection or extraction. By default only
the Datadog
extraction style is enabled.
If multiple extraction styles are enabled, extraction attempts are made in the order that those styles are specified. The first successfully extracted value is used.
Additional helpful documentation, links, and articles: