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
Flight recorder at the application layer (NOT t...
Search
Ken’ichiro Oyama
August 25, 2025
Technology
0
33
Flight recorder at the application layer (NOT the FlightRecoder newly added at Go 1.25) / Fukuoka.go #22
https://fukuokago.connpass.com/event/364970/
Ken’ichiro Oyama
August 25, 2025
Tweet
Share
More Decks by Ken’ichiro Oyama
See All by Ken’ichiro Oyama
ソフトウェア開発におけるインターフェイスという考え方 / PHPerKaigi 2025
k1low
9
5.3k
Parsing HCL/CUE / Fukuoka.go #21
k1low
0
8k
実践 net/http Middleware パターン / Kizuku.go Vol.1
k1low
2
340
Cleanup handling in Go / Go Conference 2024
k1low
6
3.7k
CI/CDがあたりまえの今の時代にAPIテスティングツールに求められていること / CI/CD Test Night #7
k1low
18
11k
Command-line interface tool design / PHPerKaigi 2024
k1low
8
3.4k
gostyle IS NOT Go Style / Fukuoka.go#19 Reboot
k1low
1
290
Parsing case study in Go / Go Conference mini 2023 Winter IN KYOTO
k1low
2
1.4k
APIシナリオテストツールとしてのrunn / 4 API testing tools
k1low
3
1.7k
Other Decks in Technology
See All in Technology
[kickflow]20250319_少人数チームでのAutify活用
otouhujej
0
190
RAID6 を楔形文字で組んで現代人を怖がらせましょう(実装編)
mimifuwa
0
200
AIと描く、未来のBacklog 〜プロジェクト管理の次の10年を想像し、創造するセッション〜
hrm_o25
0
120
九州の人に知ってもらいたいGISスポット / gis spot in kyushu 2025
sakaik
0
220
GCASアップデート(202506-202508)
techniczna
0
230
PFEM Online Feature Flag @ newmo
shinyaishitobi
2
270
リモートワークで心掛けていること 〜AI活用編〜
naoki85
0
200
サイボウズフロントエンドの横断活動から考える AI時代にできること
mugi_uno
3
1.3k
datadog-distribution-of-opentelemetry-collector-intro
tetsuya28
0
190
Gaze-LLE: Gaze Target Estimation via Large-Scale Learned Encoders
kzykmyzw
0
280
Delegate authentication and a lot more to Keycloak with OpenID Connect
ahus1
0
240
Android Studio の 新しいAI機能を試してみよう / Try out the new AI features in Android Studio
yanzm
0
170
Featured
See All Featured
Writing Fast Ruby
sferik
628
62k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Done Done
chrislema
185
16k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
1k
The World Runs on Bad Software
bkeepers
PRO
70
11k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
810
Building an army of robots
kneath
306
45k
KATA
mclloyd
32
14k
Balancing Empowerment & Direction
lara
2
580
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Transcript
Flight recorder at the application layer (NOT the FlightRecoder newly
added at Go 1.25) ⼩⼭健⼀郎 / Tailor Inc. 2025.8.25 Fukuoka.go #22
• Go 1.25で runtime/trace 追加された機能 ◦ https://pkg.go.dev/runtime/trace#FlightRecorder • トレースデータのサイズや継続的な書き込みコストから従来の実⾏トレースキャプチャでは実⽤的でな かった稀なイベントのデバッグに役にたつ軽量な実⾏トレースキャプチャ。
• 仕組みとしては実⾏トレースをインメモリのリングバッファに継続的に記録し、重要なイベントが発⽣し た際に、FlightRecorder.WriteTo を呼び出すことで、直近のトレースをファイルに書き出す。 • 直前の、必要なトレースのみをキャプチャできるため、⽣成されるトレースが⼤幅に⼩さくなる。 ◦ 従来の実⾏トレースのように⾼コストではないため、常に有効にしやすい。 • FlightRecorderConfig 内で、キャプチャする期間やデータ量を設定できる runtime/trace.FlightRecorder 2
• goroutine creation/blocking/unblocking (Goroutineの作成/ブロック/ブロック解除) • syscall enter/exit/block (System callの⼊⼒/終了/ブロック) •
GC-related events (GC 関連イベント) • changes of heap size (ヒープサイズの変更) • processor start/stop (プロセッサの開始/停⽌) • etc. runtime/trace で取得できるトレースデータ 3
• エラーが発⽣したときに原因を特定したい • コードのどこでエラーになったのか • エラーになるまでにどのような処理をしていたのか • (OSSのCLIツールとして提供しているのでOtelは使いにくい) つまり、スタックトレースや実⾏ログが欲しい アプリケーションレイヤで欲しいトレースデータ
4
• エラー時にスタックトレースと直前のログをまとめてファイルに書き出す ◦ 全てのログは必要ない。 https://pkg.go.dev/runtime/trace#FlightRecorder と同じ • ログは LogLevel=Debug な詳細なログが欲しい
アプリケーションレイヤのFlight recorder 5
スタックトレース 6
• https://github.com/k1LoW/errors • errors + stack staces. • 実装コンセプトは ◦
Retain the stack traces once stacked as far as possible. ▪ Support for errors.Join. ◦ It is possible to output stack traces in structured data. ◦ Zero dependency k1LoW/errors 7
直前のデバッグログ 8
• ユーザがログレベルをハンドリングするログハンドラと、Flight recorder⽤のログハンドラの2つに分ける ◦ Flight recorder⽤のログは常に LogLevel=Debug • log/slog だと
https://github.com/samber/slog-multi を使うと良い まずログを分岐する 9
• https://github.com/k1LoW/tail • 直近N⾏だけを保持する io.Writer を満たす実装 k1LoW/tail 10
11 完成
12
少し実⽤的で⼩さなOSSを書くのが趣味 • GitHub: @k1LoW • X: @k1LoW • SWE at
Tailor Inc. ⾃⼰紹介 13 Ken'ichiro Oyama ⼩⼭健⼀郎
14 わたしたちは、"Empower every company to deploy any ideas (誰もがデプロイできる社会を創る)" というミッ
ションのもと、誰しもがプロダクト開発の担い⼿になることができる社会の実現を⽬指しています。ミッション の実現に向けて、共に挑戦する仲間を募集しています。 https://careers.tailor.tech/ 共に働く仲間を募集しています