isutools

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 7 Imported by: 0

README

isutools

ISUCON 向けオールインワン計測モジュール。go get + 2行でアプリに組み込み、 SQL / HTTP / GraphQL / アクセスログ / プロセスリソースをブラウザでソート済み表示する。

  • 設計書: DESIGN.md
  • Status: M1 実装済み(SQL 計測 + snapshot UI + buildinfo + host 情報)

使い方(組み込みは1行)

db, _ = sqlx.Open(isutools.SQLDriverName("mysql"), dsn) // 既存の sqlx.Open を書き換えるだけ

これだけで管理サーバが 127.0.0.1:19191 に起動する(ISUTOOLS_ADDR で変更・off で無効):

  • GET :19191/ — ライブレポート(合計時間降順ソート済み)
  • GET :19191/snapshot.html — 自己完結 HTML をダウンロード(手元の PC でダブルクリックで閲覧)
  • GET :19191/json — 機械可読出力(前回世代との比較用に prev 付き)
  • POST :19191/reset — 集計リセット(ベンチ前に叩く。世代番号が進む)
  • ISUTOOLS=off で全機能無効(素のドライバ名を返すため、オーバーヘッドゼロ)

管理サーバはアプリのルーター・nginx を経由しないため外部に露出しない。 同一ポートに載せたい場合は isutools.Handler() を任意のルーターに Mount してもよい。

レポートには git revision(+dirty)・ホスト情報(CPU モデル / コア数 / メモリ GB / OS)が常に表示される。

対応対象(Phase 1)

MySQL / MariaDB / PostgreSQL / nginx / Apache / GraphQL / HTTP 1.1 / HTTP/2 / HTTP/3 (QUIC) / git hash (+dirty) / プロセス CPU・メモリ

Documentation

Overview

Package isutools is an all-in-one profiling module for ISUCON-style tuning: wrap your SQL driver, download sorted reports.

Minimal integration (1 line):

db, _ := sqlx.Open(isutools.SQLDriverName("mysql"), dsn)

SQLDriverName also starts a small admin server (default 127.0.0.1:19191, override with ISUTOOLS_ADDR, disable with ISUTOOLS_ADDR=off) serving the report UI, snapshot export, and POST /reset — the control channel for bench scripts. It intentionally runs on its own port so the application router and reverse proxy never expose it.

ISUTOOLS=off disables everything: SQLDriverName then returns the raw driver name, so the application runs unproxied with zero overhead. The on/off decision is made once at startup; it is not dynamic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler() http.Handler

Handler serves the report UI: GET / (live), GET /snapshot.html (download), GET /json, POST /reset.

func Off

func Off() bool

Off reports whether measurement is globally disabled via ISUTOOLS=off.

func RegisterSQL

func RegisterSQL(names ...string) error

RegisterSQL wraps the named drivers ("mysql", "pgx", ...) and registers measuring variants under "<name>:isutools". Prefer SQLDriverName, which also resolves the on/off decision. No-op when disabled.

func SQLDriverName

func SQLDriverName(name string) string

SQLDriverName registers a measuring wrapper for the named driver and returns the driver name the application should open. When disabled — or if registration fails — it returns the raw name unchanged, so measurement can never break application startup (fail-open). On success it also starts the admin server once.

Types

This section is empty.

Directories

Path Synopsis
adapters
chiv5 module
echov4 module
Package buildinfo resolves the git revision and dirty state of the running binary: from Go's embedded VCS stamps when available, otherwise from ldflags-injected variables or environment variables.
Package buildinfo resolves the git revision and dirty state of the running binary: from Go's embedded VCS stamps when available, otherwise from ldflags-injected variables or environment variables.
internal
agg
Package agg is the shared aggregation core: a concurrency-safe, bounded key→latency table with log2-bucket histograms for approximate percentiles.
Package agg is the shared aggregation core: a concurrency-safe, bounded key→latency table with log2-bucket histograms for approximate percentiles.
sysinfo
Package sysinfo resolves static host facts (CPU model, core count, total memory, OS) shown in every report so measurements are always attributable to the hardware they ran on.
Package sysinfo resolves static host facts (CPU model, core count, total memory, OS) shown in every report so measurements are always attributable to the hardware they ran on.
Package sqlstats wraps database/sql drivers with a measuring proxy and aggregates every query into an in-memory table.
Package sqlstats wraps database/sql drivers with a measuring proxy and aggregates every query into an in-memory table.
Package web renders isutools measurements: a live report, a self-contained downloadable snapshot.html, machine-readable JSON, and a reset endpoint.
Package web renders isutools measurements: a live report, a self-contained downloadable snapshot.html, machine-readable JSON, and a reset endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL