Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Sending Metrics to Telemetry through OpenCensus...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Moriyoshi Koizumi
August 30, 2019
Programming
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Sending Metrics to Telemetry through OpenCensus & Python
Moriyoshi Koizumi
August 30, 2019
More Decks by Moriyoshi Koizumi
See All by Moriyoshi Koizumi
Detailing Python's Coroutine out of History
moriyoshi
9
2.1k
Hacking Go Compiler Internals - 2nd season
moriyoshi
5
5.7k
(Not Very) Practical Concurrent Design Patterns in Go
moriyoshi
2
5.3k
Hacking Go Compiler Internals
moriyoshi
0
130
Other Decks in Programming
See All in Programming
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
Jetpack Compose メカニズム
skydoves
0
470
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
170
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
160
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
350
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
440
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
0
150
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.3k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
310
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
170
Heart of Swift Concurrency
koher
0
960
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
250
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
280
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
260
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
280
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
76k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Transcript
OpenCensusを通じて Stackdriver Monitoringを Pythonから使う 2019/8/30 マジフェス
Telemetryとは • アプリケーションの様々な文脈における挙動をアプリケーションの 外から「測定・解析」するしくみ • なぜ重要か? • 現代的なアプリケーション、とくにwebアプリケーションのアーキテクチャ は様々な文脈で切り取り可能な複数の層に渡っていて、それぞれの層におい て、多数のコンポーネントから構成されている
• 文脈の例: • (ネットワークサービス) DB/ミドルウェア/アプリケーションサーバ • (アプリケーションサービス) マイクロサービスA/マイクロサービスB/マイクロサー ビスC • (コールグラフ) フレームワーク/FWミドルウェア/リクエストハンドラ/DBアクセッ サ • サービス品質の維持のためには、ログ監視のような「点」の観測では限界が ある。
Telemetryに求められる要件 • コンポーネント横断的な計測可能性 • とくにマイクロサービスのような設計手法においては、ある目的を達 成するために、処理のパイプラインが複数のコンポーネントに横断的 に存在することが多い • 意味のある計測を行うためには、telemetryを行う側で関数、OSプロ セスなどを跨った計測結果を受け入れできるようにしなければならな
い
Telemetryを構成する2つの概念 • Metrics • アプリケーションの動作状況を表す数値的な指標をある時間間隔で採 取し、健康状態やサービス品質の統計的に把握する。 • Tracing • アプリケーションの特定の文脈における挙動を時間の帯としてとらえ、
稼働中のアプリケーションのボトルネックといった「面」に現れる問 題を把握する。
Telemetryを構成する2つの概念 Metrics Read Data Convert Data Send JSON Response Merge
Data Tracing Read Response Send JSON 1 User Request Session
OpenCensusとは • Telemetryの概念群を実装するベンダー中立なライブラリ/フ レームワーク • 2018年にGoogleで開始され、その後Microsoftなどが参加 • 2019年4月にOpenTracingとの合流を発表し、CNCF傘下の OpenTelemetryプロジェクトとして活動を開始
OpenCensusの構造 Stats Tracing Span View Measure View Measure View Measure
Span Trace Trace Trace Trace Stats Exporter Tracing Exporter
PythonでOpenCensusを使う • opencensus パッケージ • Exporterに依存しない部分 • opencensus-ext-xxxxxx • Exporterパッケージ
(例: opencensus-ext-stackdriver) • 各フレームワーク・ライブラリ用のインテグレーション用パッケージ
PythonでOpenCensus経由でmetricsを送る • 準備 • Measureをつくる • Viewをつくり、MeasureをViewに関連付ける • ViewをViewManagerに関連付ける •
ExporterをViewManagerに関連付ける • 実行時にやること • StatsRecorderからMeasurementMapをつくる • MeasurementMap.record() を呼び出す
Measureをつくる
Viewをつくる
Aggregationについて 送信側のaggregation処理 SumAggregation – 送信間隔の間に記録されたデータポイントの値が累積され、送信される CountAggregation – 送信間隔の間にデータポイントの記録があった回数が送信される LastValueAggregation –
最後に送信されたデータポイントの値が記録される 受信側のaggregation Cumulative – 受信側で適宜alignment期間ごとに累積される (SumAggregationに対応) Gauge – 送信された値がそのまま表示される (CountAggregation, LastValueAggregation に対応) 送信間隔 時間
ViewをViewManagerに紐づける • view_managerは opencensus.stats.stats._Stats クラスが持っている • モジュールグローバル変数 opencensus.stats.stats.stats に _Stats
クラスのシングルトンオ ブジェクトが格納されている
ExporterをViewManagerに紐づける
StatsRecorderからMeasurementMapをつくる MeasurementMapにMeasureを書き出す • 送信タイミングになると自動的にそれまでにrecordされたデータポイントが記録される • プロセスが途中で終了すると、次の送信タイミングに送信されるはずだったデータポイントは 送信されない! (多分バグ!)