- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
To manually instrument a method:
{
// Create a root span for the current request.
auto root_span = tracer.create_span();
root_span.set_name("get_ingredients");
// Set a resource name for the root span.
root_span.set_resource_name("bologna_sandwich");
// Create a child span with the root span as its parent.
auto child_span = root_span.create_child();
child_span.set_name("cache_lookup");
// Set a resource name for the child span.
child_span.set_resource_name("ingredients.bologna_sandwich");
// Spans can be finished at an explicit time ...
child_span.set_end_time(std::chrono::steady_clock::now());
} // ... or implicitly when the destructor is invoked.
// For example, root_span finishes here.
Add custom span tags to your spans to customize your observability within Datadog. Span tags are applied to your incoming traces, allowing you to correlate observed behavior with code-level information such as merchant tier, checkout amount, or user ID.
Note that some Datadog tags are necessary for unified service tagging.
Add tags directly to a span object by calling Span::set_tag
. For example:
// Add tags directly to a span by calling `Span::set_tag`
auto span = tracer.create_span();
span.set_tag("key must be string", "value must also be a string");
// Or, add tags by setting a `SpanConfig`
datadog::tracing::SpanConfig opts;
opts.tags.emplace("team", "apm-proxy");
auto span2 = tracer.create_span(opts);
To set tags across all your spans, set the DD_TAGS
environment variable as a list of key:value
pairs separated by commas.
export DD_TAGS=team:apm-proxy,key:value
datadog::tracing::TracerConfig tracer_config;
tracer_config.tags = {
{"team", "apm-proxy"},
{"apply", "on all spans"}
};
const auto validated_config = datadog::tracing::finalize_config(tracer_config);
auto tracer = datadog::tracing::Tracer(*validated_config);
// All new spans will have contains tags defined in `tracer_config.tags`
auto span = tracer.create_span();
To associate a span with an error, set one or more error-related tags on the span. For example:
span.set_error(true);
Add more specific information about the error by setting any combination of error.message
, error.stack
, or error.type
by using respectively Span::set_error_message
, Span::set_error_stack
and Span::set_error_type
. See Error Tracking for more information about error tags.
An example of adding a combination of error tags:
// Associate this span with the "bad file descriptor" error from the standard
// library.
span.set_error_message("error");
span.set_error_stack("[EBADF] invalid file");
span.set_error_type("errno");
To unset an error on a span, set Span::set_error
to false
, which removes any combination of Span::set_error_stack
, Span::set_error_type
or Span::set_error_message
.
// Clear any error information associated with this span.
span.set_error(false);
You can configure the propagation of context for distributed traces by injecting and extracting headers. Read Trace Context Propagation for information.
Traces can be excluded based on their resource name, to remove synthetic traffic such as health checks from sending traces and influencing trace metrics. Find information about this and other security and fine-tuning configuration on the Security page.