이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.
Add custom span tags to your spans to customize your observability within Datadog. The 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.
C++ tracing uses “common tags”. These tags can be sourced from both Datadog specific tags or OpenTracing tags, and included like this:
Note that the Datadog tags are necessary for unified service tagging.
Add tags directly to a span object by calling
Span::SetTag. For example:
auto tracer = ...
auto span = tracer->StartSpan("operation_name");
span->SetTag("key must be string", "Values are variable types");
span->SetTag("key must be string", 1234);
Values are of variable type and can be complex objects. Values are serialized as JSON, with the exception of a string value being serialized bare (without extra quotation marks).
To set tags across all your spans, set the
DD_TAGS environment variable as a list of
key:value pairs separated by commas.
Set errors on a span
To associate a span with an error, set one or more error-related tags on the
span. For example:
Add more specific information about the error by setting any combination of the
error.type tags. 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
span->SetTag("error.msg", "[EBADF] invalid file");
Adding any of the
error.type tags sets
error to the value
To unset an error on a span, set the
error tag to value
false, which removes
any previously set
// Clear any error information associated with this span.
Manually instrument a method
To manually instrument your code, install the tracer as in the setup examples, and then use the tracer object to create spans.
// Create a root span for the current request.
auto root_span = tracer->StartSpan("get_ingredients");
// Set a resource name for the root span.
// Create a child span with the root span as its parent.
auto child_span = tracer->StartSpan(
// Set a resource name for the child span.
// Spans can be finished at an explicit time ...
} // ... or implicitly when the destructor is invoked.
// For example, root_span finishes here.
Propagating context with headers extraction and injection
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.
Additional helpful documentation, links, and articles: