Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tracing for Granularity
Search
JBD
June 02, 2018
Programming
2
1.8k
Tracing for Granularity
JBD
June 02, 2018
Tweet
Share
More Decks by JBD
See All by JBD
eBPF in Microservices Observability at eBPF Day
rakyll
1
2k
eBPF in Microservices Observability
rakyll
1
1.6k
OpenTelemetry at AWS
rakyll
1
1.8k
Debugging Code Generation in Go
rakyll
5
1.5k
Are you ready for production?
rakyll
8
2.6k
Servers are doomed to fail
rakyll
3
1.5k
Serverless Containers
rakyll
1
240
Critical Path Analysis
rakyll
0
500
Monitoring and Debugging Containers
rakyll
2
1.1k
Other Decks in Programming
See All in Programming
Debugging: All you need to know (for simultaneous interpreting)
jmatsu
2
800
大公開!iOS開発の悩みトップ5 〜iOSDC Japan 2024〜
ryunakayama
0
190
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
2k
意外とフォントが大事だった話 / Font Issues on Internationalization
fumi23
0
110
GraphQLの魅力を引き出すAndroidクライアント実装
morux2
3
660
状態管理ライブラリZustandの導入から運用まで
k1tikurisu
3
470
メモリ最適化を究める!iOSアプリ開発における5つの重要なポイント
yhirakawa333
0
420
Android開発以外のAndroid開発経験の活かしどころ
konifar
2
1k
Jakarta EE meets AI
ivargrimstad
1
520
Crafting Cross-Platform Adventures: Building a Game Engine with Kotlin Multiplatform
dwursteisen
0
120
2024 컴포즈 정원사
jisungbin
0
150
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
170
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
89
16k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
363
22k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Clear Off the Table
cherdarchuk
91
320k
Bash Introduction
62gerente
608
210k
How to Ace a Technical Interview
jacobian
274
23k
Design by the Numbers
sachag
277
19k
How GitHub Uses GitHub to Build GitHub
holman
472
290k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
278
13k
What's new in Ruby 2.0
geeforr
340
31k
Why You Should Never Use an ORM
jnunemaker
PRO
53
8.9k
Transcript
tracing for granularity JBD, Google (@rakyll)
@rakyll
@rakyll tracing? What is tracing and why do we trace?
@rakyll
@rakyll clogged?
@rakyll leaking?
@rakyll path and direction?
@rakyll 100% availability (is a lie)
“ @rakyll A service is available if users cannot tell
there was an outage.
@rakyll Without an SLO, your team has no principled way
of saying what level of downtime is acceptable. • Error rate • Latency or throughput expectations Service Level Objectives (SLOs)
@rakyll 28 ms 100 ms 172 ms 56 ms 356
ms what user sees what else we can see sec.Check auth.AccessToken cache.Lookup spanner.Query GET /messages
@rakyll 182 ms 56 ms 245 ms what user sees
what else we can see sec.Check auth.AccessToken GET /messages 7 ms cache.Lookup
@rakyll latency...
@rakyll Go is the language to write servers. Many runtime
activities occur during the program execution: • scheduling • memory allocation • garbage collection Hard to associate a request with its impact on the runtime.
@rakyll clogged?
“ @rakyll There is no easy way to tell why
latency is high for certain requests. Is it due to GC, scheduler or syscalls? Can you review the code and tell us why? -SRE
@rakyll Execution tracer $ go tool trace • Reports fine-grained
runtime events in the lifetime of a goroutine. • Reports utilization of CPU cores. But cannot easily tell how handling a request impacts the runtime.
@rakyll 28 ms 100 ms 172 ms 56 ms 356
ms GET /messages auth.AccessToken cache.Lookup spanner.Query GET /messages
@rakyll 5 68µs 8 123µs networking serialization + deserialization garbage
collection blocking syscall what actually happens 172 ms auth.AccessToken
@rakyll 5 68µs 8 123µs epoll executing sys gc netwrite
@rakyll How? • Mark sections in code using runtime/trace. •
Enable execution tracer temporarily and record data. • Examine the recorded data.
@rakyll Go 1.11 introduces... • User regions, tasks and annotations.
• Association between user code and runtime. • Association with distributed traces.
@rakyll Go 1.11 runtime/trace import “runtime/trace” ctx, task := trace.NewTask(ctx,
“myHandler”) defer task.End() // Handler code here....
@rakyll region #1 task #1 Go 1.11 runtime/trace region #2
region #3 region #4 region #5 goroutine #1 goroutine #4 goroutine #5
@rakyll import _ "net/http/pprof" go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }()
@rakyll $ curl http://server:6060/debug/pprof/trace?seconds=5 -o trace.out $ go tool trace
trace.out 2018/05/04 10:39:59 Parsing trace... 2018/05/04 10:39:59 Splitting trace... 2018/05/04 10:39:59 Opening browser. Trace viewer is listening on http://127.0.0.1:51803
Execution tracer tasks for RPCs (/usertasks)
Execution tracer tasks for RPCs (/usertasks)
RPCs overlapping with garbage collection
Execution tracer regions (/userregions)
Region summary for conn.ready
@rakyll Record in production $ curl http://server/debug/pprof/trace?seconds=5 -o trace.out $
go tool trace trace.out
@rakyll Try It! Install the Go 1.11 beta1! golang.org/dl
@rakyll $ go get go.opencensus.io/trace import rt “runtime/trace” ctx, span
:= trace.StartSpan(ctx, “/messages”) defer span.End() rt.WithRegion(ctx, “foo”, func(ctx) { // Do something... })
@rakyll Limitations • Execution tracer cannot do accounting for cross-goroutine
operations automatically. • Exposition format is hard to parse if `go trace tool` is not used.
thank you! JBD, Google
[email protected]
@rakyll