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
1.8k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tracing for Granularity
JBD
June 02, 2018
More Decks by JBD
See All by JBD
eBPF in Microservices Observability at eBPF Day
rakyll
1
2.2k
eBPF in Microservices Observability
rakyll
1
1.8k
OpenTelemetry at AWS
rakyll
1
1.9k
Debugging Code Generation in Go
rakyll
5
1.7k
Are you ready for production?
rakyll
8
3k
Servers are doomed to fail
rakyll
3
1.6k
Serverless Containers
rakyll
1
300
Critical Path Analysis
rakyll
0
710
Monitoring and Debugging Containers
rakyll
2
1.2k
Other Decks in Programming
See All in Programming
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
200
MySQLとPostgreSQLって何が違うの?
akagami
0
120
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
160
源内ハンズオン概要編
hideg
0
210
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
350
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
250
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
130
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
100
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
400
Go 1.27 における memory allocation の高速化
andpad
0
300
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
400
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.5k
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Designing Experiences People Love
moore
143
24k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
500
Design in an AI World
tapps
1
290
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
Exploring anti-patterns in Rails
aemeredith
3
470
Amusing Abliteration
ianozsvald
1
260
WCS-LA-2024
lcolladotor
0
800
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
480
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
270
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
570
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