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
5分でわかるGoの自動計装
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ryuichi1208
February 15, 2024
2.2k
6
Share
5分でわかるGoの自動計装
ryuichi1208
February 15, 2024
More Decks by ryuichi1208
See All by ryuichi1208
会話で作る信頼性
ryuichi1208
0
140
シグナル(Unix)と仲良くなる
ryuichi1208
1
27
AI前提のサービス運用について再考する
ryuichi1208
6
1.4k
A Shallow Dive into the World of TCP
ryuichi1208
1
640
入門リトライ
ryuichi1208
20
8k
超入門SRE 2025
ryuichi1208
4
1.5k
Goで作って学ぶWebSocket
ryuichi1208
5
4.1k
コード化されていない稼働中のサーバを移設_再構築する技術
ryuichi1208
20
15k
AI前提のサービス運用ってなんだろう?
ryuichi1208
9
2k
Featured
See All Featured
Crafting Experiences
bethany
1
100
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
84
Building an army of robots
kneath
306
46k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
How STYLIGHT went responsive
nonsquared
100
6k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
110
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Bash Introduction
62gerente
615
210k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
440
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
700
Documentation Writing (for coders)
carmenintech
77
5.3k
Fireside Chat
paigeccino
42
3.9k
Transcript
1 5分でわかるGoの⾃動計装 渡部 ⿓⼀ OpenTelemetry Meetup 2024-02
技術部プラットフォームグループ 2021年 中途入社 2 自己紹介 渡部 龍一 Watanabe Ryuichi •
ロール: SRE • Otel歴: 半年 • SRE NEXTスタッフ 8/3~4で今年もやります! • SNS: @ryuichi_1208
Goでも⾃動計装されたい! 3
opentelemetry-go-instrumentation 4
5 OpenTelemetryにおける⾃動計装とは https://speakerdeck.com/k6s4i53rx/getting-started-auto-instrumentation-with-opentelemetry
6 • open-telemetry/opentelemetry-go-instrumentation ◦ 2024年2⽉15⽇の時点でも開発中のステータス • Go⾔語で書かれたアプリケーションやライブラリに⾃動的に観測可能性(オブザーバ ビリティ)を提供するプロジェクト • eBPFを使⽤して実装されている
◦ アプリケーションには⼿を加えずに外部のプロセスとして起動するだけでよい • 以下のライブラリに対応している ◦ database/sql ◦ github.com/gin-gonic/gin ◦ google.golang.org/grpc ◦ net/http opentelemetry-go-instrumentationとは
使ってみる 7
8 httpリクエスト httpリクエスト こんなアプリを想定 レスポンスを作って返す
9 こんなアプリを想定
10 こんなアプリを想定
11 • アプリケーションには⼿を⼊れずに分散トレーシングができる • Docker / docker-compose / Kubernetes(kind)で動かす環境が提供されている •
⾃前ビルドでも動かせるのでこれをやってみる opentelemetry-go-instrumentationを使う
12 • Linux with kernel version 4.19 or higher •
x64 or ARM processor • Go 1.18 or higher 制約
13
14
15
どういう仕組み?🤔 16
17 • 引数で渡されたTARGETの⽂字列から/procを検索する • eBPFを⽤いてhttpやDBとのやりとりするuprobesを使って関数にアタッチする ◦ 実⾏時にユーザー空間アプリケーションの任意の部分に動的にフックする ◦ ユーザ空間のアプリケーションに処理を差し込むための仕組み •
httpならリクエストにtraceIDを追記しつつspanを⽣成する ◦ go build -ldflags ʻ-s -w’とかで作られたバイナリでも対応している ◦ offsets-trackerを使ってデバッグ情報なしでも構造体のオフセットを知る仕組み • 内部的にはcilium/ebpfが使われている ◦ eBPF プログラムのロード、コンパイル、デバッグのためのユーティリティを提供するpure Go ライブラリ 仕組み
18 internal/pkg/instrumentation/bpf/net/http/client/bpf/probe.bpf.c
デメリット 19
20 • 関数ごとにトレースを取りたいとかは現状不可能 • 個別のsetAttributeとかもできない ◦ ⼿動軽装のissueはある ◦ https://github.com/open-telemetry/opentelemetry-go-instrumentation/issues/352 •
sampling設定なども現時点ではできない デメリット
⽤途 21
22 • シンプルなネットワークIOのみのサービスで複雑な処理をしない場合 ◦ 画像変換するだけ、外部APIを叩いてProxyするだけ • 複数サービスのうち⼀部のサービスの開発者が不在みたいなケースで⼀時的に伝播を させたい • eBPFプログラミングの練習によさそう
◦ シンボルテーブル⾒てアタッチしてinjectするみたいなのやれば⼀応実現はできるはず ◦ internal/pkg/instrumentation/bpf/net/http/client/probe.go ⽤途
eBPFにはロマンがある 23
24 ご静聴ありがとうございました