Upgrade to Pro — share decks privately, control downloads, hide ads and more …

テイルサンプリングで注意すること / Tail sampling and challenges...

Avatar for ymotongpoo ymotongpoo
February 19, 2026

テイルサンプリングで注意すること / Tail sampling and challenges with OpenTelemetry

OpenTelemetry Meetup in Sapporo での発表資料です
https://opentelemetry.connpass.com/event/376362/

Avatar for ymotongpoo

ymotongpoo

February 19, 2026
Tweet

More Decks by ymotongpoo

Other Decks in Technology

Transcript

  1. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 1 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. テイルサンプリングで注意すること ⼭⼝能迪 (@ymotongpoo) O P E N T E L E M E T R Y M E E T U P I N S A P P O R O アマゾンウェブサービスジャパン合同会社 シニアデベロッパーアドボケイト
  2. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 2 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介 ⼭⼝ 能迪(やまぐち よしふみ) アマゾンウェブサービスジャパン合同会社 シニアデベロッパーアドボケイト 専⾨領域 • オブザーバビリティ • SRE全般 @ymotongpoo
  3. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3 ⼊⾨ OpenTelemetry 3章 OpenTelemetry概要 トレースはトランザクションのオブザーバビリティの 中核です。分散システムのパフォーマンス、健全性、 そして本番環境での挙動を理解するための最良の⽅法 です。
  4. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 4 シナリオ: 分散トレースを取得したい 分散トレースを取得する計装をした
  5. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 5 最初期: ボトルネックが⾒つかって嬉しい • スロークエリが⾒つかった • 不必要な直列処理を発⾒した • 予期しない依存関係を発⾒した
  6. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 6 中期: トレースが多すぎる • ストレージコストが⾼い • 分析ツールが重い(⾃前運⽤) • 計測時のオーバーヘッド • コレクターがSPOF
  7. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 7 解決策1: コレクタープール コレクターを複数⽴てて負荷分散
  8. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8 解決策2: サンプリング ヘッドベースサンプリング 最初のスパンを受け取った瞬間に記録するかを決定 有⼒な⼿法 • 確率的サンプリング • eg. 100回に1回(1%) • ルールベースサンプリング • eg. ヘルスチェックの除外 テイルベースサンプリング 特定のトレースのすべてのスパンを受け取ったあとに 記録するかを決定 有⼒な⼿法 • ルールベースサンプリング • eg. トレース全体のレイテンシー • eg. スパン数の合計 • eg. 特定のスパンが含まれるか
  9. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 9 コレクタープール × テイルベースサンプリングの罠 テイルを知る術がない
  10. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 10 コレクタープール x テイルベースサンプリングの罠 ロードバランサーがトレースIDを ⾒て振り分けないとだめ
  11. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 11 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. デモ
  12. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 12 loadbalancing エクスポーター & tail_sampling プロセッサー https://github.com/ymotongpoo/otel-lb-tailsampling-demo
  13. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 13 loadbalancing エクスポーターの設定 exporters: loadbalancing: routing_key: "traceID" protocol: otlp: resolver: dns: hostname: otel-tier2-internal port: "4317" トレースなら "service", "traceID", "attribute" が有効
  14. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 14 コレクタープール側の設定 kind: Service metadata: name: otel-tier2-internal spec: clusterIP: None # Headlessにする selector: app: otel-tier2 ports: - port: 4317 targetPort: 4317 kind: StatefulSet metadata: name: otel-tier2 spec: serviceName: otel-tier2-internal replicas: 4 selector: matchLabels: app: otel-tier2 template: metadata: labels: app: otel-tier2 Pod名を {StatefulSet名}-{通し番号} で固定
  15. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 15 tail_sampling プロセッサーの設定 processors: batch: tail_sampling: decision_wait: 5s num_traces: 10000 expected_new_traces_per_sec: 100 policies: - name: latency-policy type: latency latency: {threshold_ms: 100}
  16. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 17 チャレンジ OTLP でロードバランサーに送信しているときに起きていること • エクスポーターからロードバランサーへの送信も1つのトレース • ロードバランサーは送信トレースのヘッダー (traceparent) は⾒れる • OTLP over gRPC は内部に複数のトレースデータ (protobuf) を持つ loadbalancing エクスポーター SpanレベルまでProtobufの中⾝を⾒て ルーティングできる。最強。 汎⽤ L4/L7 LB • 送信のトレースのHTTPヘッダしか⾒れない。 • 期待した動作を実現するためにはProtobufの中⾝ を⾒れるような拡張を作る必要がある。 • さらに動的にDNSでコレクターの名前を解決しな いといけない。
  17. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 18 AWS Builder Center で知⾒を共有してください builders.aws.com