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
My Favorite Talks at GopherCon 2019
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuki Ito
August 20, 2019
Technology
2.1k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
My Favorite Talks at GopherCon 2019
Yuki Ito
August 20, 2019
More Decks by Yuki Ito
See All by Yuki Ito
newmo の創業を支える Software Architecture と Platform Engineering
110y
5
3.7k
Modular Monolith Go Server with GraphQL Federation + gRPC
110y
1
1.2k
Modular Monolith + Go @ newmo
110y
1
1.3k
Go + GraphQL @ newmo
110y
3
1k
Architect / Platform Team at KAUCHE
110y
1
730
Cloud Run + Observability / Reliability @ KAUCHE
110y
0
690
Cloud Run CI/CD + QA @ KAUCHE
110y
1
690
Microservices on Cloud Run @ KAUCHE
110y
0
330
KAUCHE Loves Go
110y
0
550
Other Decks in Technology
See All in Technology
Webとヘルスデータ
yukukotani
1
350
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
110
DEFCON_CHV_CTF_Write-up.pdf
bata_24
0
130
KPIだけでは評価できないプロダクトが考えるべき Evalsという第二の評価系 / Beyond KPIs: Evals as a Second Evaluation Framework for Products #PdEConf
aki_iinuma
4
3.9k
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
150
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
450
AIネイティブプロダクトで顧客価値を最大化するプロダクトエンジニアとFDEの協働
righttouch
PRO
0
220
AI時代のAPI品質を支えるガードレール / API Guardrails for API quality in the AI era
yokawasa
1
210
module Synths; end
asonas
1
130
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
250
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
250
2026-09-09 【sigma_ucj#1】Sigma を IaC 管理したい! / IaC for Sigma
civitaspo
0
110
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
690
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
GitHub's CSS Performance
jonrohan
1033
470k
We Are The Robots
honzajavorek
0
360
[SF Ruby Conf 2025] Rails X
palkan
2
1.4k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Scaling GitHub
holman
464
140k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Speed Design
sergeychernyshev
33
2.1k
Leo the Paperboy
mayatellez
9
2.3k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Transcript
1 My Favorite Talks at GopherCon 2019 Yuki ITO
Table of Contents !2 Observability in Go Socket to Me:
Where do Sockets Live in Go? Day 0 (Pre-Conference Workshop): Day 2:
Table of Contents !3 Observability in Go Socket to Me:
Where do Sockets Live in Go? Day 0 (Pre-Conference Workshop): Day 2:
Observability in Go !4 https://github.com/freeformz/go-observability-workshop/ Repository
Observability in Go !5 Log Trace Metric 3 Pillars for
Observability
Observability in Go !6 Log Trace Metric 3 Pillars for
Observability
Logs !7 log package func handler(w http.ResponseWriter, r *http.Request) {
status := http.StatusOK // net/http returns 200 by default defer func(t time.Time) { log.Printf( "%s %q => %d (%2.3fs)\n", r.Method, r.URL.String(), status, time.Since(t).Seconds(), ) }(time.Now()) // … }
Logs !8 log package func main() { log.SetFlags(log.Flags() | log.Lshortfile)
log.Println("Listening at: http://localhost:" + port) http.ListenAndServe(":"+port, nil) // ... } 2019/08/20 19:00:00 server.go:54: Listening at: http://localhost:8080
Logs !9 Structured Logs github.com/sirupsen/logrus 2019/08/20 19:00:00 server.go:54: Listening at:
http://localhost:8080 { “level”:"info", "msg":"Listening at: http://localhost:8080”, “time":"2019-07-17T21:26:08-07:00" }
!10 Log Trace Metric How should we log? If the
only observability tool we have is logs, then we should log everything.
!11 Log Trace Metric How should we log? If we
have metrics and traces, then reduce logging to important events meant largely for human consumption.
Observability in Go !12 Log Trace Metric 3 Pillars for
Observability
Metrics !13 expvar package import ( "expvar" // ... )
func main() { // ... // Expose the port value ep := expvar.NewString("Port") ep.Set(port) http.ListenAndServe(":"+port, nil) //... }
Metrics !14 expvar package package expvar // ... func init()
{ http.HandleFunc("/debug/vars", expvarHandler) Publish("cmdline", Func(cmdline)) Publish("memstats", Func(memstats)) }
Metrics !15 expvar package $ curl -s http://localhost:8080/debug/vars | jq
.Port "8080"
Metrics !16 expvar makes us be able to expose metrics
We can recognize only `current status` of system. Hoever…
Metrics !17 Prometheus Time Series Database
Metrics !18 import ( // ... "github.com/prometheus/client_golang/prometheus/promhttp" ) func main()
{ // ... http.Handle("/metrics", promhttp.Handler()) // … http.ListenAndServe(":"+port, nil) // ... }
Metrics !19 Pull Model Prometheus Scrape `/metrics` Application server
Metrics !20
Observability in Go !21 Log Trace Metric 3 Pillars for
Observability
Traces !22 Microservices ServiceB ServiceA
Traces !23 Distributed Tracing Jaeger
Traces !24 import ( // ... "contrib.go.opencensus.io/exporter/jaeger" "go.opencensus.io/trace" ) func
main() { je, err := jaeger.NewExporter(jaeger.Options{ CollectorEndpoint: "http://localhost:14268/api/traces", Process: jaeger.Process{ ServiceName: "servicea", Tags: []jaeger.Tag{ jaeger.StringTag("server", "1"), jaeger.StringTag("port", port), jaeger.BoolTag("demo", true), }, }, }) trace.RegisterExporter(je) }
Traces !25 func queryServiceBHandler(c *http.Client, url string) http.HandlerFunc { return
func(w http.ResponseWriter, r *http.Request) { ctx, span := trace.StartSpan( r.Context(), "queryServiceBHandler", ) defer span.End() // ... } }
Traces !26
Traces !27
Observability in Go !28 Log Trace Metric 3 Pillars for
Observability
Table of Contents !29 Observability in Go Socket to Me:
Where do Sockets Live in Go? Day 0 (Pre-Conference Workshop): Day 2:
!30 System calls under net.Listen & Accept https://about.sourcegraph.com/go/gophercon-2019-socket-to-me-where-do-sockets-live-in-go
!31 System calls under net.Listen & Accept https://about.sourcegraph.com/go/gophercon-2019-socket-to-me-where-do-sockets-live-in-go
!32 func (srv *Server) Serve(l net.Listener) error { // ...
for { rw, e := l.Accept() // ... c := srv.newConn(rw) go c.serve(ctx) } } Socket to me net/http/server.go
!33 System calls under net.Listen & Accept https://about.sourcegraph.com/go/gophercon-2019-socket-to-me-where-do-sockets-live-in-go
Socket Options in Go !34 ListenConfig.Listen() ListenConfig.Control RawConn.Control() Callback to
set socket options
Socket Options in Go !35 https://github.com/110y/sockoptgo/ Example Implementation
Socket Options in Go !36 ListenConfig.Listen() ListenConfig.Control RawConn.Control() Callback to
set socket options
!37 func Listen(network, address string) (Listener, error) { var lc
ListenConfig return lc.Listen(context.Background(), network, address) } net.Listen() Socket Options in Go
!38 Socket Options in Go lc := net.ListenConfig{ Control: listenControler,
} lis, err := lc.Listen(ctx, "tcp4", addr)
Socket Options in Go !39 ListenConfig.Listen() ListenConfig.Control RawConn.Control() Callback to
set socket options
!40 func listenControler(network, address string, c syscall.RawConn) error { return
c.Control(func(fd uintptr) { syscall.SetsockoptInt( int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1, ) }) } Socket Options in Go
!41 func listenControler(network, address string, c syscall.RawConn) error { return
c.Control(func(fd uintptr) { syscall.SetsockoptInt( int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1, ) }) } Socket Options in Go
Table of Contents !42 Observability in Go Socket to Me:
Where do Sockets Live in Go? Day 0 (Pre-Conference Workshop): Day 2: