Datadog を使用したトレースおよび APM 用語の詳細をご覧ください。
トレーシング API は、サービス側の API というよりはむしろ Agent の API です。
トレースをローカルエンドポイント http://localhost:8126/v0.3/traces
に送信して、それを Agent が Datadog に転送できるようにします。
PUT http://localhost:8126/v0.3/tracesNot supported in the EU regionNot supported in the GOV regionNot supported in the US regionNot supported in the US3 region
Datadog の APM を使用すると、コードをトレースしてパフォーマンスメトリクスを収集し、 アプリケーションのどの部分で遅延または非効率が発生しているかを特定することができます。
トレーシングデータは、HTTP API から Datadog Agent に送信されます。 Datadog は、Datadog Agent へのメトリクスの送信を簡略化するために、いくつかの公式ライブラリ を提供しています。ただし、それらのライブラリを使用できないアプリケーションや、 公式の Datadog トレーシングライブラリが まだ提供されていない言語で書かれたアプリケーションを計測するために、 API を直接使用することもできます。
トレースは、次のようなトレースの配列として送信されます。
[ trace1, trace2, trace3 ]
それぞれのトレースは、次のようなスパンの配列です。
trace1 = [ span, span2, span3 ]
さらに、それぞれのスパンは、trace_id
, span_id
, resource
などを含む辞書として機能します。
APM と分散型トレーシングの用語については、こちらを参照してください。
注: 同じトレース内の各スパンは同じ trace_id を使用する必要があります。
しかし、trace_id
と span_id
は異なる値でなければなりません。
フィールド
種類
説明
duration
int64
The duration of the request in nanoseconds.
error
int32
Set this value to 1 to indicate if an error occurred.
If an error occurs, you should pass additional information, such as the error message, type and stack information in the meta property.
meta
object
A set of key-value metadata. Keys and values must be strings.
<any-key>
string
Additional properties for key-value metadata.
metrics
object
A set of key-value metadata. Keys must be strings and values must be 64-bit floating point numbers.
<any-key>
double
Additional properties for key-value metrics.
name
string
The span name. The span name must not be longer than 100 characters.
parent_id
int64
The span integer ID of the parent span.
resource
string
The resource you are tracing. The resource name must not be longer than 5000 characters.
service
string
The service you are tracing. The service name must not be longer than 100 characters.
span_id
int64
The span integer (64-bit unsigned) ID.
start
int64
The start time of the request in nanoseconds from the UNIX epoch.
trace_id
int64
The unique integer (64-bit unsigned) ID of the trace containing this span.
type
enum
The type of request.
Allowed enum values: web,db,cache,custom
[
[
{
"duration": 12345,
"error": "integer",
"meta": {
"<any-key>": "string"
},
"metrics": {
"<any-key>": "number"
},
"name": "span_name",
"parent_id": "integer",
"resource": "/home",
"service": "service_name",
"span_id": 987654321,
"start": 0,
"trace_id": 123456789,
"type": "web"
}
]
]
OK
# Curl command
curl -X PUT "http://localhost:8126/v0.3/traces" \
-H "Content-Type: application/json" \
-d @- << EOF
[
[
{
"duration": 12345,
"name": "span_name",
"resource": "/home",
"service": "service_name",
"span_id": 987654321,
"start": 0,
"trace_id": 123456789
}
]
]
EOF