The Adventurer’s Guide to Forking the Go Runtime
summary
Creates a reproducible set of rolling patches applied to Go 1.20.7 that inject tracing into the runtime by adding a Trace field to the G struct and hooking goexit/gostart (goxat0/newproc1), plus small overlays for HTTP and database/sql. Uses go:linkname and unsafe to implement hooks outside the runtime, emits OpenTelemetry spans and sends to Jaeger, and traces outbound requests via Traceparent headers. Demo shows per-request tracing without app changes and expands a trace from ~6 spans to 27 spans, revealing DNS/TCP and driver internals.
AI-written summary · about
chapters (19)
- 0:00Start
- 0:35WHAT'S OUR GOAL?
- 1:16FORKS
- 1:58SETTING UP OUR FORK
- 3:44CREATING OUR BUILD SCRIPT
- 4:29OUR FIRST PATCH
- 5:14A SIMPLE APP
- 5:40SOME GO INTERNALS
- 7:28RUNTIME/PROC.GO
- 9:04DEMO APPLICATION
- 10:56WHAT EXACTLY ARE WE GOING TO DO?
- 13:03GETTING OUR CODE COMPILING AGAIN
- 15:49TRACING REQUESTS
- 16:52PATCHING IT IN
- 19:08TRACEPARENT
- 20:12DESIGNING A SIMPLE SPAN API
- 21:19LET'S START RECORDING SPANS
- 22:50PATCH THE BASE QUERY FUNCTION
- 28:25WHAT ABOUT OTHER APPROACHES?
related talks
30mMastering Distributed Tracing with Go
25mTracing Go
22mDynamic Go Instrumentation for Production Environments
39mAuto-Instrumenting Go Libraries for Tracing with eBPF and OpenTelemetry
28mHow to Win Frames and Influence Pointers
34mOpenTelemetry for Dummies: Instrumenting Go Apps
16mLightning Talks
23mIntroduction to OpenTracing
