7. Count Connector でメトリクスを作成する

7.3 Sum Connector のテスト

1 min

Exercise

Gateway を起動する Gateway terminal ウィンドウで以下を実行します

bash
../otelcol --config=gateway.yaml

Agent を起動する Agent terminal ウィンドウで以下を実行します

bash
../otelcol --config=agent.yaml

Loadgen を起動する Spans terminal ウィンドウで、以下の loadgen コマンドを使用して8つのスパンを送信します

bash
../loadgen -count 8

AgentGateway の両方がデバッグ情報を表示し、データを処理していることを示します。loadgen が完了するまで待ちます。

メトリクスを確認する スパンを処理する際、Agent はメトリクスを生成して Gateway に転送します。Gateway はそれらを gateway-metrics.out に書き込みます。

メトリクス出力に user.card-charge が存在し、それぞれに user.name 属性があることを確認するには、以下の jq クエリを実行します

bash
jq -r '.resourceMetrics[].scopeMetrics[].metrics[] | select(.name == "user.card-charge") | .sum.dataPoints[] | "\(.attributes[] | select(.key == "user.name").value.stringValue)\t\(.asDouble)"' gateway-metrics.out | while IFS=$'\t' read -r name charge; do
    printf "%-20s %s\n" "$name" "$charge"
done

Info

それぞれのターミナルで Ctrl-C を押して AgentGateway のプロセスを停止してください。