Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

オブザーバビリティ

Tazuna は OpenTelemetry ベースのトレーシングを組み込みでサポートします。 すべての CLI コマンドが OTLP/gRPC 経由で trace を export でき、CI / クラスタ運用上の 時間計測やエラー追跡に使えます。

トレーシングは opt-in です。何もフラグを渡さなければ no-op tracer が使われ、 外部依存はゼロのままです。

有効化

ルートコマンドに次のグローバルフラグが追加されています。

フラグデフォルト説明
--otlp-endpointstring""OTLP/gRPC collector のエンドポイント(例: localhost:4317)。空文字なら no-op。
--otlp-insecurebooltrueOTLP exporter でプレーンテキスト gRPC を使う(TLS 無し)。

--otlp-endpoint を渡したコマンドだけが trace を発火します。短命 CLI が collector に ぶら下がってしまわないよう、shutdown には 5 秒のタイムアウトが入っています。

# Jaeger / Tempo / OTel Collector など、OTLP/gRPC を受けられる先に向ける
tazuna apply -f tazuna.yaml --otlp-endpoint=localhost:4317
tazuna plan  -f tazuna.yaml --otlp-endpoint=localhost:4317

トレースの構造

Tazuna は 3 階層の trace tree を出します。

tazuna.Apply / tazuna.Plan / tazuna.Status / tazuna.StateDrift  ← Runner top-level span
  └── tazuna.ApplyToCluster                                      ← Runner internal span
        └── Kustomize.Apply / Helmfile.Apply / GenesisSecret.Apply / ORAS.Apply
                                                                 ← Manager span
  • Runner span(tracer 名 tazuna/runner)— トップレベルコマンドの実行時間を まとめて測ります。CLI から最初に開く span です。
  • Manager span(tracer 名 tazuna/manager)— 各 Manifest type 固有の処理 (kubectl apply 相当 / helmfile sync / oras pull / etc.)を 1 span ずつ計測します。

Runner span と Manager span の名前を分けてあるので、Datadog / Jaeger 等で service / operation 単位の分析がしやすくなっています。

主な span attribute

Attribute付くタイミング値の例
tazuna.yaml.pathRunner span./tazuna.yaml
manifests.countRunner span12
apply.synctazuna.Apply spantrue / false
apply.prunetazuna.Apply spantrue / false
apply.atomictazuna.Apply spantrue / false
manifest.nameManager spaningress-nginx
manifest.typeManager spankustomize / helmfile / oras / genesissecret
manifest.pathManager span./kustomize/ingress
genesissecret.providerGenesisSecret.Apply spanprimary-op / default-op

エラー時には span に error ステータスが付き、メッセージは span.RecordError で ぶら下がります。

CI での使い方

Datadog / Honeycomb / Grafana Cloud などの SaaS collector を使うと、apply の所要時間や 失敗率を時系列で追えます。CI から渡す例:

# GitHub Actions
- name: tazuna apply (with tracing)
  env:
    OTEL_EXPORTER_OTLP_HEADERS: api-key=${{ secrets.OTEL_API_KEY }}
  run: tazuna apply -f tazuna.yaml --otlp-endpoint=otel.example.com:4317

short-lived な CLI なので、collector 側で service.name=tazuna で絞ると、CI run ごとの span tree がそのまま見えるはずです。

関連